Bug 537708

Summary: wpa_supplicant seems to ignore an country=DE setting in its config
Product: [openSUSE] openSUSE 11.2 Reporter: Marius Tomaschewski <mt>
Component: OtherAssignee: Marius Tomaschewski <mt>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P3 - Medium CC: coolo, jmatejek, radmanic
Version: Factory   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Successfull test using nl80211 driver

Description Marius Tomaschewski 2009-09-09 13:15:47 UTC
It looks like, that the wpa_supplicant (-Dwext) in factory ignores
an country=DE setting in its config, e.g.:

>>>
ctrl_interface=/var/run/wpa_supplicant
country=DE
network={
  scan_ssid=1
  ssid="SSSSSSSSS"
  key_mgmt=WPA-PSK
  psk="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
<<<

When I set the regulatory domain using "iw reg set DE", it works fine;
I can see the event in "udevadm monitor --environment kernel" output:

KERNEL[1252495972.399814] change   /devices/platform/regulatory.0 (platform)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/platform/regulatory.0
SUBSYSTEM=platform
COUNTRY=DE
MODALIAS=platform:regulatory
SEQNUM=1400

and "iw reg get" shows the proper "country DE" setting after.

When I set it in the config and start wpa_supplicant, there is no such
event visible and iw reg get query does not show the new setting.

BTW: A sysconfig using/setting the country is in Base:System/sysconfig
only at the moment. See also fate#305301.
Comment 1 Marius Tomaschewski 2009-09-09 13:23:00 UTC
The problem occurred with the following package versions:

wpa_supplicant-0.6.9-2.30.x86_64
iw-0.9.15-1.3.x86_64
libiw30-30.pre8-4.2.x86_64
crda-1.1.0-1.4.x86_64
kernel-desktop-2.6.31-6.1.x86_64
Comment 2 Marius Tomaschewski 2009-09-09 14:16:33 UTC
Created attachment 317421 [details]
Successfull test using nl80211 driver

The set_country callbask seems to be not implemented for the 'wext'
driver, but only in privsep, nl80211, ndis:

$ grep -rl set_country .
./hostapd/hostapd.c
./hostapd/driver_i.h
./src/drivers/driver.h
./src/drivers/driver_privsep.c
./src/drivers/driver_nl80211.c
./src/drivers/driver_ndis.c
./wpa_supplicant/wpa_priv.c
./wpa_supplicant/driver_i.h
./wpa_supplicant/wpa_supplicant.c

Setting the driver to "nl80211" (WIRELESS_WPA_DRIVER="nl80211" in the
ifcfg-file) works fine, see attachment.
Comment 3 Marius Tomaschewski 2009-09-09 14:23:16 UTC
Vladimir,

I'd say we need a "iw reg set" call in case the driver is not
one that supports it / one of the above... What do you say?

Michal,
the WIRELESS_WPA_DRIVER ifcfg-file variable is new:

## Type:        string
## Default:     ""
#
# This variable allows to override the wpa driver name that should be used
# by the wpa_supplicant. In most cases "wext" can be used, but there are
# few exceptions.
#
WIRELESS_WPA_DRIVER=''

* Do Aug 13 2009 mt@suse.de
- version 0.72.3
- Updated kernel driver to wpa_supplicant driver name mappings,
  added WIRELESS_WPA_DRIVER ifcfg variable allowing the user to
  specify/override the wpa driver (bug 477833, bug 481380).
Comment 4 Vladimir Botka 2009-09-09 19:44:37 UTC
(In reply to comment #3)
> Vladimir,
> 
> I'd say we need a "iw reg set" call in case the driver is not
> one that supports it / one of the above... What do you say?
 
Marius,

Part of the project [1] is also a wpa_supplicant with -Dnl80211. This unified extension will solve this problem. I can see the wpa_supplicant to use the new extension in Factory [2], but to test the crda I need more time. 

Adding Jan Matejek to the CC who is the maintainer of the python-m2crypto. We need this package to build crda package.

[1] http://linuxwireless.org/en/developers/Documentation/nl80211

[2]
 # wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -dd -Dnl80211
Initializing interface 'wlan0' conf '/etc/wpa_supplicant/wpa_supplicant.conf' driver 'nl80211' ctrl_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant/wpa_supplicant.conf' -> '/etc/wpa_supplicant/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant/wpa_supplicant.conf'
country='CZ'
Comment 5 Marius Tomaschewski 2009-09-09 20:34:47 UTC
OK. The nl80211 driver and crda were working fine for me in my test today,
see attached output in comment 2.

The question is, if it is safe to switch from 'wext' to the new 'nl80211'.
(The user can switch back using WIRELESS_WPA_DRIVER='wext' as workaround).

At the moment we have the following driver mapping (see also bug 477833
and bug 481380) in the /etc/sysconfig/network/scripts/ifup-wireless:

            prism54)
                WPA_DRIVER=prism54
                PREFER_WPA_SUPPLICANT=no
                ;;
            rt61|rt73)
                WPA_DRIVER=ralink
                ;;
            ipw2200|ipw2100|ipw3945|hostap_*)
                WPA_DRIVER=wext
                ;;
            ndiswrapper|*.sys)
                WPA_DRIVER=wext
                ;;
            rt2500usb|rt2500pci)
                WPA_DRIVER=wext
                ;;
            rt61pci|rt73usb|rt2400pci)
                WPA_DRIVER=wext
                ;;
            iwlagn|iwl3945|iwl4965)
                WPA_DRIVER=wext
                ;;
            zd1211rw)
                WPA_DRIVER=wext
                ;;
            ath5k|ath9k|ath_pci)
                WPA_DRIVER=wext
                ;;
            b43|b43legacy|ssb)
                WPA_DRIVER=wext
                ;;
            p54pci|p54usb)
                WPA_DRIVER=wext
                ;;
            at76*)
                WPA_DRIVER=wext
                ;;
            *)
                WPA_DRIVER=unsupported
                PREFER_WPA_SUPPLICANT=no
                ;;
   ...
            if [ "$WPA_DRIVER" = "unsupported" ]; then
                message "`printf "    %-9s warning: WPA configured but may be unsupported" $INTERFAC
                message "`printf "    %-9s warning: by this device" $INTERFACE`"
                info_mesg "using WPA driver 'wext' for interface $INTERFACE"
                WPA_DRIVER=wext
            fi
            start_wpa_supplicant
Comment 6 Vladimir Botka 2009-09-10 09:39:47 UTC
(In reply to comment #5)
> OK. The nl80211 driver and crda were working fine for me in my test today,
> see attached output in comment 2.
> 
> The question is, if it is safe to switch from 'wext' to the new 'nl80211'.

I have tested the nl80211 with Factory and Intel 5100. For iwlagn it works. I would suggest that you switch the script to nl80211 at least for the Intel cards (iwl*) and we will fix it on the fly if something goes wrong and people report problems.

I put [1] into your script, but "./ifup-wireless wlan0" did not start wpa_supplicant. I was not able to run it out of the box so please tell me how do you intend to use the ifup-wireless . I have tested the nl82011 by setting the AP via iwconfig, started wpa_supplicant and dhcpcd from command-line.

[1]
<             iwlagn)
<                 WPA_DRIVER=nl80211
<                 ;;
Comment 7 Marius Tomaschewski 2009-09-14 06:43:30 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > OK. The nl80211 driver and crda were working fine for me in my test today,
> > see attached output in comment 2.
> > 
> > The question is, if it is safe to switch from 'wext' to the new 'nl80211'.
> 
> I have tested the nl80211 with Factory and Intel 5100. For iwlagn it works. I
> would suggest that you switch the script to nl80211 at least for the Intel
> cards (iwl*) and we will fix it on the fly if something goes wrong and people
> report problems.
> 
> I put [1] into your script, but "./ifup-wireless wlan0" did not start
> wpa_supplicant. I was not able to run it out of the box so please tell me how
> do you intend to use the ifup-wireless.

Just call "yast2 network" and configure the wireless interface there.

The ifup-wireless script is a script called via "ifup","ifdown" and
"ifstatus" and "rcnetwork" in traditional mode (NETWORKMANAGER=no).

> I have tested the nl82011 by setting
> the AP via iwconfig, started wpa_supplicant and dhcpcd from command-line.
> 
> [1]
> <             iwlagn)
> <                 WPA_DRIVER=nl80211
> <                 ;;

OK, then let's collect it a little bit. For me ath5k works fine too.
Comment 8 Vladimir Botka 2009-09-14 19:36:01 UTC
(In reply to comment #7)
> 
> Just call "yast2 network" and configure the wireless interface there.
> 

I have added the WIRELESS_REGULATORY_DOMAIN="CZ" into the /etc/sysconfig/network/config.

When I bring the inteface up I receive messages:
 wlan0     device: Intel Corporation Wireless WiFi Link 5100
    wlan0     starting wpa_supplicant
Failed to set interface wlan0 mode
Could not configure driver to use managed mode
    wlan0     IP address: 192.168.102.14/24

The wpa_supplicant is running:
wpa_supplicant -iwlan0 -c/var/run/wpa_supplicant-wlan0.conf -Dnl80211 -P/var/run/wpa_supplicant/wlan0.pid -B

But the regulatory domain is not set:
# iw reg get
country 00:

If I put country=CZ into the /etc/wpa_supplicant/wpa_supplicant.conf and start the wpa_supplicant manualy:
wpa_supplicant -iwlan0 -Dnl80211 -dddt -c/etc/wpa_supplicant/wpa_supplicant.conf

Then the regulatory domain is set:
# iw reg get
country CZ:

I have tested with the sysconfig 0.72.3-1.1 . Because this is sysconfig issue now I would like to assign it to you, Marius. Is it OK ?
Comment 9 Marius Tomaschewski 2009-09-15 09:29:00 UTC
I guess, the sysconfig version 0.72.3-1.1 was too old... Was there
change log in "rpm -q --changelog sysconfig"?:

Wed Sep  9 13:07:36 CEST 2009 - mt@suse.de
- Implemented support to set the wireless regulatory domain using
  WIRELESS_REGULATORY_DOMAIN network/config variable (fate#305301).


There should be this line in ifup-wireless script:

@@ -600,6 +610,7 @@ print_wpa_conf()
     # header
     echo "ctrl_interface=/var/run/wpa_supplicant"
     test -n "$WIRELESS_AP_SCANMODE" && echo "ap_scan=$WIRELESS_AP_SCANMODE"
+    test -n "$WIRELESS_REGULATORY_DOMAIN" && echo "country=$WIRELESS_REGULATORY_DOMAIN"
 
     get_first_index
     local index=$?

The "country=CZ" keyword is added then quite at the begin to the
generated /var/run/wpa_supplicant-wlan0.conf file.
Comment 10 Marius Tomaschewski 2009-09-15 09:36:41 UTC
When I see correctly in openSUSE:Factory, you need this version:
  Version:        0.72.3
  Release:        2

The sysconfig-0.72.3-1.3 RPM from
  http://download.opensuse.org/factory/repo/oss/suse/
is still too old, you need sysconfig-0.72.3-2.1 or later.

Please update your package to the one you'll get via e.g.:
  osc getbinaries openSUSE:Factory sysconfig standard x86_64
Comment 11 Marius Tomaschewski 2009-09-15 11:07:57 UTC
As I already wrote in previous comments, it works with the new driver.

The new driver works quite well with my Atheros PCMCIA card (Netgear
WG511T), but I've also the warning messages from wpa_supplicant:

  Failed to set interface wlan0 mode
  Could not configure driver to use managed mode

same as in comment #8.

I've added a note about this issue to the WIRELESS_REGULATORY_DOMAIN
description:

## Type:        string
## Default:     ''
#
# Set this variable to the ISO / IEC 3166 alpha2 country code
# specifying the wireless regulatory domain to set.
# When not-empty, it will be set in the wpa_supplicant config
# or via 'iw reg set' command.
#
# Note: in wpa_supplicant mode, it is currently (openSUSE 11.2)
# not supported by our default 'wext', but by the new 'nl80211'
# wpa driver. You can set WIRELESS_WPA_DRIVER='nl80211' in the
# per interface ifcfg config file. We will switch to use the
# new driver as soon as we've tested it with more chipsets.
#
WIRELESS_REGULATORY_DOMAIN=''

and an extensive change log entry to sysconfig-0.72.4 that us
actually submitted to openSUSE:Factory:

- version 0.72.4
- Added note to WIRELESS_REGULATORY_DOMAIN variable description in
  /etc/sysconfig/network/config, that it needs the new nl80211 wpa
  driver, that can be enabled using the WIRELESS_WPA_DRIVER ifcfg
  variable on a per interface basis (bnc#537708).

I think, this should catch this issue quite well for now.
IMO it is not a good idea to hurry too much with switching to the
new nl80211 driver and perhaps break several chipsets just because
of the regulatory domain.

When somebody disagrees, please reopen. I've reassigned to me.
Comment 12 Marius Tomaschewski 2009-09-15 11:55:07 UTC
See also bug 535750 comment 7:
"[...] If the wpa_supplicant is running with the -Dnl80211 then it
 does not authenticate. -Dwext works fine.[...]"
Comment 13 Marius Tomaschewski 2010-03-05 13:56:07 UTC
Cloned this bug to track driver switch on 11.3 and to collect non-working
cases ==>> bug 585802.
Comment 14 Bernhard Wiedemann 2016-04-15 09:51:12 UTC
This is an autogenerated message for OBS integration:
This bug (537708) was mentioned in
https://build.opensuse.org/request/show/20462 Factory / sysconfig