From: Steven Barth Date: Wed, 26 Feb 2014 13:21:48 +0000 (+0100) Subject: Don't always assume routes & addresses are applied X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4d09244bc73a3b8bc8168366526e4ddded41057e;p=oweals%2Fnetifd.git Don't always assume routes & addresses are applied Actually check netlink return values and remember failure. Signed-off-by: Steven Barth --- diff --git a/interface-ip.c b/interface-ip.c index 3bd92cf..b1abbc6 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -480,7 +480,7 @@ interface_update_proto_addr(struct vlist_tree *tree, if (a_new && a_old) { keep = true; - if (a_old->flags != a_new->flags) + if (a_old->flags != a_new->flags || a_old->failed) keep = false; if (a_old->valid_until != a_new->valid_until || @@ -521,7 +521,8 @@ interface_update_proto_addr(struct vlist_tree *tree, if (node_new) { a_new->enabled = true; if (!(a_new->flags & DEVADDR_EXTERNAL) && (!keep || replace)) { - system_add_address(dev, a_new); + if (system_add_address(dev, a_new)) + a_new->failed = true; if (!keep) { if ((a_new->flags & DEVADDR_FAMILY) == DEVADDR_INET6) @@ -575,7 +576,7 @@ interface_update_proto_route(struct vlist_tree *tree, if (node_old && node_new) keep = !memcmp(&route_old->nexthop, &route_new->nexthop, sizeof(route_old->nexthop)) && - (route_old->table == route_new->table); + (route_old->table == route_new->table) && !route_old->failed; if (node_old) { if (!(route_old->flags & DEVADDR_EXTERNAL) && route_old->enabled && !keep) @@ -591,7 +592,8 @@ interface_update_proto_route(struct vlist_tree *tree, route_new->metric = iface->metric; if (!(route_new->flags & DEVADDR_EXTERNAL) && !keep && _enabled) - system_add_route(dev, route_new); + if (system_add_route(dev, route_new)) + route_new->failed = true; route_new->iface = iface; route_new->enabled = _enabled; diff --git a/interface-ip.h b/interface-ip.h index 2559bcc..de8343d 100644 --- a/interface-ip.h +++ b/interface-ip.h @@ -77,6 +77,7 @@ struct device_prefix { struct device_addr { struct vlist_node node; bool enabled; + bool failed; /* ipv4 only */ uint32_t broadcast; @@ -99,6 +100,7 @@ struct device_route { bool enabled; bool keep; + bool failed; union if_addr nexthop; int mtu;