Don't always assume routes & addresses are applied
authorSteven Barth <steven@midlink.org>
Wed, 26 Feb 2014 13:21:48 +0000 (14:21 +0100)
committerSteven Barth <steven@midlink.org>
Wed, 26 Feb 2014 13:21:48 +0000 (14:21 +0100)
Actually check netlink return values and remember failure.

Signed-off-by: Steven Barth <steven@midlink.org>
interface-ip.c
interface-ip.h

index 3bd92cf49198c22b0d1b845e5f31b44c082f1a64..b1abbc60de4557edf5017f4f202077a78058b9d9 100644 (file)
@@ -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;
index 2559bccc4adc1b946a2acce77555dd04a72b744c..de8343d04e14643a135b14fdd7948ad440f5e6a5 100644 (file)
@@ -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;