[OpenWrt-Devel] [PATCH 2/3] [RESEND] netifd : Apply interface metric on subnet routes when reloading ip

Hans Dedecker dedeckeh at gmail.com
Thu Oct 23 05:12:54 EDT 2014


Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 interface-ip.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/interface-ip.c b/interface-ip.c
index 62d15fd..1459e9c 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -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,16 @@ 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;
 	}
 
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list