Modify

Opened 7 years ago

Closed 6 years ago

#8239 closed defect (wontfix)

b43 (or mac80211): essid gets lost in adhoc-mode by config.sh (ifconfig down)

Reported by: borcky@… Owned by: developers
Priority: high Milestone: Backfire 10.03.1
Component: base system Version: Backfire 10.03.1 RC3
Keywords: mac80211, iwconfig, iw, adhoc, b43, wifi, essid, ssid Cc:

Description

I'm running Backfire (10.03, r23985) with the kernel 2.6.32.25 on a Buffalo WHR54GS.

Now I want to create/join an adhoc-network, but it fails.

The wlan0 device gets all the right settings until /lib/network/config.sh is called. I enabled DEBUG = echo to find out following.

In /lib/network/config.sh where the "Interface settings" (line 326) in the function setup_interface are made, the script does an "ifconfig $iface down" to set the macaddr. At this step, the wlan0 looses its previously set essid.

I tried to unset the macaddr in /etc/config/network, but without macaddr set, the device won't be found: PHY for wifi device wlan0 not found

I don't know if this is a general problem with all mac80211-drivers or only with b43.

Later on, I replaced the iw-command (line 372) in /lib/wifi/mac80211.sh which sets the essid with an iwconfig-command.

- iw dev "$ifname" ibss join "$ssid" $freq ${fixed:+fixed-freq} $bssid ${mcval:+mcast-rate $mcval}
+ iwconfig "$ifname" essid "$ssid"

This works. Somehow the wlan0 interface forgets the essid after a "ifconfig wlan0 down" when its set with the iw-command. This is not the case with the iwconfig-command.

I problem remains with the stable and experimental b43-firmware.

What's the difference between iwconfig and iw in this situation?
How to solve this problem?

Attachments (2)

wireless (453 bytes) - added by borcky@… 7 years ago.
/etc/config/wireless
network (1007 bytes) - added by anonymous 7 years ago.

Download all attachments as: .zip

Change History (13)

Changed 7 years ago by borcky@…

/etc/config/wireless

Changed 7 years ago by anonymous

comment:1 Changed 7 years ago by borcky@…

Ah yes, and when I do a "wifi down" and "wifi up", following is being logged:

Nov 14 16:37:34 10-247-20-81 user.info kernel: b43-phy0: Loading firmware version 478.104 (2008-07-01 00:50:23)
Nov 14 16:37:36 10-247-20-81 user.notice root: adding wlan0 (wlan0) to firewall zone freifunk
Nov 14 16:37:37 10-247-20-81 user.notice firewall.freifunk: adding nat rule for wlan0(10.247.0.0/16)
Nov 14 16:37:38 10-247-20-81 user.notice firewall.freifunk: adding nat rule for wlan0(10.247.20.80/28)
Nov 14 16:37:38 10-247-20-81 user.notice firewall.freifunk: applying nat rules on zone freifunk
Nov 14 16:37:45 10-247-20-81 daemon.info Freifunk Watchdog: Config changed, reloading
Nov 14 16:37:45 10-247-20-81 daemon.info Freifunk Watchdog: Monitoring wlan0: bssid=02:CA:FF:EE:BA:BE channel=10
Nov 14 16:37:45 10-247-20-81 daemon.warn Freifunk Watchdog: BSSID mismatch on wlan0: current=00:00:00:00:00:00 wanted=02:CA:FF:EE:BA:BE

comment:2 Changed 7 years ago by borcky@…

After some more tests, it looks like it's a general problem with the mac80211-drivers.

I tested with different devices (rt73usb, ipw2200, b43) to create an adhoc-connection by first connecting with the iw-command (iw dev wlan0 join ibssi ...), then by putting the interface down and up again with ifconfig. After that, the ssid- or bssid-settings are gone. The iw-command can't set ssid- or bssid-settings on mac80211-devices in a way that they survive a "ifconfig wlan0 down && ifconfig wlan0 up".

I found out two workarounds for the scripts in OpenWRT.

First (maybe better) workaround: Don't ifconfig down a mac80211-device in /lib/network/config.sh:

Index: package/base-files/files/lib/network/config.sh
===================================================================
--- package/base-files/files/lib/network/config.sh	(Revision 24000)
+++ package/base-files/files/lib/network/config.sh	(working copy)
@@ -325,9 +325,15 @@
 
 	# Interface settings
 	grep "$iface:" /proc/net/dev > /dev/null && {
-		local mtu macaddr
+		local mtu macaddr type
 		config_get mtu "$config" mtu
 		config_get macaddr "$config" macaddr
+		config_get type "$config" type
+		# don't ifconfig down mac80211-interfaces for
+		# setting macaddr, otherwise they'll loose wifi-settings
+		# like ssid's ...
+		echo $type
+		[ "$type" = "mac80211" ] && echo ist mac80211 && macaddr=""
 		[ -n "$macaddr" ] && $DEBUG ifconfig "$iface" down
 		$DEBUG ifconfig "$iface" ${macaddr:+hw ether "$macaddr"} ${mtu:+mtu $mtu} up

Second possible workaround: Use iwconfig istead of iw in /lib/wifi/mac80211.sh:

Index: package/mac80211/files/lib/wifi/mac80211.sh
===================================================================
--- package/mac80211/files/lib/wifi/mac80211.sh	(Revision 24000)
+++ package/mac80211/files/lib/wifi/mac80211.sh	(Arbeitskopie)
@@ -369,7 +369,7 @@
 						mcsub="$(( ($mcast_rate / 100) % 10 ))"
 						[ "$mcsub" -gt 0 ] && mcval="$mcval.$mcsub"
 					}
-					iw dev "$ifname" ibss join "$ssid" $freq ${fixed:+fixed-freq} $bssid ${mcval:+mcast-rate $mcval}
+					iwconfig "$ifname" essid "$ssid" freq "$freq"M
 				;;
 				sta)
 					if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then

Maybe you should integrate one of the patches in Backfire 10.3.1? What do you think?

Thanks for any comments.

comment:3 Changed 7 years ago by nbd

  • Resolution set to worksforme
  • Status changed from new to closed

i'm pretty sure this was fixed a long time ago

comment:4 Changed 6 years ago by borcky@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened

i'm pretty sure this was fixed a long time ago

I just tested 10.03.1-rc5 with brcm47xx.

The bssid- and essid-settings get lost after configuring the macaddr by /lib/network/config.sh when I am doing a "wifi down" and a "wifi up".

workaround in config.sh: do not put down iface for setting the macaddr when its type is mac80211.

comment:5 Changed 6 years ago by nbd

do you have a mac address set for wireless in /etc/config/network?

comment:6 Changed 6 years ago by borcky@…

no, I have no mac address set in /etc/config/network, it's set in /etc/config/wireless. it doesn't change anything when I set the macaddr in /etc/config/network or if I remove the setting completely. apparently the mac80211-drivers need the macaddr setting in /etc/config/wireless

comment:7 Changed 6 years ago by nbd

please show me your /etc/config/network and /etc/config/wireless

comment:8 Changed 6 years ago by borcky@…

/etc/config/network:

config 'switch' 'eth0'
	option 'enable' '1'

config 'switch_vlan' 'eth0_0'
	option 'device' 'eth0'
	option 'vlan' '0'
	option 'ports' '0 1 2 3 5'

config 'switch_vlan' 'eth0_1'
	option 'device' 'eth0'
	option 'vlan' '1'
	option 'ports' '4 5'

config 'interface' 'loopback'
	option 'ifname' 'lo'
	option 'proto' 'static'
	option 'ipaddr' '127.0.0.1'
	option 'netmask' '255.0.0.0'

config 'interface' 'lan'
	option 'type' 'bridge'
	option 'ifname' 'eth0.0'
	option 'proto' 'static'
	option 'ipaddr' '192.168.1.1'
	option 'netmask' '255.255.255.0'
	option 'dns' '208.67.222.222 208.67.220.220'

config 'interface' 'wan'
	option 'ifname' 'eth0.1'
	option 'proto' 'dhcp'

config 'interface' 'radio0'
	option 'proto' 'static'
	option 'ipaddr' '10.247.11.241'
	option 'netmask' '255.255.0.0'
	option 'ifname' 'wlan0'
	option 'dns' '208.67.222.222 208.67.220.220'

config 'alias' 'radio0dhcp'
	option 'proto' 'static'
	option 'interface' 'radio0'
	option 'ipaddr' '6.11.241.1'
	option 'netmask' '255.255.255.0'

/etc/config/wireless:

config 'wifi-device' 'radio0'
	option 'type' 'mac80211'
	option 'macaddr' '00:1c:10:52:30:51'
	option 'diversity' '0'
	option 'hwmode' '11g'
	option 'disabled' '0'
	option 'channel' '10'
	option 'txpower' '18'
	option 'txantenna' '1'
	option 'rxantenna' '1'
	option 'country' 'CH'
	option 'distance' '2000'

config 'wifi-iface'
	option 'device' 'radio0'
	option 'encryption' 'none'
	option 'network' 'radio0'
	option 'ssid' 'www.openwireless.ch'
	option 'mode' 'adhoc'
	option 'bssid' '02:CA:FF:EE:BA:BE'

comment:9 Changed 6 years ago by jow

This might be a well known bug in the mac80211 scripts, caused by a clash of identifiers. Can you try to rename your "radio0" network to "wireless0" or something else? The resulting configs should look like this then:

config 'interface' 'wireless0'
	option 'proto' 'static'
	option 'ipaddr' '10.247.11.241'
	option 'netmask' '255.255.0.0'
	option 'dns' '208.67.222.222 208.67.220.220'

config 'alias' 'wireless0dhcp'
	option 'proto' 'static'
	option 'interface' 'wireless0'
	option 'ipaddr' '6.11.241.1'
	option 'netmask' '255.255.255.0'
config 'wifi-iface'
	option 'device' 'radio0'
	option 'encryption' 'none'
	option 'network' 'wireless0'
	option 'ssid' 'www.openwireless.ch'
	option 'mode' 'adhoc'
	option 'bssid' '02:CA:FF:EE:BA:BE'

comment:10 Changed 6 years ago by borcky@…

ok, this worked.

which well known bug is this? ticket number? will this be solved in the next rc or final version of backfire 10.03.1?

comment:11 Changed 6 years ago by nbd

  • Resolution set to wontfix
  • Status changed from reopened to closed

marking this as wontfix for now, the issue will automatically go away once the rework of the network configuration system gets merged.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.