Modify

Opened 8 years ago

Closed 7 years ago

Last modified 2 years ago

#5164 closed defect (fixed)

madwifi.sh - multi vaps with psk+wep brought up with open vap (wep encryption disabled)

Reported by: framer99 Owned by: developers
Priority: high Milestone: Barrier Breaker 14.07
Component: packages Version: Trunk
Keywords: madwifi.sh madwifi wpa wep vap Cc:

Description

madiwif.sh brings up a psk or a wep AP correctly.

But, if i put the same psk and wep vap configs together into /etc/config/wireless at the same time, intending to run psk and wep vaps concurrently, hostpapd gets started up on the wep vap because the madwwifi.sh var start_hostapd==1 (set to 1 for the psk vap)

The final result is that the wep vap has encryption disabled.

I think when hostap gets started on the wep vap, it clears the WEP encryption from the wep vap, so ... the result is a wide open vap potentially bridged to the lan or whatever it was setup as.

I can manually assign a wep key to the vap after wifi up, but it should have worked doing wifi up.

Here is the dual vap config: (again, putting each vap in by itself, everything works)

root@OpenWrt:/etc/config# cat /etc/config/wireless
config wifi-device wifi0
        option type atheros
        option channel auto
        #option disabled 1

config wifi-iface
        option device wifi0
        option network lan
        option mode ap
        option ssid wpavap
        option encryption psk
        option key 'mysecretpassphrase'

config wifi-iface
        option device wifi0
        option network lan
        option mode ap
        option ssid wepvap
        option encryption wep
        option key 1
        option key1 's:mykey'
root@OpenWrt:/etc/config#

here is some debug output showing wifi up , using the dual vap config, you can see that hostapd is started for the wep vap. You can also see that the final state is no encryption on the wep vap

root@OpenWrt:/etc/config# wifi down ; killall hostapd ; wifi up ; iwconfig ; sle
ep 2 ; ps
killall: hostapd: no process killed
device ath0 entered promiscuous mode
br-lan: topology change detected, propagating
br-lan: port 2(ath0) entering forwarding state
Configuration file: /var/run/hostapd-ath0.conf
Using interface ath0 with hwaddr 00:15:6d:64:20:ff and ssid 'wpavap'
device ath1 entered promiscuous mode
br-lan: topology change detected, propagating
br-lan: port 3(ath1) entering forwarding state
Configuration file: /var/run/hostapd-ath1.conf
Using interface ath1 with hwaddr 0a:15:6d:64:20:ff and ssid 'wepvap'
lo        no wireless extensions.

wifi0     no wireless extensions.

eth0      no wireless extensions.

eth1      no wireless extensions.

eth2      no wireless extensions.

br-lan    no wireless extensions.

ath0      IEEE 802.11g  ESSID:"wpavap"  Nickname:""
          Mode:Master  Frequency:2.422 GHz  Access Point: Not-Associated
          Bit Rate:0 kb/s   Tx-Power:18 dBm   Sensitivity=1/1
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:0A00-5533-9F24-F7A7-9205-FF11-71AF-690A [2]   Security mode:open
          Power Management:off
          Link Quality=0/70  Signal level=-96 dBm  Noise level=-96 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

ath1      IEEE 802.11g  ESSID:"wepvap"  Nickname:""
          Mode:Master  Channel:0  Access Point: Not-Associated
          Bit Rate:0 kb/s   Tx-Power:18 dBm   Sensitivity=1/1
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=0/70  Signal level=-96 dBm  Noise level=-96 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

  PID USER       VSZ STAT COMMAND
    1 root       940 S    init
    2 root         0 SW<  [kthreadd]
    3 root         0 SW<  [ksoftirqd/0]
    4 root         0 SW<  [events/0]
    5 root         0 SW<  [khelper]
   50 root         0 SW<  [kblockd/0]
   54 root         0 SW<  [kseriod]
   97 root         0 SW   [pdflush]
   98 root         0 SW   [pdflush]
   99 root         0 SW<  [kswapd0]
  140 root         0 SW<  [aio/0]
  244 root         0 SW<  [mtdblockd]
  256 root         0 SW<  [kpsmoused]
  259 root         0 SW<  [hid_compat]
  513 root         0 SWN  [jffs2_gcd_mtd0]
  518 root       940 S    logger -s -p 6 -t ''
  520 root       960 R    /bin/ash --login
  521 root       940 S    init
  530 root       952 S    syslogd -C16
  532 root       932 S    klogd
  544 root       484 S    /sbin/hotplug2 --override --persistent --max-children
 1190 root       728 S    /usr/sbin/dropbear -p 22
 1197 root       936 S    /usr/sbin/httpd -p 80 -h /www -r OpenWrt
 1336 nobody     604 S    /usr/sbin/dnsmasq -K -D -y -Z -b -E -s lan -S /lan/ -
 1404 root       956 S    udhcpc -t 0 -i eth2 -b -p /var/run/eth2.pid -R
 1418 root       808 S    /usr/sbin/ntpd -g -p /var/run/ntpd.pid
 8606 root      1968 S    hostapd -P /var/run/wifi-ath0.pid -B /var/run/hostapd
 8679 root      1968 S    hostapd -P /var/run/wifi-ath1.pid -B /var/run/hostapd
 8682 root       940 R    ps
root@OpenWrt:/etc/config#

Here is another wifi up run showing that the iwconfig calls are correct, so it's all pointing to the startup_hostapd=1 setting.

root@OpenWrt:/etc/config# sh -x /sbin/wifi up 2>&1  | grep iwconfig
br-lan: port 2(ath0) entering disabled state
device ath0 left promiscuous mode
br-lan: port 2(ath0) entering disabled state
br-lan: port 3(ath1) entering disabled state
device ath1 left promiscuous mode
br-lan: port 3(ath1) entering disabled state
+ iwconfig ath0 channel 0
device ath0 entered promiscuous mode
br-lan: topology change detected, propagating
br-lan: port 2(ath0) entering forwarding state
+ iwconfig ath0 essid on
+ iwconfig ath0 essid wpavap
+ iwconfig ath1 enc [1] s:mykey
+ iwconfig ath1 enc [2] off
+ iwconfig ath1 enc [3] off
+ iwconfig ath1 enc [4] off
+ iwconfig ath1 enc [1]
device ath1 entered promiscuous mode
br-lan: topology change detected, propagating
br-lan: port 3(ath1) entering forwarding state
+ iwconfig ath1 essid on
+ iwconfig ath1 essid wepvap
root@OpenWrt:/etc/config#

Unfortunately I have no patch to fix this... I just figured it out tonight.

Attachments (1)

001-reset_vars_in_foreach_vif.patch (456 bytes) - added by framer99 8 years ago.
clear "local" vars on each vif loop in madwifi.sh

Download all attachments as: .zip

Change History (7)

comment:1 Changed 8 years ago by framer99

looking deeper into this tonight, it seems that the "for each vif" loop in enable_atheros() with local declaration of start_hostapd:

    local first=1
    for vif in $vifs; do
        local start_hostapd vif_txpower

is not having the desired effect. start_hostapd gets set to 1 for the first vif which is psk, and remains set to 1 for subsequent loops of the "for each vif" block... even for wep vifs

I put some debug statements in around the $enc case statement lines and produced this:

root@OpenWrt:/lib/wifi# wifi up
before case $enc statement , vif=cfg031a2e start_hostapd=
enter wpa case, vif=cfg031a2e start_hostapd=
in wpa case after setting start_hostapd to 1, vif=cfg031a2e start_hostapd=1
Configuration file: /var/run/hostapd-ath0.conf
Using interface ath0 with hwaddr 00:15:6d:64:20:ff and ssid 'wpavap'
before case $enc statement , vif=cfg05b630 start_hostapd=1
enter wep case, vif=cfg05b630 start_hostapd=1
Configuration file: /var/run/hostapd-ath1.conf
Using interface ath1 with hwaddr 0a:15:6d:64:20:ff and ssid 'wepvap'
root@OpenWrt:/lib/wifi#

so is busybox ash supposed to honor local var declaration within a for loop inside a function?

I thought in bash(which i realize is not "ash" ) the local var declaration was used to set scope within the context of the current function call and not applicable to a individual for loop.

comment:2 Changed 8 years ago by framer99

so, assuming local var decl is not honored inside a for loop in ash, then the fix seems to be something like:

1. set start_hostapd=0 at the top(but inside) of the for each vif loop, 
2. set start_hostapd=1 in the wpa/psk case of the "case $enc" statement,

and remove the local declaration of start_hostapd to prevent confusion.

comment:3 Changed 8 years ago by framer99

ash man page says local keyword makes variables local scope for the function they are in. It doesn't mention a for loop, but my testing shows it doesn't work.

attached patch changes the local statement to an actual clear of the variables.
The check to actually run hostapd looks for start_hostapd to be non-zerolength, so things work as they should.

tested on x86 alix trunk build.

Changed 8 years ago by framer99

clear "local" vars on each vif loop in madwifi.sh

comment:4 Changed 8 years ago by framer99

this ticket can be closed since changeset 16308

https://dev.openwrt.org/changeset/16308

fixes the same problem

comment:5 Changed 7 years ago by florian

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

comment:6 Changed 2 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

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.