Bug 167847

Summary: [ural] dlink dwl-122g e crashes(?) when trying wap2 crypto
Product: Base System Reporter: cjr
Component: usbAssignee: freebsd-usb (Nobody) <usb>
Status: Open ---    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description cjr 2012-05-13 21:40:02 UTC
A usb wifi dongle, dlink g-122g revision e, works using the ural module, which apparently loads if_run.ko and gives run0 as an interface.

It is possible to use the dongle as a wifi ap from several wifi clients with these lines in /etc/rc.conf:

wlans_run0="wlan0"
create_args_wlan0="wlanmode hostap"
ifconfig_wlan0="inet 192.168.3.1 netmask 255.255.255.0 ssid bsdap mode 11g"

When trying to encrypt wlan traffic with WPA2, using either ifconfig ... authmode wpa or hostapd, it is neither possible to connect to the wifi ap nor to see the wifi ap with the usual tools. The system appears to be under load, other network traffic gets very slow and setting the dongle in unencrypted mode does not change the situation. The issue resolves when manually removing the usb dongle. Having manually removed the usb dongle, it is possible to connect unencrypted again. I interpret this as crashing of the if_run driver or the associated wlan-modules.

My hostapd.conf is as follows (comments taken out):
                 
File Edit Options Buffers Tools Help                                                                     
interface=wlan0
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
                                                                                                         
dump_file=/tmp/hostapd.dump
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
ssid=bsdap
country_code=US
hw_mode=g
channel=60
beacon_int=100
dtim_period=2
max_num_sta=255
rts_threshold=2347
fragm_threshold=2346
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wmm_enabled=1

wmm_ac_bk_cwmin=4
wmm_ac_bk_cwmax=10
wmm_ac_bk_aifs=7
wmm_ac_bk_txop_limit=0
wmm_ac_bk_acm=0
                                                                                                         
wmm_ac_be_aifs=3
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=10
wmm_ac_be_txop_limit=0
wmm_ac_be_acm=0
                                                                                                         
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmin=3
wmm_ac_vi_cwmax=4
wmm_ac_vi_txop_limit=94
wmm_ac_vi_acm=0
                                                                                                         
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmin=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_txop_limit=47
wmm_ac_vo_acm=0
eapol_key_index_workaround=0

own_ip_addr=127.0.0.1
wpa=3
wpa_passphrase=secretkey
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP

How-To-Repeat: kldload ural

ifconfig wlan0 create wlandev run0 wlanmode ap
ifconfig wlan0 inet 192.168.3.1 netmask 255.255.255.0 ssid bsdap.

Connect to see that run0 is working.

Then

ifconfig wlan0 destroy
ifconfig wlan0 create wlandev run0 wlanmode ap
ifconfig wlan0 inet 192.168.3.1 netmask 255.255.255.0 ssid bsdap country DE authmode wpa

or alternatively

/etc/rc.d/hostapd onestart 

or

hostapd -ddK /etc/hostapd.conf
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-05-14 21:26:28 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-usb

reclassify.
Comment 2 PseudoCylon 2012-05-16 04:28:12 UTC
First, comment out 3 lines you have added to /etc/rc.conf temporary
until the problem is solved.

Try this hostapd.conf

interface=wlan0
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
ssid= bsdap
wpa=2
wpa_passphrase=UseYourOwnPwd
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP

Then, plugin the device,
#ifconfig wlan create wlandev run0 wlanmode ap
#/etc/rc.d/hostapd onestart
#ifconfig wlan0 inet 192.168.3.1


AK
Comment 3 cjr 2012-05-17 18:01:50 UTC
I have followed your suggestion replacing hostapd.conf with yours and
removing the wlan-startup from rc.conf. Additionally, I have compiled
the required drivers (if_run and ural, wlan*) into the kernel.

The problem of sluggish network traffic after enabling the module is
gone as well as any statements requiring wlan_amrr to be loaded
manually. The problem of not being able to connect persists.

ifconfig wlan0 gives 

wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether b8:a3:86:97:c1:ec
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11g <hostap>
        status: running
        ssid bsdap channel 1 (2412 MHz 11g) bssid b8:a3:86:97:c1:ec
        country US authmode WPA2/802.11i privacy MIXED deftxkey 2
        AES-CCM 2:128-bit txpower 0 scanvalid 60 protmode CTS wme
        dtimperiod 1 -dfs
Comment 4 PseudoCylon 2012-05-18 07:00:42 UTC
On Thu, May 17, 2012 at 11:01 AM, Christopher J. Ruwe <cjr@cruwe.de> wrote:
> The problem of not being able to connect persists.

Do stations see the bsdap or nothing at all? Does
% ifconfig wlan0 list ap
list the ap? (Do it one of stations.)

If it does,
first issue
# wlandebug -i wlan0 assoc+auth+crypto
then have a station to connect the ap.
Let me know what it says.

Just in case, you have changed "UseYourOwnPwd" in hostapd.conf to the
actual password you are using, haven't you?
wpa_passphrase=UseYourOwnPwd


AK
Comment 5 cjr 2012-05-18 10:22:49 UTC
> Do stations see the bsdap or nothing at all? Does
> % ifconfig wlan0 list ap
> list the ap? (Do it one of stations.)

The stations see nothing at all. Using 

ifconfig <dev> list ap _before_ enabling hostapd gives 

bsdap           b8:a3:86:97:c1:ec    6   54M -63:-95  100 ES   WME

_after_ enabling hostapd, the stations cannot see the ap anymore.


> If it does,
> first issue
> # wlandebug -i wlan0 assoc+auth+crypto
> then have a station to connect the ap.
> Let me know what it says.

I fear that I cannot use wlandebug, I have already tried.

[cjr@ritchie:~]$ wlandebug
wlandebug: sysctl-get(net.wlan.0.debug): No such file or directory

and

[cjr@ritchie:~]$ sysctl -a | grep wlan
device  wlan
device  wlan_wep
device  wlan_ccmp
device  wlan_tkip
device  wlan_amrr
device  wlan_acl
device  wlan_xauth
device  wlan_rssadapt
net.wlan.cac_timeout: 60
net.wlan.nol_timeout: 1800
net.wlan.addba_maxtries: 3
net.wlan.addba_backoff: 10000
net.wlan.addba_timeout: 250
net.wlan.recv_bar: 1
net.wlan.0.%parent: run0
net.wlan.0.driver_caps: 92324864
net.wlan.0.bmiss_max: 2
net.wlan.0.inact_run: 300
net.wlan.0.inact_probe: 30
net.wlan.0.inact_auth: 180
net.wlan.0.inact_init: 30
net.wlan.0.amrr_rate_interval: 1000
net.wlan.0.amrr_max_sucess_threshold: 15
net.wlan.0.amrr_min_sucess_threshold: 1

> Just in case, you have changed "UseYourOwnPwd" in hostapd.conf to the
> actual password you are using, haven't you?
> wpa_passphrase=UseYourOwnPwd

Yes, I have ;-). I think it will not matter until I _myself_ can see and
connect to the wlan ap. I could ask the cracker to help my to connect,
though. 


Thank you, cheers, Christopher
Comment 6 cjr 2012-05-18 10:26:36 UTC
Mangled the subject line ... sorry to introduce hassle ...

> Do stations see the bsdap or nothing at all? Does
> % ifconfig wlan0 list ap
> list the ap? (Do it one of stations.)

The stations see nothing at all. Using 

ifconfig <dev> list ap _before_ enabling hostapd gives 

bsdap           b8:a3:86:97:c1:ec    6   54M -63:-95  100 ES   WME

_after_ enabling hostapd, the stations cannot see the ap anymore.


> If it does,
> first issue
> # wlandebug -i wlan0 assoc+auth+crypto
> then have a station to connect the ap.
> Let me know what it says.

I fear that I cannot use wlandebug, I have already tried.

[cjr@ritchie:~]$ wlandebug
wlandebug: sysctl-get(net.wlan.0.debug): No such file or directory

and

[cjr@ritchie:~]$ sysctl -a | grep wlan
device  wlan
device  wlan_wep
device  wlan_ccmp
device  wlan_tkip
device  wlan_amrr
device  wlan_acl
device  wlan_xauth
device  wlan_rssadapt
net.wlan.cac_timeout: 60
net.wlan.nol_timeout: 1800
net.wlan.addba_maxtries: 3
net.wlan.addba_backoff: 10000
net.wlan.addba_timeout: 250
net.wlan.recv_bar: 1
net.wlan.0.%parent: run0
net.wlan.0.driver_caps: 92324864
net.wlan.0.bmiss_max: 2
net.wlan.0.inact_run: 300
net.wlan.0.inact_probe: 30
net.wlan.0.inact_auth: 180
net.wlan.0.inact_init: 30
net.wlan.0.amrr_rate_interval: 1000
net.wlan.0.amrr_max_sucess_threshold: 15
net.wlan.0.amrr_min_sucess_threshold: 1

> Just in case, you have changed "UseYourOwnPwd" in hostapd.conf to the
> actual password you are using, haven't you?
> wpa_passphrase=UseYourOwnPwd

Yes, I have ;-). I think it will not matter until I _myself_ can see and
connect to the wlan ap. I could ask the cracker to help my to connect,
though. 


Thank you, cheers, Christopher
Comment 7 PseudoCylon 2012-05-19 03:40:41 UTC
On Fri, May 18, 2012 at 3:26 AM, Christopher J. Ruwe <cjr@cruwe.de> wrote:

> The stations see nothing at all. Using
There is an issue with rt2020 (radio chip your device has). The device
stops working when re-initialized. So, you need to issue commands on
exact order I posted.

By saying that,
> ifconfig <dev> list ap _before_ enabling hostapd gives
>
> bsdap =A0 =A0 =A0 =A0 =A0 b8:a3:86:97:c1:ec =A0 =A06 =A0 54M -63:-95 =A01=
00 ES =A0 WME
if there is "before," you need to unplug and re-plugin the device.
Then, see what happens after.

> connect to the wlan ap. I could ask the cracker to help my to connect,
> though.
Then, do so. Let me know when the cracker comes up any patch.


AK
Comment 8 cjr 2012-05-19 17:57:00 UTC
Thank you for your help so far ... knowing that any reinitialization
will stop the device and following your advice in that order, I have
the wlan working with WPA. I established unencrypted wlan first and
tried to change that to encrypted wlan afterwards.

Is there any initialization order that I should follow in my rc.conf?
And shouldn't there some hint (known bugs) be included into either
ural(4) or runfw(4)? I could write something up ...



.Sh KNOWN BUGS
Some RT2020-based devices do not tolerate being reinitialized, e.g.,
stop working when changing authentification. To resume working, these
need to be pulled out and reinserted. Any reinitializing operations,
e.g., changing autentification or encryption, require unplugging and
re-plugging of the device. Conversely, it is not possible to change a
running wlan from open to encrypted.



Thank you for your help, cheers and have a nice weekend, cheers,
Christopher
Comment 9 PseudoCylon 2012-05-20 09:19:51 UTC
On Sat, May 19, 2012 at 10:57 AM, Christopher J. Ruwe <cjr@cruwe.de> wrote:
>
> Is there any initialization order that I should follow in my rc.conf?
For a workaround, save following script into /usr/local/etc/rc.d/ as "ap_setup"

--bigin script--

#!/bin/sh

# PROVIDE: ap_setup
# REQUIRE: DAEMON
# REQUIRE: mountcritremote
# BEFORE: LOGIN
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="ap_setup"
rcvar=`set_rcvar`
start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name
eval "${rcvar}=\${${rcvar}:-'NO'}"

ap_setup_start()
{
	/etc/rc.d/hostapd onestart
	ifconfig wlan0 inet 192.168.3.1
	/usr/local/etc/rc.d/isc-dhcpd onestart    #if used
}

ap_setup_stop()
{
	/usr/local/etc/rc.d/isc-dhcpd onestop    #if used
	/etc/rc.d/hostapd onestop
}

run_rc_command "$1"

--end script--

Then, add following lines to /etc/rc.conf
wlans_run0="wlan0"
create_args_wlan0="wlanmode ap"
ap_setup_enable="YES"    #the same name as workaround script
dhcpd_ifaces="wlan0"    #if used
Try not to use other standard instructions since it might break init order.


AK
Comment 10 cjr 2012-06-03 12:15:34 UTC
I am most sorry to reply that late ... I was down with the flu last week
and did not trust myself to be accurate ... 

I think the hardware issue you described has some other effect too,
i.e., the devie does not properly initialize at boot. So, the scripts
you provided me with do not work. What I need to do is unplug the dongle
after boot and then execute the commands you gave to me manually. I have
not tried to find out whether your scripts work _with_ the
dongle-remove-step directly after boot.

What works for me is a custom script with your commands in sequential
order. Anyways, thank you very much for your helping me getting that
donlge to work.

Cheers, have a nice week, 
-- 
Christopher J. Ruwe
TZ: GMT + 1h
Comment 11 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:11 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped