tomeshnet / prototype-cjdns-pi

Prototype system for mesh networks on single board computers
https://chat.tomesh.net/#/room/#software:tomesh.net
GNU General Public License v3.0
218 stars 42 forks source link

When using 802.11s/adhoc some devices do not go into RUNNING state when WPA_SUPPLICANT is also running #468

Closed darkdrgn2k closed 4 years ago

darkdrgn2k commented 4 years ago

Reports that a stock raspbian does not have the issues with "RUNNING" missing from mesh-point state.

darkdrgn2k commented 4 years ago

Clean install

:heavy_check_mark: mesh module only

wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  

:x: Disabled WPA Kill in mesh-point

wlan1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

:x: manual meshpoint

sudo ifconfig wlan1 down
sudo iw wlan1 set type mp
sudo ifconfig wlan1 up
sudo iw dev wlan1  mesh join tomesh freq 2412
sudo iw dev wlan1  set mesh_param mesh_fwding=0
wlan1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
darkdrgn2k commented 4 years ago

Script reported to work:

#!/bin/bash

function isMeshable {
    interface=`iw dev | grep phy#$1 -A 1 | grep Interface | awk '{print $2}'`

    # Check to see if driver reports missing mesh point support
    if  [ -z "$(iw phy phy$1 info | grep 'mesh point')" ]; then
        result='' # Indicate interface is not meshable
    # XRADIO driver reports Mesh Point but does not actually work
    elif [ "$(basename $(readlink /sys/class/net/$interface/device/driver))" == 'xradio_wlan' ]; then
        result='' # Indicate interface is actually not meshable
    else
        result='1' # Indicate interface supports mesh point
    fi

    echo $result
}

set -e

# Set wireless regulatory domain
sudo iw reg set BO

# Find first 802.11s Mesh Point capable device
for wlanfile in /sys/class/net/*; do
    int="$(basename "$wlanfile")"
    if [ -d "/sys/class/net/$int/wireless" ]; then
        phy=$(iw dev "$int" info | grep wiphy | awk '{print $2}')
        if [ ! -z "$phy" ]; then
            if ! [ -z $(isMeshable "$phy") ]; then
                mesh_dev="$int"
            fi
        fi
    fi
done

# If no device found exit with error
if [ -z "$mesh_dev" ]; then
    exit 1
fi

# Shut down the mesh_dev interface
sudo ifconfig $mesh_dev down

# Convert mesh_dev to 802.11s Mesh Point interface
sudo iw $mesh_dev set type mp

# Bring up the mesh_dev interface
sudo ifconfig $mesh_dev up

# Optionally assign IPv4 address to the mesh_dev interface
# sudo ifconfig $mesh_dev 192.168.X.Y

# Join the mesh network
# To join radio in HT40+ htmode (enable 802.11n rates) add  HT40+ to end of this line
sudo iw dev $mesh_dev mesh join HS freq 2412 HT40+

# Disable forwarding since we rely on cjdns to do routing and only uses Mesh Point as a point-to-point link
sudo iw dev $mesh_dev set mesh_param mesh_fwding=0

# Prevent trying to establish connections with nodes under -65 dBm
sudo iw dev $mesh_dev set mesh_param mesh_rssi_threshold -85

# Make a local-link ip out of yggdrasil ip if $mesh_dev does not have a local-link ip
if [ ! -z "$(which yggdrasilctl)" ]; then
  if [ -z "$(ip addr show dev $mesh_dev | grep inet6\ fe)" ]; then
      ip="$(sudo yggdrasilctl getSelf | grep "IPv6 address" | awk '{print $3}' | cut -d ":" -f5-8)"
      ip address add dev $mesh_dev scope link fe80::${ip}/64
  fi
fi
pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.40.240  netmask 255.255.255.0  broadcast 192.168.40.255
        inet6 fddd:869:29bf::b78  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::1a5:fc4d:706:f857  prefixlen 64  scopeid 0x20<link>
        inet6 2607:f2c0:940e:1c00:c08d:4bf9:7902:fd6a  prefixlen 64  scopeid 0x0<global>
        inet6 2607:f2c0:940e:1c00::b78  prefixlen 128  scopeid 0x0<global>
        inet6 fddd:869:29bf:0:3836:a52d:898d:32f6  prefixlen 64  scopeid 0x0<global>
        ether dc:a6:32:04:64:8a  txqueuelen 1000  (Ethernet)
        RX packets 79  bytes 9959 (9.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 121  bytes 54489 (53.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether dc:a6:32:04:64:8b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 18:a6:f7:14:26:d2  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi@raspberrypi:~ $ bash test.sh
pi@raspberrypi:~ $ iw dev
phy#1
        Interface wlan1
                ifindex 4
                wdev 0x100000001
                addr 18:a6:f7:14:26:d2
                type mesh point
                channel 1 (2412 MHz), width: 40 MHz, center1: 2422 MHz
                txpower 20.00 dBm
phy#0
        Unnamed/non-netdev interface
                wdev 0x2
                addr 22:a7:2e:81:9d:48
                type P2P-device
                txpower 31.00 dBm
        Interface wlan0
                ifindex 3
                wdev 0x1
                addr dc:a6:32:04:64:8b
                type managed
                channel 34 (5170 MHz), width: 20 MHz, center1: 5170 MHz
                txpower 31.00 dBm
pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.40.240  netmask 255.255.255.0  broadcast 192.168.40.255
        inet6 fddd:869:29bf::b78  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::1a5:fc4d:706:f857  prefixlen 64  scopeid 0x20<link>
        inet6 2607:f2c0:940e:1c00:c08d:4bf9:7902:fd6a  prefixlen 64  scopeid 0x0<global>
        inet6 2607:f2c0:940e:1c00::b78  prefixlen 128  scopeid 0x0<global>
        inet6 fddd:869:29bf:0:3836:a52d:898d:32f6  prefixlen 64  scopeid 0x0<global>
        ether dc:a6:32:04:64:8a  txqueuelen 1000  (Ethernet)
        RX packets 151  bytes 16432 (16.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 177  bytes 64973 (63.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether dc:a6:32:04:64:8b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 18:a6:f7:14:26:d2  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi@raspberrypi:~ $
darkdrgn2k commented 4 years ago

Reported behaviors seems to be because of different drivers the ALFA wireless cards use.

Seems the underlying issue has something to do with drivers, however patching wpa_supplicant works on all devices.