From ceeed831285357d125f71b9a3b4c27de50af49e6 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Mon, 10 Mar 2014 16:27:52 +0100 Subject: [PATCH] netifd: Assign interface metric to route metric when route is created Interface metric needs to be assigned to the route metric parameter at route creation time. Otherwise if the interface metric is different from 0 route_cmp will wrongly conclude the routes are different. In this case the route will be added/deleted and could end up with the route missing in the kernel depending on the add/delete order. Signed-off-by: Hans Dedecker --- interface-ip.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interface-ip.c b/interface-ip.c index b1abbc6..d5a3832 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -322,7 +322,8 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) if ((cur = tb[ROUTE_METRIC]) != NULL) { route->metric = blobmsg_get_u32(cur); route->flags |= DEVROUTE_METRIC; - } + } else + route->metric = iface->metric; if ((cur = tb[ROUTE_MTU]) != NULL) { route->mtu = blobmsg_get_u32(cur); @@ -588,9 +589,6 @@ interface_update_proto_route(struct vlist_tree *tree, if (node_new) { bool _enabled = enable_route(ip, route_new); - if (!(route_new->flags & DEVROUTE_METRIC)) - route_new->metric = iface->metric; - if (!(route_new->flags & DEVADDR_EXTERNAL) && !keep && _enabled) if (system_add_route(dev, route_new)) route_new->failed = true; -- 2.25.1