[PATCH 2/2] interface-ip: copy more info for target host route

Hans Dedecker dedeckeh at gmail.com
Sun Nov 28 07:54:56 PST 2021


On Tue, Nov 23, 2021 at 3:06 AM <luizluca at gmail.com> wrote:
>
> From: Luiz Angelo Daros de Luca <luizluca at gmail.com>
>
> interface_ip_add_target_route was adding a host route without
> copying other confs like type, source, online). The result was that this:
>
>   unreachable 192.168.0.9  metric 123
>
> was being converted to:
>
>   192.168.0.9 dev lo scope link  metric 123
>
> valid_until is still not copied but I'm not sure if it is needed as this
> route might get updated when the source route is refreshed/expired.
>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca at gmail.com>
> ---
>  interface-ip.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/interface-ip.c b/interface-ip.c
> index 7b63ef9..6fdbf18 100644
> --- a/interface-ip.c
> +++ b/interface-ip.c
> @@ -300,12 +300,17 @@ interface_ip_add_target_route(union if_addr *addr, bool v6, struct interface *if
>                 return NULL;
>
>         route->flags = v6 ? DEVADDR_INET6 : DEVADDR_INET4;
> +       route->flags |= r->next & (DEVROUTE_MTU | DEVROUTE_METRIC |
> +                       DEVROUTE_TYPE | DEVROUTE_ONLINK | DEVROUTE_TABLE);
The patch fails to compile :
route->flags |= r->next & (DEVROUTE_MTU | DEVROUTE_METRIC |
     |                         ^
interface-ip.c:303:25: note: each undeclared identifier is reported
only once for each function it appears in
interface-ip.c: At top level:

Hans
>         route->mask = v6 ? 128 : 32;
>         memcpy(&route->addr, addr, addrsize);
>         memcpy(&route->nexthop, &r_next->nexthop, sizeof(route->nexthop));
>         route->mtu = r_next->mtu;
>         route->metric = r_next->metric;
>         route->table = r_next->table;
> +       route->type = r_next->type;
> +       memcpy(&route->source, &r_next->source, addrsize);
> +       route->sourcemask = r_next->sourcemask;
>         route->iface = iface;
>         vlist_add(&iface->host_routes, &route->node, route);
>
> --
> 2.33.1
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list