Re: What changed in rc.d infrastructure in last months?

2015-10-26 Thread Adrian Chadd
On 26 October 2015 at 01:27, Lev Serebryakov  wrote:
> Hello NGie,
>
> Sunday, October 25, 2015, 11:09:03 PM, you wrote:
>
>
>> Ok, this is really not making sense from a design perspective.
>> `ifconfig_` is being overloaded for starting up hostap’s (even though
>> ifconfig itself doesn’t support hostap — only `wlanmode ap`). I don’t
>  ifconfig doesn't support dhcp either, but dhclient is run via "DHCP" in
>  `ficonfig_`
>
>> understand why it was done this way instead of just creating additional
>> variables for `hostapd_`
>  Long time ago there was simple `hostapd_enable` and `hostapd_interfaces` :)
>  But it doesn't allow to automagically start hostapd for hotplugged (i.e.
>  USB) interfaces. On the other hand, automatic DHCP on hot-plugged
>  interfaces have sense and automatic hostapd doesn't, IMHO.

This sounds like the same issue as double-running wpa_supplicant.

I thought this was fixed already :( Would someone please figure out a
cleanish solution to this? I'd really appreciate it.


-a
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-26 Thread Lev Serebryakov
Hello NGie,

Sunday, October 25, 2015, 11:09:03 PM, you wrote:


> Ok, this is really not making sense from a design perspective.
> `ifconfig_` is being overloaded for starting up hostap’s (even though
> ifconfig itself doesn’t support hostap — only `wlanmode ap`). I don’t
 ifconfig doesn't support dhcp either, but dhclient is run via "DHCP" in
 `ficonfig_`

> understand why it was done this way instead of just creating additional
> variables for `hostapd_`
 Long time ago there was simple `hostapd_enable` and `hostapd_interfaces` :)
 But it doesn't allow to automagically start hostapd for hotplugged (i.e.
 USB) interfaces. On the other hand, automatic DHCP on hot-plugged
 interfaces have sense and automatic hostapd doesn't, IMHO.

-- 
Best regards,
 Levmailto:l...@freebsd.org

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-26 Thread John Baldwin
On Monday, October 26, 2015 04:38:21 AM Adrian Chadd wrote:
> On 26 October 2015 at 01:27, Lev Serebryakov  wrote:
> > Hello NGie,
> >
> > Sunday, October 25, 2015, 11:09:03 PM, you wrote:
> >
> >
> >> Ok, this is really not making sense from a design perspective.
> >> `ifconfig_` is being overloaded for starting up hostap’s (even though
> >> ifconfig itself doesn’t support hostap — only `wlanmode ap`). I don’t
> >  ifconfig doesn't support dhcp either, but dhclient is run via "DHCP" in
> >  `ficonfig_`
> >
> >> understand why it was done this way instead of just creating additional
> >> variables for `hostapd_`
> >  Long time ago there was simple `hostapd_enable` and `hostapd_interfaces` :)
> >  But it doesn't allow to automagically start hostapd for hotplugged (i.e.
> >  USB) interfaces. On the other hand, automatic DHCP on hot-plugged
> >  interfaces have sense and automatic hostapd doesn't, IMHO.
> 
> This sounds like the same issue as double-running wpa_supplicant.
> 
> I thought this was fixed already :( Would someone please figure out a
> cleanish solution to this? I'd really appreciate it.

Note that /etc/pccard_ether bails right away if the interface is marked up
without doing anything.  That is what is supposed to make devd events at
boot get ignored.  (See the initial loop in pccard_ether_start().)

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread Adrian Chadd
Hm, poke glebius? He went and rototilled bits of net80211 recently and
that did touch the rc scripts.


-a


On 25 October 2015 at 12:20, Lev Serebryakov  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"!
>
> --
> Best regards,
>  Lev  mailto:l...@freebsd.org
>
> ___
> freebsd-current@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread NGie Cooper

> On Oct 25, 2015, at 12:39, Lev Serebryakov  wrote:
> 
> Hello NGie,
> 
> Sunday, October 25, 2015, 10:30:47 PM, you wrote:
> 
> 
>> This [the hostapd start/stop logic] all gets triggered whenever the 
>> interface goes up and down.
>  So, first time hostapd is started by /etc/rc.d/netif before devd, and
> second time devd call /etc/rc.d/netif again on interface up, am I right?
> 
>  It looks weird.

It depends on how it’s setup. Is your interface is using DHCP and are you using 
the stock devd.conf file? From etc/devd.conf:

 55 notify 0 {
 56 match "system"  "IFNET";
 57 match "type""LINK_UP";
 58 media-type  "ethernet";
 59 action "/etc/rc.d/dhclient quietstart $subsystem";
 60 };
 …
 74 notify 0 {
 75 match "system"  "IFNET";
 76 match "type""LINK_UP";
 77 media-type  "802.11";
 78 action "/etc/rc.d/dhclient quietstart $subsystem";
 79 };

Thanks!
-NGie
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread Lev Serebryakov
Hello NGie,

Sunday, October 25, 2015, 10:45:10 PM, you wrote:

> It depends on how it’s setup. Is your interface is using DHCP and are you
> using the stock devd.conf file? From etc/devd.conf:
  devd.conf is stock one, but, of course, HOSTAP-interface uses static
 address. One more time:

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"

 Everything works, but this  double-configuration of wlan and double-start
of hostpad looks ugly.

-- 
Best regards,
 Levmailto:l...@freebsd.org

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread NGie Cooper

> On Oct 25, 2015, at 12:54, NGie Cooper  wrote:

...

> I’ll need to double-check the rcorder and get back to you on that.

Answering this part: nope. devd still gets started after netif on my branch, so 
it’ll still start hostapd twice:

$ rcorder `make -VFILES SRCCONF=/dev/null`
growfs
...
netif
devd
...
$

Thanks,
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread NGie Cooper

> On Oct 25, 2015, at 12:58, NGie Cooper  wrote:
> 
> 
>> On Oct 25, 2015, at 12:54, NGie Cooper  wrote:
> 
> ...
> 
>> I’ll need to double-check the rcorder and get back to you on that.
> 
> Answering this part: nope. devd still gets started after netif on my branch, 
> so it’ll still start hostapd twice:
> 
> $ rcorder `make -VFILES SRCCONF=/dev/null`
> growfs
> ...
> netif
> devd
> ...
> $

Ok, this is really not making sense from a design perspective. `ifconfig_` 
is being overloaded for starting up hostap’s (even though ifconfig itself 
doesn’t support hostap — only `wlanmode ap`). I don’t understand why it was 
done this way instead of just creating additional variables for 
`hostapd_`, similar to `ifconfig_` (other than maybe, it simplified 
things because `_ifconfig_getargs` could be used to grab the variables from 
`ifconfig_` — but it seems like a kludge to me).

I’d need to boot up FreeBSD on one of my PC laptops to confirm what the 
behavior is (the earliest I will likely be able to do this is later on today).

$ grep -r hostap sbin/ifconfig/
sbin/ifconfig/ifconfig.8:.Cm hostap ),
sbin/ifconfig/ifconfig.8:.Cm hostap
sbin/ifconfig/ifconfig.8:.Xr hostapd 8
$

Thanks,
-NGie
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread NGie Cooper

> On Oct 25, 2015, at 12:20, Lev Serebryakov  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_.

 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
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread Lev Serebryakov
Hello NGie,

Sunday, October 25, 2015, 10:30:47 PM, you wrote:


> This [the hostapd start/stop logic] all gets triggered whenever the interface 
> goes up and down.
  So, first time hostapd is started by /etc/rc.d/netif before devd, and
 second time devd call /etc/rc.d/netif again on interface up, am I right?

  It looks weird.

> 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.

-- 
Best regards,
 Levmailto:l...@freebsd.org

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread NGie Cooper

> On Oct 25, 2015, at 12:30, NGie Cooper  wrote:

…

> 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 }

Here’s an example of how this works, by the way:

$ sh find_hostapifs.sh
wlan1 is!
$ cat find_hostapifs.sh
. /etc/rc.subr
load_rc_config

. /etc/network.subr
for i in em0 wlan0 wlan1; do
hostapif $i && echo "$i is!”
done
$ grep ^ifconfig /etc/rc.conf
ifconfig_em0="inet W.X.Y.Z netmask 255.255.255.0"
ifconfig_em0_ipv6="inet6 accept_rtadv"
ifconfig_wlan0="inet 127.0.0.2/8"
ifconfig_wlan1=“hostap”
$

It’s documented here:

 On the other hand, if you want to configure your wireless
 interface with hostapd(8), you need to add ``HOSTAP'' to the
 ifconfig_ variable.  hostapd(8) will use the
 settings from /etc/hostapd-.conf

Cheers,
-NGie
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread Lev Serebryakov
Hello NGie,

Sunday, October 25, 2015, 10:39:51 PM, you wrote:


> It’s documented here:

>  On the other hand, if you want to configure your wireless
>  interface with hostapd(8), you need to add ``HOSTAP'' to the
>  ifconfig_ variable.  hostapd(8) will use the
>  settings from /etc/hostapd-.conf
 I understand this, and as you can see from my config samples, I'm using
exactly this feature.

 I'm wonder why ifconfig & hostapd try to start TWICE now for same
interaface in course of normal boot now. It was not case in, say, r285355.

-- 
Best regards,
 Levmailto:l...@freebsd.org

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Re: What changed in rc.d infrastructure in last months?

2015-10-25 Thread NGie Cooper

> On Oct 25, 2015, at 12:46, Lev Serebryakov  wrote:
> 
> Hello NGie,
> 
> Sunday, October 25, 2015, 10:39:51 PM, you wrote:
> 
> 
>> It’s documented here:
> 
>> On the other hand, if you want to configure your wireless
>> interface with hostapd(8), you need to add ``HOSTAP'' to the
>> ifconfig_ variable.  hostapd(8) will use the
>> settings from /etc/hostapd-.conf
> I understand this, and as you can see from my config samples, I'm using
> exactly this feature.
> 
> I'm wonder why ifconfig & hostapd try to start TWICE now for same
> interaface in course of normal boot now. It was not case in, say, r285355.

These commits are probably why — in particular now all net80211 devices 
post-r287394/r287398 are being restarted via /etc/pccard_ether, which will 
trigger /etc/rc.d/netif (which doesn’t make sense because iwn, etc _aren’t_ 
pcmcia devices).
Sidenote, fixing bug 202726 might fix this case with [serial] boot. I’ll need 
to double-check the rcorder and get back to you on that.
Thanks,
-NGie


r287398 | glebius | 2015-09-02 07:38:16 -0700 (Wed, 02 Sep 2015) | 4 lines

Add iwm(4), that was missing in r287394.

Submitted by:   Shawn Webb


r287394 | glebius | 2015-09-02 05:46:42 -0700 (Wed, 02 Sep 2015) | 11 lines

Fix dynamic attach/detach of 802.11 devices after r287197:

o In pccard_ether add code to start children of a 802.11
  device, that are configured in rc.conf.
o In devd.conf provide a regex matching all 802.11 devices,
  and on match run pccard_ether to spawn children.

PR: 202784
Submitted by:   
In collaboration with:  "Oleg V. Nauman" 

r287197 | glebius | 2015-08-27 01:56:39 -0700 (Thu, 27 Aug 2015) | 43 lines

Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.

Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.

Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:

- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
  the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
  driver about any changes: number of wlan(4) interfaces, number of them
  in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
  driver experiences errors and can not attribute them to any specific
  interface, driver updates ic_oerrors or ic_ierrors counters.

Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
  now provided by net.wlan.devices sysctl.

Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.

Reviewed by:adrian
Sponsored by:   Netflix
Sponsored by:   Nginx, Inc.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"