[openwrt/openwrt] netifd: update dhcp.script to handle dynamic routing

LEDE Commits lede-commits at lists.infradead.org
Wed Jan 10 00:21:41 PST 2018


dedeckeh pushed a commit to openwrt/openwrt.git, branch master:
https://git.lede-project.org/012d20eebe3aec0818aa949eb7b14754640df797

commit 012d20eebe3aec0818aa949eb7b14754640df797
Author: Mogula Pranay <mogula.pranay at nxp.com>
AuthorDate: Tue Jan 9 11:43:29 2018 +0530

    netifd: update dhcp.script to handle dynamic routing
    
    Certain DHCP servers push a gateway outside of the assigned interface subnet,
    to support those situations, install a host route towards the gateway.
    
    If Gateway and IP are served in same network, openwrt quagga cannot learn
    routes (rip routes are not getting added, showing inactive) whereas
    working fine when Gateway and IP are in different network.
    
    Signed-off-by: Mogula Pranay <mogula.pranay at nxp.com>
    Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 package/network/config/netifd/Makefile                     | 2 +-
 package/network/config/netifd/files/lib/netifd/dhcp.script | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
index 4eb4737..3efcd30 100644
--- a/package/network/config/netifd/Makefile
+++ b/package/network/config/netifd/Makefile
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=netifd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(LEDE_GIT)/project/netifd.git
diff --git a/package/network/config/netifd/files/lib/netifd/dhcp.script b/package/network/config/netifd/files/lib/netifd/dhcp.script
index 24f243c..00604f4 100755
--- a/package/network/config/netifd/files/lib/netifd/dhcp.script
+++ b/package/network/config/netifd/files/lib/netifd/dhcp.script
@@ -18,9 +18,15 @@ setup_interface () {
 	proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}"
 	# TODO: apply $broadcast
 
+	local ip_net
+	eval "$(ipcalc.sh "$ip/$mask")";ip_net="$NETWORK"
+
 	local i
 	for i in $router; do
-		proto_add_ipv4_route "$i" 32 "" "$ip"
+		local gw_net
+		eval "$(ipcalc.sh "$i/$mask")";gw_net="$NETWORK"
+
+		[ "$ip_net" != "$gw_net" ] && proto_add_ipv4_route "$i" 32 "" "$ip"
 		proto_add_ipv4_route 0.0.0.0 0 "$i" "$ip"
 
 		local r



More information about the lede-commits mailing list