From: Hans Dedecker Date: Mon, 10 Mar 2014 15:27:52 +0000 (+0100) Subject: netifd: Assign interface metric to route metric when route is created X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ceeed831285357d125f71b9a3b4c27de50af49e6;p=oweals%2Fnetifd.git 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 --- 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;