[LEDE-DEV] [PATCHv2] odhcpd: don't enable server mode on non-static lan port
Karl Palsson
karlp at etactica.com
Fri Sep 1 04:22:11 PDT 2017
Instead of blindly enabling the odhcpd v6 server and RA server on the
lan port, only do that if the lan port protocol is "static"
This prevents the unhelpful case of a device being a dhcpv4 client and
v6 server on the same ethernet port.
Signed-off-by: Karl Palsson <karlp at etactica.com>
---
Changes since v1
* use /etc/board.json instead of assuming uci has been updated
* make server _only_ for static, instead of everything but dhcp
* remove logging, no other early service logs anything
package/network/services/odhcpd/files/odhcpd.defaults | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/package/network/services/odhcpd/files/odhcpd.defaults b/package/network/services/odhcpd/files/odhcpd.defaults
index e184da90acbb..e9b2353f063b 100644
--- a/package/network/services/odhcpd/files/odhcpd.defaults
+++ b/package/network/services/odhcpd/files/odhcpd.defaults
@@ -2,6 +2,21 @@
uci -q get dhcp.odhcpd && exit 0
touch /etc/config/dhcp
+. /usr/share/libubox/jshn.sh
+
+json_load "$(cat /etc/board.json)"
+json_select network
+json_select lan
+json_get_vars protocol
+json_select ..
+json_select ..
+
+case "$protocol" in
+# only enable server mode on statically addressed lan ports
+"static") MODE=server ;;
+*) MODE=disabled ;;
+esac
+
uci batch <<EOF
set dhcp.odhcpd=odhcpd
set dhcp.odhcpd.maindhcp=0
@@ -10,5 +25,7 @@ set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
set dhcp.odhcpd.loglevel=4
set dhcp.lan.dhcpv6=server
set dhcp.lan.ra=server
+set dhcp.lan.dhcpv6=$MODE
+set dhcp.lan.ra=$MODE
commit dhcp
EOF
--
2.4.11
More information about the Lede-dev
mailing list