[LEDE-DEV] RFC [PATCH] odhcpd: don't enable server mode on dhcp lan

Daniel Golle daniel at makrotopia.org
Thu Aug 31 10:46:17 PDT 2017


Hi Karl,

On Thu, Aug 31, 2017 at 05:17:38PM +0000, Karl Palsson wrote:
> Instead of blindly enabling the odhcpd v6 server and RA server on the
> lan port, only do that if the lan port isn't set to DHCP.
> 
> This prevents the unhelpful case of a device being a dhcpv4 client and
> v6 server on the same ethernet port.

Generating UCI from presumingly already generated UCI has proven to be
a bad practise in the past. See inline for an alternative approach.

> 
> Signed-off-by: Karl Palsson <karlp at etactica.com>
> -- 
> 
> Should other protocols be excluded?  The list on https://lede-project.org/docs/user-guide/network_configuration
> is rather long.  Are there other modes worth considering?
> 
> ---
>  package/network/services/odhcpd/files/odhcpd.defaults | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/package/network/services/odhcpd/files/odhcpd.defaults b/package/network/services/odhcpd/files/odhcpd.defaults
> index e184da90acbb..152e63dd18b6 100644
> --- a/package/network/services/odhcpd/files/odhcpd.defaults
> +++ b/package/network/services/odhcpd/files/odhcpd.defaults
> @@ -2,13 +2,23 @@
>  uci -q get dhcp.odhcpd && exit 0
>  touch /etc/config/dhcp
>  
> +LANPROTO=$(uci -q get network.lan.proto)

Imho it'd be nicer to read this via
```
. /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 ..
```


> +MODE=server
> +
> +case "$LANPROTO" in
> +"dhcp")
> +	echo "odhcpd: Not enabling server mode on a dhcp lan!" > /dev/kmsg
> +	MODE=disabled
> +	;;
> +esac
> +
>  uci batch <<EOF
>  set dhcp.odhcpd=odhcpd
>  set dhcp.odhcpd.maindhcp=0
>  set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
>  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
> 
> 
> _______________________________________________
> Lede-dev mailing list
> Lede-dev at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev



More information about the Lede-dev mailing list