Skip to content

Commit

Permalink
netifd: update dhcp.script to handle dynamic routing
Browse files Browse the repository at this point in the history
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@nxp.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
  • Loading branch information
Mogula Pranay authored and dedeckeh committed Jan 10, 2018
1 parent 18f4944 commit 012d20e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 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
Expand Down
8 changes: 7 additions & 1 deletion package/network/config/netifd/files/lib/netifd/dhcp.script
Expand Up @@ -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
Expand Down

0 comments on commit 012d20e

Please sign in to comment.