From: Luiz Angelo Daros de Luca <luizl...@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

Signed-off-by: Luiz Angelo Daros de Luca <luizl...@gmail.com>
---
 interface-ip.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/interface-ip.c b/interface-ip.c
index 648f521..7c60fec 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -301,9 +301,26 @@ interface_ip_add_target_route(union if_addr *addr, bool 
v6, struct interface *if
        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;
+       if (r_next->flags & DEVROUTE_MTU) {
+               route->mtu = r_next->mtu;
+               route->flags |= DEVROUTE_MTU;
+       }
+       if (r_next->flags & DEVROUTE_METRIC) {
+               route->metric = r_next->metric;
+               route->flags |= DEVROUTE_METRIC;
+       }
+       if (r_next->flags & DEVROUTE_TABLE) {
+               route->table = r_next->table;
+               route->flags |= DEVROUTE_TABLE;
+       }
+       if (r_next->flags & DEVROUTE_TYPE) {
+               route->type = r_next->type;
+               route->flags |= DEVROUTE_TYPE;
+       }
+       if (r_next->flags & DEVROUTE_ONLINK)
+               route->flags |= DEVROUTE_ONLINK;
+       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@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to