What changed in rc.d infrastructure in last months?

NGie Cooper yaneurabeya at gmail.com
Sun Oct 25 19:30:49 UTC 2015


> On Oct 25, 2015, at 12:20, Lev Serebryakov <lev at FreeBSD.org> wrote:
> 
> Hello freebsd-current,
> 
> 
> New version of -CURRENT try to configure wlan0 and run hostapd twice:
> 
> Created wlan(4) interfaces: wlan0.
> Created clone interfaces: gif0.
> em0: link state changed to UP
> em0: link state changed to DOWN
> ifconfig: NONE: bad value
> vlan0: changing name to 'skynet'
> vlan1: changing name to 'eltel'
> Starting hostapd.
> Configuration file: /etc/hostapd-wlan0.conf
> Using interface wlan0 with hwaddr 00:15:6d:85:5f:fc and ssid "home.serebryakov.spb.ru"
> wlan0: interface state UNINITIALIZED->ENABLED
> wlan0: AP-ENABLED
> gif0: link state changed to UP
> Starting Network: lo0 em0 em1 wlan0 gif0.
> ....
> Starting devd.
> ifconfig: SIOCS80211: Device busy
> hostapd already running?  (pid=455).
> em1: link state changed to UP
> eltel: link state changed to UP
> skynet: link state changed to UP
> Starting Network: wlan0.
> 
> Before this there was no second try to run hostapd. What should I change in
> /etc/rc.d to eliminate this double-run and double-configuration? Now I
> have:
> 
> wlans_ath0="wlan0"
> create_args_wlan0="wlanmode hostap bssid"
> ifconfig_wlan0="HOSTAP inet 192.168.135.1 netmask 255.255.255.0 mode 11ng channel 3:ht/40 -bgscan ssid home.serebryakov.spb.ru country DE regdomain row txpower 30"
> 
> I DON'T have "hostapd_enable”!

etc/rc.d/hostapd is written a bit weird for an rc.d script. It doesn’t check “hostapd_enable” in the case where it’s explicitly provided an interface:

15 ifn="$2"
16 if [ -z "$ifn" ]; then
17         rcvar="hostapd_enable"
18         conf_file="/etc/${name}.conf"
19         pidfile="/var/run/${name}.pid"
20 else
21         rcvar=
22         conf_file="/etc/${name}-${ifn}.conf"
23         pidfile="/var/run/${name}-${ifn}.pid"
24 fi

This scenario is trigged by network.subr:

 221         if wpaif $1; then
 222                 /etc/rc.d/wpa_supplicant start $1
 223                 _cfg=0          # XXX: not sure this should count
 224         elif hostapif $1; then
 225                 /etc/rc.d/hostapd start $1
 226                 _cfg=0
 227         fi
 …
 251         if wpaif $1; then
 252                 /etc/rc.d/wpa_supplicant stop $1
 253                 _cfg=0
 254         elif hostapif $1; then
 255                 /etc/rc.d/hostapd stop $1
 256                 _cfg=0
 257         fi

What determines whether or not it’s a hostapif? Whether or not `hostap` is in ifconfig_<interface>.

 445 # hostapif if
 446 #       Returns 0 if the interface is a HOSTAP interface and 1 otherwise.
 447 hostapif()
 448 {
 449         local _tmpargs _arg
 450         _tmpargs=`_ifconfig_getargs $1`
 451 
 452         for _arg in $_tmpargs; do
 453                 case $_arg in
 454                 [Hh][Oo][Ss][Tt][Aa][Pp])
 455                         return 0
 456                         ;;
 457                 esac
 458         done
 459 
 460         return 1
 461 }

This [the hostapd start/stop logic] all gets triggered whenever the interface goes up and down.

glebius broke etc/rc.d/{devd,ldconfig} back in April by reordering the dependencies, which can affect this. See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202726 for more details.

Cheers!
-NGie


More information about the freebsd-current mailing list