From: Steven Barth Date: Tue, 19 May 2015 08:58:34 +0000 (+0200) Subject: ipv6: use kernel >= 3.14 handling of offlink-addresses X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=8faa5b30b12ee3e4d06a8d2557d1f112f1f2786e;p=project%2Fnetifd.git ipv6: use kernel >= 3.14 handling of offlink-addresses Signed-off-by: Steven Barth --- diff --git a/interface-ip.c b/interface-ip.c index 1a22ce6..18dd2fa 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -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); diff --git a/system-linux.c b/system-linux.c index a6734a4..bfd623b 100644 --- a/system-linux.c +++ b/system-linux.c @@ -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;