Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Oct 2015 12:30:47 -0700
From:      NGie Cooper <yaneurabeya@gmail.com>
To:        lev@FreeBSD.org
Cc:        freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: What changed in rc.d infrastructure in last months?
Message-ID:  <DA78289A-176E-44EF-A2A2-1CEE10DF54ED@gmail.com>
In-Reply-To: <16610120144.20151025222025@serebryakov.spb.ru>
References:  <16610120144.20151025222025@serebryakov.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

> On Oct 25, 2015, at 12:20, Lev Serebryakov <lev@FreeBSD.org> wrote:
>=20
> Hello freebsd-current,
>=20
>=20
> New version of -CURRENT try to configure wlan0 and run hostapd twice:
>=20
> 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=3D455).
> em1: link state changed to UP
> eltel: link state changed to UP
> skynet: link state changed to UP
> Starting Network: wlan0.
>=20
> 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:
>=20
> wlans_ath0=3D"wlan0"
> create_args_wlan0=3D"wlanmode hostap bssid"
> ifconfig_wlan0=3D"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"
>=20
> I DON'T have "hostapd_enable=E2=80=9D!

etc/rc.d/hostapd is written a bit weird for an rc.d script. It doesn=E2=80=
=99t check =E2=80=9Chostapd_enable=E2=80=9D in the case where it=E2=80=99s=
 explicitly provided an interface:

15 ifn=3D"$2"
16 if [ -z "$ifn" ]; then
17         rcvar=3D"hostapd_enable"
18         conf_file=3D"/etc/${name}.conf"
19         pidfile=3D"/var/run/${name}.pid"
20 else
21         rcvar=3D
22         conf_file=3D"/etc/${name}-${ifn}.conf"
23         pidfile=3D"/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=3D0          # XXX: not sure this should count
 224         elif hostapif $1; then
 225                 /etc/rc.d/hostapd start $1
 226                 _cfg=3D0
 227         fi
 =E2=80=A6
 251         if wpaif $1; then
 252                 /etc/rc.d/wpa_supplicant stop $1
 253                 _cfg=3D0
 254         elif hostapif $1; then
 255                 /etc/rc.d/hostapd stop $1
 256                 _cfg=3D0
 257         fi

What determines whether or not it=E2=80=99s 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=3D`_ifconfig_getargs $1`
 451=20
 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=20
 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=3D202726 for more =
details.

Cheers!
-NGie=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DA78289A-176E-44EF-A2A2-1CEE10DF54ED>