ipv6: use kernel >= 3.14 handling of offlink-addresses
authorSteven Barth <steven@midlink.org>
Tue, 19 May 2015 08:58:34 +0000 (10:58 +0200)
committerSteven Barth <steven@midlink.org>
Tue, 19 May 2015 08:58:34 +0000 (10:58 +0200)
Signed-off-by: Steven Barth <steven@midlink.org>
interface-ip.c
system-linux.c

index 1a22ce635206ad0cd2f85ad9c625593e11601de3..18dd2fa72027ddfccb4c8b6bc3be5f7b999a582f 100644 (file)
@@ -442,6 +442,9 @@ interface_handle_subnet_route(struct interface *iface, struct device_addr *addr,
        struct device *dev = iface->l3_dev.dev;
        struct device_route route;
 
+       if (addr->flags & DEVADDR_OFFLINK)
+               return;
+
        memset(&route, 0, sizeof(route));
        route.iface = iface;
        route.flags = addr->flags;
@@ -453,14 +456,11 @@ interface_handle_subnet_route(struct interface *iface, struct device_addr *addr,
                route.flags |= DEVADDR_KERNEL;
                system_del_route(dev, &route);
 
-               if (!(addr->flags & DEVADDR_OFFLINK)) {
-                       route.flags &= ~DEVADDR_KERNEL;
-                       route.metric = iface->metric;
-                       system_add_route(dev, &route);
-               }
+               route.flags &= ~DEVADDR_KERNEL;
+               route.metric = iface->metric;
+               system_add_route(dev, &route);
        } else {
-               if (!(addr->flags & DEVADDR_OFFLINK))
-                       system_del_route(dev, &route);
+               system_del_route(dev, &route);
        }
 }
 
@@ -562,7 +562,7 @@ interface_update_proto_addr(struct vlist_tree *tree,
                                }
                        }
 
-                       if ((a_new->flags & DEVADDR_OFFLINK) || iface->metric)
+                       if (iface->metric)
                                interface_handle_subnet_route(iface, a_new, true);
                }
        }
@@ -1228,7 +1228,7 @@ void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled)
 
                if (enabled) {
                        system_add_address(dev, addr);
-                       if ((addr->flags & DEVADDR_OFFLINK) || iface->metric)
+                       if (iface->metric)
                                interface_handle_subnet_route(iface, addr, true);
                } else {
                        interface_handle_subnet_route(iface, addr, false);
index a6734a4bed7b39a8680f521d7ae850dc2398a3c6..bfd623b8825651995449cea0073cb5074609dce2 100644 (file)
@@ -1427,6 +1427,7 @@ static int system_addr(struct device *dev, struct device_addr *addr, int cmd)
                .ifa_family = (alen == 4) ? AF_INET : AF_INET6,
                .ifa_prefixlen = addr->mask,
                .ifa_index = dev->ifindex,
+               .ifa_flags = (addr->flags & DEVADDR_OFFLINK) ? IFA_F_NOPREFIXROUTE : 0,
        };
 
        struct nl_msg *msg;