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

luizluca at gmail.com luizluca at gmail.com
Mon Nov 22 18:04:52 PST 2021


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);
 	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




More information about the openwrt-devel mailing list