[OpenWrt-Devel] Custom init.d script switching LAN static -> dhcp triggers reload <-> hostapd race

Flavio Alves flawioo at gmail.com
Fri Sep 14 08:08:44 EDT 2018


Hi Rafal,
In my opinion you should make this config in uci-defaults.

That's pretty simple and can works as you want.

Em sex, 14 de set de 2018 08:49, Rafał Miłecki <zajec5 at gmail.com> escreveu:

> My custom OpenWrt 18.06 builds have LAN interface configured as static:
>
> config interface lan
>         option ifname   'eth0.1'
>         option type     'bridge'
>         option proto    'static'
>         option ipaddr   '192.168.0.1'
>         option netmask  '255.255.255.0'
>
>
> Then I have a following init.d script:
>
> START=99
> start() {
>         [ "$(nvram get use_dhcp)" = "1" ] && {
>                 logger -t "lan-switcher" "Switching lan to DHCP"
>                 uci set network.lan.proto=dhcp
>                 uci commit network
>                 /etc/init.d/network reload
>         }
> }
>
>
> The first observation: booting order always differs slightly. Using the
> same firmware & firstboot produces slightly different log on every boot.
>
>
> The real problem: in some cases my init.d script kicks in in such a
> moment that causes a race between netifd reload (triggered by a script)
> and hostapd start. If hostapd happens to start while netifd is reloading
> lan config (it removes interface to switch it into dhcp mode) it results
> in:
>
> Thu Sep 13 18:11:16 2018 daemon.err hostapd: Configuration file:
> /var/run/hostapd-phy1.conf
> Thu Sep 13 18:11:16 2018 daemon.err hostapd: nl80211: Failed to add
> interface wlan1 into bridge br-lan: No such device
>
>
> My question is whether there is any good & simple solution to that?
> Should I fix my script? Or can netifd get some internal mutex/sync that
> will stop it from reloading interfaces & starting hostapd at the same
> time?
>
>
> I'm attaching two logs with netifd's debugging included.
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20180914/7732e8f0/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list