oblique / create_ap

[NOT MAINTAINED] This script creates a NATed or Bridged WiFi Access Point.
BSD 2-Clause "Simplified" License
4.43k stars 998 forks source link

create_ap can't work after upgrade from previous version #130

Closed caasiu closed 8 years ago

caasiu commented 8 years ago

I'm running Arch with Networkmanager 1.0.8-1 the previous version doesn't work well with wpa_supplicant 2.5 but fine with 2.3(I'm sure!!) here is the issue message:

RTNETLINK answers: Device or resource busy
ERROR: Maybe your WiFi adapter does not fully support virtual interfaces.
       Try again with --no-virt.

so, I try to use yaourt to upgrade create_ap but get the same result, I also try install manually,but same error:

Config dir: /tmp/create_ap.wlp8s0.conf.naB96qFb
PID: 1306
Network Manager found, set ap0 as unmanaged device... DONE
wlp8s0 is already associated with channel 1 (2412 MHz)
Creating a virtual WiFi interface... ap0 created.
RTNETLINK answers: Device or resource busy

ERROR: Maybe your WiFi adapter does not fully support virtual interfaces.
       Try again with --no-virt.

Doing cleanup.. done

I have double checked Networkmanager.conf and I comfirm there is unmanaged-devices=interface-name:ap0,but it still doesn't work even use wpa_supplicant 2.3!! Do I miss anything before upgrate to latest version? Beside, how to make a clean installation? Thanks for your time

caasiu commented 8 years ago

Here is iw list:

Wiphy phy0
    max # scan SSIDs: 20
    max scan IEs length: 439 bytes
    max # sched scan SSIDs: 20
    max # match sets: 11
    Retry short limit: 7
    Retry long limit: 4
    Coverage class: 0 (up to 0m)
    Device supports RSN-IBSS.
    Device supports AP-side u-APSD.
    Supported Ciphers:
        * WEP40 (00-0f-ac:1)
        * WEP104 (00-0f-ac:5)
        * TKIP (00-0f-ac:2)
        * CCMP (00-0f-ac:4)
        * CMAC (00-0f-ac:6)
    Available Antennas: TX 0 RX 0
    Supported interface modes:
         * IBSS
         * managed
         * AP
         * AP/VLAN
         * monitor
         * P2P-client
         * P2P-GO
         * P2P-device
    Band 1:
        Capabilities: 0x11e2
            HT20/HT40
            Static SM Power Save
            RX HT20 SGI
            RX HT40 SGI
            TX STBC
            RX STBC 1-stream
            Max AMSDU length: 3839 bytes
            DSSS/CCK HT40
        Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
        Minimum RX AMPDU time spacing: 4 usec (0x05)
        HT Max RX data rate: 300 Mbps
        HT TX/RX MCS rate indexes supported: 0-15
        Bitrates (non-HT):
            * 1.0 Mbps
            * 2.0 Mbps (short preamble supported)
            * 5.5 Mbps (short preamble supported)
            * 11.0 Mbps (short preamble supported)
            * 6.0 Mbps
            * 9.0 Mbps
            * 12.0 Mbps
            * 18.0 Mbps
            * 24.0 Mbps
            * 36.0 Mbps
            * 48.0 Mbps
            * 54.0 Mbps
        Frequencies:
            * 2412 MHz [1] (22.0 dBm)
            * 2417 MHz [2] (22.0 dBm)
            * 2422 MHz [3] (22.0 dBm)
            * 2427 MHz [4] (22.0 dBm)
            * 2432 MHz [5] (22.0 dBm)
            * 2437 MHz [6] (22.0 dBm)
            * 2442 MHz [7] (22.0 dBm)
            * 2447 MHz [8] (22.0 dBm)
            * 2452 MHz [9] (22.0 dBm)
            * 2457 MHz [10] (22.0 dBm)
            * 2462 MHz [11] (22.0 dBm)
            * 2467 MHz [12] (22.0 dBm) (no IR)
            * 2472 MHz [13] (22.0 dBm) (no IR)
    Supported commands:
         * new_interface
         * set_interface
         * new_key
         * start_ap
         * new_station
         * new_mpath
         * set_mesh_config
         * set_bss
         * authenticate
         * associate
         * deauthenticate
         * disassociate
         * join_ibss
         * join_mesh
         * remain_on_channel
         * set_tx_bitrate_mask
         * frame
         * frame_wait_cancel
         * set_wiphy_netns
         * set_channel
         * set_wds_peer
         * start_sched_scan
         * probe_client
         * set_noack_map
         * register_beacons
         * start_p2p_device
         * set_mcast_rate
         * channel_switch
         * set_qos_map
         * add_tx_ts
         * connect
         * disconnect
    Supported TX frame types:
         * IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
         * P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
    Supported RX frame types:
         * IBSS: 0x40 0xb0 0xc0 0xd0
         * managed: 0x40 0xd0
         * AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
         * AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
         * mesh point: 0xb0 0xc0 0xd0
         * P2P-client: 0x40 0xd0
         * P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
         * P2P-device: 0x40 0xd0
    WoWLAN support:
         * wake up on disconnect
         * wake up on magic packet
         * wake up on pattern match, up to 20 patterns of 16-128 bytes,
           maximum packet offset 0 bytes
         * can do GTK rekeying
         * wake up on GTK rekey failure
         * wake up on EAP identity request
         * wake up on 4-way handshake
         * wake up on rfkill release
         * wake up on network detection, up to 11 match sets
         * wake up on TCP connection
    software interface modes (can always be added):
         * AP/VLAN
         * monitor
    valid interface combinations:
         * #{ managed } <= 1, #{ AP, P2P-client, P2P-GO } <= 1, #{ P2P-device } <= 1,
           total <= 3, #channels <= 2
    HT Capability overrides:
         * MCS: ff ff ff ff ff ff ff ff ff ff
         * maximum A-MSDU length
         * supported channel width
         * short GI for 40 MHz
         * max A-MPDU length exponent
         * min MPDU start spacing
    Device supports TX status socket option.
    Device supports HT-IBSS.
    Device supports SAE with AUTHENTICATE command
    Device supports low priority scan.
    Device supports scan flush.
    Device supports per-vif TX power setting
    P2P GO supports CT window setting
    P2P GO supports opportunistic powersave setting
    Driver supports a userspace MPM
    Device supports static SMPS
    Device supports dynamic SMPS
    Device supports WMM-AC admission (TSPECs)
    Device supports configuring vdev MAC-addr on create

and why can't use create_ap without Networkmanager? I wonder if networkmanager take the full use of the interface? Thanks

oblique commented 8 years ago

I also use Arch, I will update it in few hours and I will let you know. Try to stop NetworkManager and then use create_ap. Do you get an error?

caasiu commented 8 years ago

Thanks for reply so quick yes. Error:NetworkManager is not running. Does create_ap have to run with NM? As I can't use wifi-menu + create_ap btw,if I use unmanaged-devices=mac:mymacaddress instead of interface-name in NM.conf, I can use create_ap but can't connect to internet on other arch,your script + NM + wpa_supplicant 2.5 run well, so i don't know what's wrong with mine My wireless card is 7260 and Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller

oblique commented 8 years ago

The error is from nmcli and does not affect create_ap. I just pushed a commit that redirects it to /dev/null. Before you run hostapd, run the following and give me the output:

ps uxa | grep hostapd
iw dev

I also use Arch with hostapd 2.5 and works fine.

oblique commented 8 years ago

You are probably running another instance of create_ap or hostapd. I can get this error if an already running create_ap and try to run a second instance on the same time.

caasiu commented 8 years ago

My hostapd version is 2.5-1,too here is output in order: ps uxa | grep hostapd roger 2579 0.0 0.0 11020 2196 pts/0 D+ 09:43 0:00 grep hostapd iw dev phy#0 Unnamed/non-netdev interface wdev 0x2 addr type P2P-device Interface wlp8s0 ifindex 3 wdev 0x1 addr mymac type managed channel 1 (2412 MHz), width: 40 MHz, center1: 2422 MHz

hostapd.service is not enabled,is it? I don't have any conf file under /etc/hostapd/ (I didn't remove it manually) and fail to systemctl start hostapd.service create_ap doesn't require wpa_supplicant,but I'm sure it's related to wpa_supplicant(2.3-->2.5) not hostapd --- I know it's rediculous I did remove previous version create_ap directly from /usr/bin/create_ap and then clone the latest version from your git after can't use it, so is there any problem with that?

oblique commented 8 years ago

You should not enable or run hostapd manually, create_ap will take care of it. To install the new create_ap just clone and run make install.

From iw dev it looks like the problem in that a P2P-device is created and we can not combine this with an extra virtual interface, probably the new wpa_supplicant create the p2p device.

My adapter does not support P2P (a.k.a WiFi Direct) so I can not reproduce it. I will try to find another adapter. For now try the following before you run create_ap and let me know if it works or not:

iw wdev 2 p2p stop
caasiu commented 8 years ago

Get the same result it's still not working :( However thanks your help According to your README, I try both make install and yaourt to reinstall again,but show same error--not support virtual interface. Before using yaourt, I have to remove create_ap from /usr/lib/ manually, and after yaourt -S,pacman show me /usr/lib/systemed/system/create_ap save as create_ap.pacorig How can i make a clean installation?

caasiu commented 8 years ago

After I downgrade wpa_supplicant to 2.3, then run iw dev: phy#0 Interface wlp8s0 ifindex 3 wdev 0x1 addr type managed channel 1 (2412 MHz), width: 40 MHz, center1: 2422 MHz

There is no p2p device anymore,but run create_ap with nm:

Config dir: /tmp/create_ap.wlp8s0.conf.feZULXM5 PID: 1894 Network Manager found, set ap0 as unmanaged device... DONE wlp8s0 is already associated with channel 1 (2412 MHz) Creating a virtual WiFi interface... ap0 created. RTNETLINK answers: Device or resource busy

ERROR: Maybe your WiFi adapter does not fully support virtual interfaces. Try again with --no-virt.

So, it may be related to something else. btw, stop nm I can run create_ap and I notice that ap0 address and p2p device address are same under wpa_supplicant 2.5

oblique commented 8 years ago

So, without NetworkManager you can run create_ap without any problems?

caasiu commented 8 years ago

Yes ! To be specific, create_ap runs well after I stop networkmanager.service, but my computer can't connect to internet. So does wifi-menu So, if wifi interface has already been used,create_ap can't create virtual interface

caasiu commented 8 years ago

When it comes to wpa_supplicant 2.3:

ArchLinux NetworkManager[373]: <info>  (ap0): using nl80211 for WiFi device control
ArchLinux NetworkManager[373]: <info>  (ap0): driver supports Access Point (AP) mode
 * ArchLinux NetworkManager[373]: <info>  (ap0): new 802.11 WiFi device (carrier:UNKNOWN,driver:'iwlwifi', ifindex: 4)
ArchLinux NetworkManager[373]: <info>  (ap0): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
 * ArchLinux NetworkManager[373]: <error> [1450703558.811711] [platform/nm-linux-platform.c:2883] do_change_link(): platform-lin
ArchLinux kernel: IPv6: ADDRCONF(NETDEV_UP): ap0: link is not ready
ArchLinux NetworkManager[373]: <error> [1450703558.819861] [supplicant-manager/nm-supplicant-interface.c:766] interface_add_c
ArchLinux NetworkManager[373]: <info>  (ap0): supplicant interface state: starting -> down
 * ArchLinux NetworkManager[373]: <error> [1450703558.822036] [supplicant-manager/nm-supplicant-interface.c:766] interface_add_c

when it's wpa_supplicant 2.5:

ArchLinux NetworkManager[384]: <info>  (ap0): using nl80211 for WiFi device control
ArchLinux NetworkManager[384]: <info>  (ap0): driver supports Access Point (AP) mode
 * ArchLinux NetworkManager[384]: <info>  (ap0): new 802.11 WiFi device (carrier: UNKNOWN, drive
r: 'iwlwifi', ifindex: 5)
ArchLinux NetworkManager[384]: <info>  (ap0): device state change: unmanaged -> unavailable (
reason 'managed') [10 20 2]
 * ArchLinux NetworkManager[384]: <error> [1450701007.206031] [platform/nm-linux-platform.c:2883] do_change_link(): platform-linux: do-cha
ArchLinux kernel: IPv6: ADDRCONF(NETDEV_UP): ap0: link is not ready
ArchLinux wpa_supplicant[424]: Could not set interface ap0 flags (UP): Device or resource bus
ArchLinux wpa_supplicant[424]: nl80211: Could not set interface 'ap0' UP
ArchLinux wpa_supplicant[424]: nl80211: deinit ifname=ap0 disabled_11b_rates=0
ArchLinux wpa_supplicant[424]: Could not set interface ap0 flags (UP): Device or resource bus
ArchLinux wpa_supplicant[424]: WEXT: Could not set interface 'ap0' UP
ArchLinux wpa_supplicant[424]: ap0: Failed to initialize driver interface
 * ArchLinux NetworkManager[384]: <error> [1450701007.212310] [supplicant-manager/nm-supplicant-interface.c:766] interface_add_cb(): (ap0)
caasiu commented 8 years ago

I go back to previous version.

commit 0ba638f7808ab3019bf8b02ebe354556f7f084eb
Author: oblique <psyberbits@gmail.com>
Date:   Tue Sep 2 23:05:46 2014 +0300

    Detect if the adapter can be an AP and AP+STA

    Fix #9

The newer version can't work for me with wpa_supplicant 2.3. Just don't know why... Then I add unmanaged-devices=mac:XX:XX:XX:XX:83 in NM.conf here is my iw dev

phy#0
    Interface wlp8s0ap
        ifindex 13
        wdev 0xb
        addr XX:XX:XX:XX:XX:83
        ssid accesspoint
        type AP
        channel 1 (2412 MHz), width: 20 MHz (no HT), center1: 2412 MHz
    Interface wlp8s0
        ifindex 3
        wdev 0x1
        addr XX:XX:XX:XX:XX:82
        type managed
        channel 1 (2412 MHz), width: 40 MHz, center1: 2422 MHz

Is it probably related to the width of virtual interface? Thanks your time and great help

oblique commented 8 years ago

No. It is related on the combinations of virtual interfaces that your adapter accepts and how many interfaces you can have.

caasiu commented 8 years ago

Just 1 interface. I check and install previous version one by one. I'm sure create_ap can't work fine, since the version below.

 commit ec0df440f82e7a0daca10dc1b12a1c85bb47b9d7
Author: oblique <psyberbits@gmail.com>
Date:   Sun Sep 21 18:28:41 2014 +0300

    Add 'managed' virtual interface instead of '__ap', hostapd will change it anyway

Hope it can help you ;)

oblique commented 8 years ago

Checkout to origin/master and then revert that commit. Does it work after that?

caasiu commented 8 years ago

no. Both of them said:

wlp8s0 is already associated with channel 11 (2462 MHz), fallback to channel 11
Creating a virtual WiFi interface... ap0 created.
RTNETLINK answers: Device or resource busy

ERROR: Maybe your WiFi adapter does not fully support virtual interfaces.
       Try again with --no-virt.

And the latest version(2dcc4070006790f139dd46e63cac2aa23df3c62e) working fine for me also give message

hostapd will fail to use channel 1 because wlp8s0 is already set to channel 11, fallback to channel 11.
oblique commented 8 years ago

Hi, can you fetch the latest commit and test it?

caasiu commented 8 years ago

Cheer! You make it! :+1: It solves the issue. Could you please explain the solution in short? Thank you very much.

oblique commented 8 years ago

I was creating the new virtual interface as managed and then hostapd was changing it to __ap. The problem was that some adapters can not have two managed interfaces, so now I'm creating it as __ap from the beginning.