[LEDE-DEV] RFC [PATCH] odhcpd: don't enable server mode on dhcp lan
Karl Palsson
karlp at tweak.net.au
Thu Aug 31 14:35:55 PDT 2017
Daniel Golle <daniel at 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 at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/lede-dev
>
> _______________________________________________
> Lede-dev mailing list
> Lede-dev at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.html
Type: application/pgp-signature
Size: 1161 bytes
Desc: OpenPGP Digital Signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20170831/c2eef977/attachment.sig>
More information about the Lede-dev
mailing list