Bug 202784 - r287197: wlan interfaces aren't brought up at boot or after removal/inserting
Summary: r287197: wlan interfaces aren't brought up at boot or after removal/inserting
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: wireless (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Gleb Smirnoff
URL: https://lists.freebsd.org/pipermail/s...
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-30 23:49 UTC by vidwer+fbsdbugs
Modified: 2015-09-02 12:47 UTC (History)
3 users (show)

See Also:


Attachments
redirecting 'sh -x /etc/rc.d/netif' stdout to a file, from tcsh (24.15 KB, application/x-gzip)
2015-08-30 23:49 UTC, vidwer+fbsdbugs
no flags Details
patch to devd.conf and pccard_ether to properly create 802.11 children (1.95 KB, patch)
2015-09-01 10:59 UTC, Gleb Smirnoff
no flags Details | Diff
patch to devd.conf and pccard_ether to properly create 802.11 children (2.02 KB, patch)
2015-09-02 11:31 UTC, Gleb Smirnoff
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vidwer+fbsdbugs 2015-08-30 23:49:02 UTC
Created attachment 160542 [details]
redirecting 'sh -x /etc/rc.d/netif' stdout to a file, from tcsh

Manually running 'service netif restart' works around this.

/etc/network.subr and /etc/rc.d/netif have been updated by mergemaster
-p and mergemaster -iF

Attach is the output of 'sh -x /etc/rc.d/netif restart'.

Lines 19848..19850 might prove that wpa_supplicant isn't killed when it should have been.
Comment 1 Gleb Smirnoff freebsd_committer 2015-09-01 10:15:34 UTC
Can you please share your rc.conf?
Comment 2 vidwer+fbsdbugs 2015-09-01 10:29:45 UTC
(In reply to Gleb Smirnoff from comment #1)
wlans_run0="wlan0"
wlans_rsu0="wlan1"
wlandebug_wlan1=0xffffff00
ifconfig_wlan0="WPA DHCP"
ifconfig_wlan1="WPA DHCP"
Comment 3 Gleb Smirnoff freebsd_committer 2015-09-01 10:37:17 UTC
Are rsu and run compiled into the kernel, or are they kernel loadables? If the latter, are they loaded in /boot/loader.conf or by other means?
Comment 4 vidwer+fbsdbugs 2015-09-01 10:54:11 UTC
(In reply to Gleb Smirnoff from comment #3)
Those are kernel loadables, loaded automagically (not through kldload or from /boot/loader.conf).

# ls /boot/kernel/if_run* /boot/kernel/if_rsu*
/boot/kernel/if_rsu.ko          /boot/kernel/if_run.ko
/boot/kernel/if_rsu.ko.symbols  /boot/kernel/if_run.ko.symbols

Also, there isn't a 'Starting Network: wlan[01]' line, because it seems its modules are loaded when the script finishes and gateways are added.
Comment 5 Gleb Smirnoff freebsd_committer 2015-09-01 10:59:37 UTC
Created attachment 160585 [details]
patch to devd.conf and pccard_ether to properly create 802.11 children

Please try the attached patch.
Comment 6 vidwer+fbsdbugs 2015-09-01 11:30:59 UTC
(In reply to Gleb Smirnoff from comment #5)
That patch didn't work for me, on top of r287356M. Still had to run 'service netif restart'.
Comment 7 Gleb Smirnoff freebsd_committer 2015-09-01 11:36:08 UTC
Can you please debug the patch? Where does it fail? Does devd rule match? If yes, is pccard_ether executed? If yes, is /etc/rc.d/netif executed from pccard_ether?
Comment 8 vidwer+fbsdbugs 2015-09-01 13:35:39 UTC
(In reply to Gleb Smirnoff from comment #7)

This is (a part of) devd's output when starting it in the foreground:

Processing event '+run0 at bus=0 hubaddr=1 port=3 devaddr=2 interface=0 ugen=ugen0.2 vendor=0x1737 product=0x0077 devclass=0x00 devsubclass=0x00 sernum="" release=0x0101 mode=host intclass=0xff intsubclass=0xff intprotocol=0xff on uhub0'
Pushing table
setting device-name=run0
setting bus=0
setting hubaddr=1
setting port=3
setting devaddr=2
setting interface=0
setting ugen=ugen0.2
setting vendor=0x1737
setting product=0x0077
setting devclass=0x00
setting devsubclass=0x00
setting sernum=
setting release=0x0101
setting mode=host
setting intclass=0xff
setting intsubclass=0xff
setting intprotocol=0xff
setting bus=uhub0
Processing attach event
Testing device-name=run0 against ^ed50$, invert=0
Testing device-name=run0 against ^ubt[0-9]+$, invert=0
Testing device-name=run0 against ^ukbd0$, invert=0
Testing vendor=0x1737 against ^0x0854$, invert=0
Testing vendor=0x1737 against ^0x1645$, invert=0
Testing device-name=run0 against ^(ath|bwi|bwn|ipw|iwi|iwn|malo|mwl|ral|rsu|rum|run|uath|upgt|ural|urtw|urtwn|wi|wpi|wtap|zyd)[0-9]+$, invert=0
Executing '/etc/pccard_ether run0 startchildren'
/etc/pccard_ether: unknown directive 'startchildren'.
Usage: /etc/pccard_ether [fast|force|one|quiet](start|stop|restart|rcvar|enabled)
Comment 9 oleg.nauman 2015-09-01 14:16:10 UTC
Comment on attachment 160585 [details]
patch to devd.conf and pccard_ether to properly create 802.11 children

devd events on insertion after your patch:

!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.0
!system=DEVFS subsystem=CDEV type=CREATE cdev=ugen0.2
!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.1
!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.2
!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.3
!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.4
!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.5
!system=DEVFS subsystem=CDEV type=CREATE cdev=usb/0.2.6
!system=USB subsystem=DEVICE type=ATTACH ugen=ugen0.2 cdev=ugen0.2 vendor=0x07d1 product=0x3c0d devclass=0x00 devsubclass=0x00 sernum="1.0" release=0x0101 mode=host port=2 parent=ugen0.1
!system=USB subsystem=INTERFACE type=ATTACH ugen=ugen0.2 cdev=ugen0.2 vendor=0x07d1 product=0x3c0d devclass=0x00 devsubclass=0x00 sernum="1.0" release=0x0101 mode=host interface=0 endpoints=7 intclass=0xff intsubclass=0xff intprotocol=0xff
+run0 at bus=0 hubaddr=1 port=2 devaddr=2 interface=0 ugen=ugen0.2 vendor=0x07d1 product=0x3c0d devclass=0x00 devsubclass=0x00 sernum="1.0" release=0x0101 mode=host intclass=0xff intsubclass=0xff intprotocol=0xff on uhub0

wlan interface still down, /etc/pccard_ether seems not invoked at all
Comment 10 oleg.nauman 2015-09-01 14:36:09 UTC
Well it works after simple /etc/pccard_ether patch:



diff -u /etc/pccard_ether.old /etc/pccard_ether
--- /etc/pccard_ether.old       2015-09-01 17:33:12.136219000 +0300
+++ /etc/pccard_ether   2015-09-01 17:29:53.198953000 +0300
@@ -17,6 +17,9 @@
 stop_cmd="pccard_ether_stop"
 restart_precmd="checkauto"
 restart_cmd="pccard_ether_restart"
+startchildren_cmd="pccard_ether_startchildren"
+stopchildren_cmd="pccard_ether_stopchildren"
+extra_commands="startchildren stopchildren"

 setup_routes()
 {
Comment 11 oleg.nauman 2015-09-01 14:38:59 UTC
devd events after additional /etc/pccard_ether patch:

....
Testing device-name=run0 against ^(ath|bwi|bwn|ipw|iwi|iwn|malo|mwl|ral|rsu|rum|run|uath|upgt|ural|urtw|urtwn|wi|wpi|wtap|zyd)[0-9]+$, invert=0
Executing '/etc/pccard_ether run0 startchildren'
/etc/pccard_ether: DEBUG: run_rc_command: doit: pccard_ether_startchildren 
/etc/rc.d/netif: DEBUG: checkyesno: netif_enable is set to YES.
/etc/rc.d/netif: DEBUG: run_rc_command: doit: netif_start wlan1
/etc/rc.d/netif: DEBUG: wlan_up
/etc/rc.d/netif: DEBUG: child wlan1
ifconfig: interface wlan1 does not exist
Created wlan(4) interfaces: wlan1.
/etc/rc.d/netif: DEBUG: Created wlan(4)s: wlan1
/etc/rc.d/netif: DEBUG: Cloned: 
/etc/rc.d/wpa_supplicant: DEBUG: pid file (/var/run/wpa_supplicant/wlan1.pid): not readable.
/etc/rc.d/wpa_supplicant: DEBUG: load_kld: wlan_wep kernel module already loaded.
/etc/rc.d/wpa_supplicant: DEBUG: load_kld: wlan_tkip kernel module already loaded.
/etc/rc.d/wpa_supplicant: DEBUG: load_kld: wlan_ccmp kernel module already loaded.
Starting wpa_supplicant.
/etc/rc.d/wpa_supplicant: DEBUG: run_rc_command: doit: /usr/sbin/wpa_supplicant -s -B -i wlan1 -c /etc/wpa_supplicant.conf -D bsd -P /var/run/wpa_supplicant/wlan1.pid
/etc/rc.d/dhclient: DEBUG: pid file (/var/run/dhclient.wlan1.pid): not readable.
/etc/rc.d/dhclient: DEBUG: run_rc_command: start_precmd: dhclient_prestart 
/etc/rc.d/dhclient: DEBUG: checkyesno: background_dhclient is set to NO.
Starting dhclient.
/etc/rc.d/dhclient: DEBUG: run_rc_command: doit: /sbin/dhclient  wlan1 
wlan1: no link ....... got link
DHCPREQUEST on wlan1 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.102 -- renewal in 3600 seconds.
Starting Network: wlan1.
/etc/rc.d/netif: DEBUG: checkyesno: rc_startmsgs is set to YES.
wlan1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:26:5a:0a:cb:fa
        inet 192.168.0.102 netmask 0xffffff00 broadcast 192.168.0.255 
        media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
        status: associated
        ssid Liberty7 channel 1 (2412 MHz 11g) bssid f8:1a:67:56:16:16
        country US authmode WPA privacy ON deftxkey UNDEF txpower 0 bmiss 7
        scanvalid 60 protmode CTS wme roaming MANUAL
        groups: wlan
Comment 12 vidwer+fbsdbugs 2015-09-01 15:11:51 UTC
(In reply to oleg.nauman from comment #10)

Yes, I can confirm that the extra line brings up $wifi-interface during boot and/or removal/inserting:

+extra_commands="startchildren stopchildren"
Comment 13 Gleb Smirnoff freebsd_committer 2015-09-02 11:31:27 UTC
Created attachment 160632 [details]
patch to devd.conf and pccard_ether to properly create 802.11 children

Guys, can you please confirm, that we are happy with this patch?
Comment 14 vidwer+fbsdbugs 2015-09-02 12:40:16 UTC
(In reply to Gleb Smirnoff from comment #13)

That patch works for me, can you commit it?
Comment 15 commit-hook freebsd_committer 2015-09-02 12:46:57 UTC
A commit references this bug:

Author: glebius
Date: Wed Sep  2 12:46:43 UTC 2015
New revision: 287394
URL: https://svnweb.freebsd.org/changeset/base/287394

Log:
  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:	<vidwer gmail.com>
  In collaboration with:	"Oleg V. Nauman" <oleg opentransfer.com>

Changes:
  head/etc/devd.conf
  head/etc/pccard_ether