On 01.09.2017 00:35, Karl Palsson wrote:
Daniel Golle <dan...@makrotopia.org> wrote:
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.
Cool with me, the json_load approach is..... kinda opaque still
at the moment, but if that's the future and meant to be magically
more stable, awesome. (This file was _already_ looking at "uci -q
get dhcp.odhcpd" not using any json loading, so... I just
followed the course)

But the general concept? Is that ok? That's more interesting to
me :)

Sincerely,
Karl Palsson

  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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev
_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

I personally would like something like that because there are times when I forget to disable the server mode and it may confuse the users


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to