netifd : Apply interface metric on subnet routes when reloading ip
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 23 Oct 2014 09:12:54 +0000 (11:12 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 24 Oct 2014 17:54:26 +0000 (19:54 +0200)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface-ip.c

index 62d15fd7477e07fa38a401c2c28cf033d22c404b..6659f8bac16dc0a3ad974250103e0201e7272034 100644 (file)
@@ -1154,9 +1154,11 @@ void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled)
        struct device_addr *addr;
        struct device_route *route;
        struct device *dev;
+       struct interface *iface;
 
        ip->enabled = enabled;
-       dev = ip->iface->l3_dev.dev;
+       iface = ip->iface;
+       dev = iface->l3_dev.dev;
        if (!dev)
                return;
 
@@ -1164,10 +1166,14 @@ void interface_ip_set_enabled(struct interface_ip_settings *ip, bool enabled)
                if (addr->enabled == enabled)
                        continue;
 
-               if (enabled)
+               if (enabled) {
                        system_add_address(dev, addr);
-               else
+                       if ((addr->flags & DEVADDR_OFFLINK) || iface->metric)
+                               interface_handle_subnet_route(iface, addr, true);
+               } else {
+                       interface_handle_subnet_route(iface, addr, false);
                        system_del_address(dev, addr);
+               }
                addr->enabled = enabled;
        }