Configure batman adv on openwrt

Hi all! I configured Batman adv on three routers with the same firmware. And everything works well as long as the wired network is not connected. When connecting two routers directly, the second one stops responding. At the same time, everything works great over Wi-Fi. Both 2.4 and 5 GHz networks are configured for meshes and access points with the same names and parameters.

root@OpenWrt:/# cat /etc/config/network

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

config globals 'globals'
        option ula_prefix 'fd9c:cbbd:1596::/48'

config interface 'wan'
        option ifname 'eth1'
        option proto 'static'
        option netmask '255.255.255.0'
        list dns '8.8.8.8'
        option ipaddr '10.99.99.103'
        option gateway '10.99.99.99'

config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.2.253'
        option netmask '255.255.255.0'
        option ip6assign '60'
        list dns '8.8.8.8'
        option ifname 'bat0 eth0'
        option stp '1'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 1 2 3 4'
        option vid '1'

config interface 'bat0'
        option proto 'batadv'
        option bonding '1'
        option routing_algo 'BATMAN_IV'
        option hop_penalty '30'
        option bridge_loop_avoidance '1'
        option gw_mode 'server'

config interface 'BM_50'
        option proto 'batadv_hardif'
        option master 'bat0'
        option mtu '2304'

config interface 'BM_24'
        option proto 'batadv_hardif'
        option master 'bat0'
        option mtu '2304'

If you like have a look at this reference config: Batman mesh MTU configuation - #2 by _bernd

You likely don't needmostofthe options you have set and you have an error with your hardif config...

Unfortunately, your answer does not solve the situation I described in any way - settings like yours do not change anything

Then show your whole network config...

root@OpenWrt:/# cat /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option channel '36'
        option hwmode '11a'
        option path 'pci0000:00/0000:00:00.0'
        option htmode 'VHT80'
        option txpower '6'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option mode 'ap'
        option txpower '6'
        option key '*****'
        option encryption 'psk2'
        option ft_over_ds '0'
        option ssid 'Home_Router'
        option mobility_domain '1234'
        option ft_psk_generate_local '1'
        option ieee80211r '1'
        option network 'lan BE_0'

config wifi-device 'radio1'
        option type 'mac80211'
        option channel '11'
        option hwmode '11g'
        option path 'platform/ahb/18100000.wmac'
        option htmode 'HT20'
        option txpower '12'

config wifi-iface 'default_radio1'
        option device 'radio1'
        option mode 'ap'
        option txpower '12'
        option encryption 'psk2'
        option ft_over_ds '0'
        option mobility_domain '1234'
        option ft_psk_generate_local '1'
        option ieee80211r '1'
        option ssid 'Home_Router'
        option key '*****'
        option network 'lan BE_0'

config wifi-iface 'wifinet2'
        option mesh_rssi_threshold '0'
        option key '*****'
        option encryption 'sae'
        option device 'radio0'
        option mode 'mesh'
        option mesh_id 'Home_Mesh'
        option mesh_fwding '0'
        option network 'BM_50'

config wifi-iface 'wifinet3'
        option mesh_rssi_threshold '0'
        option encryption 'none'
        option device 'radio1'
        option mode 'mesh'
        option mesh_id 'Home_Mesh'
        option mesh_fwding '0'
        option network 'BM_24'

root@OpenWrt:/#

I want batman adv to work on all interfaces of the router + mesh + access points + bonding

your wireless config is a start but i/we need the network config...

just as a reference:

config wifi-iface 'mesh0'
    option  device      'radio0'
    option  ifname      'mesh0'
    option  network     'bat0_hardif_mesh0'
    option  mode        'mesh'
    option  mesh_fwding '0'
    option  mesh_id     'fde6:a09a:b373::/48'
    option  encryption  'psk2+ccmp'
    option  key         'XXX'

config wifi-iface 'mesh1
    option  device      'radio1'
    option  ifname      'mesh1'
    option  network     'bat0_hardif_mesh1'
    option  mode        'mesh'
    option  mesh_fwding '0'
    option  mesh_id     'fde6:a09a:b373::/48'
    option  encryption  'psk2+ccmp'
    option  key         'XXX'
config device
    option  name            'bat0'

config interface            'bat0'
    option  proto           'batadv'
    option  routing_algo    'BATMAN_IV'

config interface            'bat0_hardif_mesh0'
    option  proto           'batadv_hardif'
    option  master          'bat0'
    option  mtu             '2304'

config interface            'bat0_hardif_mesh1'
    option  proto           'batadv_hardif'
    option  master          'bat0'
    option  mtu             '2304'

Example switch port config:

config device
    option  name            'br-vlan65'
    option  type            'bridge'
    list    ports           'eth0.65'
    list    ports           'bat0.65'

Unfortunately, I can’t figure out how exactly to implement what I need.
Maybe it will be clearer this way:

  1. There are several devices (let's say 6) that I want to connect to a mesh network
  2. One point has Internet access via the van interface
  3. All points must be connected both via a wired network and a wireless network for greater fault tolerance.
  4. The network is single, there are no vlans in it, i.e. all devices see each other.
    How exactly can this be implemented? Thanks in advance for your patience!
root@OpenWrt:/# cat /etc/config/network

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

config globals 'globals'
        option ula_prefix 'fd9c:cbbd:1596::/48'

config interface 'wan'
        option ifname 'eth1'
        option proto 'static'
        option netmask '255.255.255.0'
        list dns '8.8.8.8'
        option ipaddr '10.99.99.103'
        option gateway '10.99.99.99'

config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.2.253'
        option netmask '255.255.255.0'
        option ip6assign '60'
        list dns '8.8.8.8'
        option ifname 'bat0 eth0 eth0'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 1 2 3 4'
        option vid '1'

config interface 'bat0'
        option proto 'batadv'
        option bonding '1'
        option routing_algo 'BATMAN_IV'
        option hop_penalty '30'
        option bridge_loop_avoidance '1'
        option gw_mode 'server'

config interface 'BM_50'
        option proto 'batadv_hardif'
        option master 'bat0'
        option mtu '2304'

config interface 'BM_24'
        option proto 'batadv_hardif'
        option master 'bat0'
        option mtu '2304'

root@OpenWrt:/# cat /etc/config/wireless

config wifi-device 'radio0'
        option type 'mac80211'
        option channel '36'
        option hwmode '11a'
        option path 'pci0000:00/0000:00:00.0'
        option htmode 'VHT80'
        option txpower '6'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option txpower '6'
        option key '12345678t'
        option encryption 'psk2'
        option ft_over_ds '0'
        option ssid 'Arma_Router'
        option mobility_domain '1234'
        option ft_psk_generate_local '1'
        option ieee80211r '1'

config wifi-device 'radio1'
        option type 'mac80211'
        option channel '11'
        option hwmode '11g'
        option path 'platform/ahb/18100000.wmac'
        option htmode 'HT20'
        option txpower '12'

config wifi-iface 'default_radio1'
        option device 'radio1'
        option network 'lan'
        option mode 'ap'
        option txpower '12'
        option encryption 'psk2'
        option ft_over_ds '0'
        option mobility_domain '1234'
        option ft_psk_generate_local '1'
        option ieee80211r '1'
        option ssid 'Arma_Router'
        option key '12345678t'

config wifi-iface 'wifinet2'
        option mesh_rssi_threshold '0'
        option key '12345678t'
        option encryption 'sae'
        option device 'radio0'
        option mode 'mesh'
        option mesh_id 'Arma_Mesh'
        option mesh_fwding '0'
        option network 'BM_50'

config wifi-iface 'wifinet3'
        option mesh_rssi_threshold '0'
        option encryption 'none'
        option device 'radio1'
        option mode 'mesh'
        option mesh_id 'Arma_Mesh'
        option mesh_fwding '0'
        option network 'BM_24'

root@OpenWrt:/#

Not quiet sure, but just give it a try. Either it helps, or at least it cleans things up....

# On openwrt there is always at least one VLAN defined. This part is "correct"
config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 1 2 3 4'
        option vid '1'

config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.2.253'
        option netmask '255.255.255.0'
        option ip6assign '60'
        list dns '8.8.8.8'
        list ifname 'bat0.1'
        list ifname 'eth0.1'

I've just set the VLAN 1 explicit on eth0 and bat0. If an option can be used multiple times, then option can be replaced by multiple list...

For now I would highly recommend to disable bonding on the batman-adv config! Get your mesh working before you try to "improve" it... The same applies to hop_penalty. For now stick with the defaults, as I have them posted already.
The gw_mode set the server is only usfull, if the router/ap (where it is set) actually has a WAN/uplink configured and available and working. Keep that in mind and read up https://www.open-mesh.org/projects/batman-adv/wiki/Gateways if you have not done so already...

Only this AP should have set gw mode "server" then.

For this you don't need bonding! And mixing/bonding ethernet+wireless does not sound like a good idea because of the highle different latency of the medium. If you only have a small mesh then multiple paths wont give any benefit.

I try my best :wink:

If the devices have a wired connection then you don't need mesh networking at all. You've got a basic star topology with one WAN connection (so that's your router) and the rest are just wireless access points with wired connections to the router. Give them all the same SSID and passphrase/PSK, put them on different channels, allow your wireless devices to move between them as required.

1 Like

Sure, the user could also pull more then one cable between these devices, but having batman-adv instant of STP isn't the worst of all ideas. Also it give the flexibility to not need cables at all between the router and AP(s).

We just don't know how the user has connected the devices :wink: Could be a Star, but could anything else, too.

I already wrote about fault tolerance - this is exactly what the mesh will be used for. But it turns out that with a wired connection this technology works much worse than just STP

if the Batman adv loop avoidance is worst then STP then something is off.
STP is/should be way slower.
Sadly there is no Rapid STP and Multiple VLAN STP.
Do you see something odd in the log or with the batcli?

I don’t see anything like that, although on the other hand, what exactly should you look at and what should you pay attention to?

brctl show to show the current state of the bridge. STP should be disabled, because you want to have loop avoidance: batctl meshif bat0 bridge_loop_avoidance should return enabled.

Connect two times to the router/ap, or use i.e. tmux, and follow the log with logread -f, while you i.e. turn the wireless off and on, or unplug, and plugin cables...
I suggest to wait for like 20 to 30 sec after unplug and replugin a cable or put the wireless back online, to see what happens...
For what you should look? Messages like if devices/interface got blocked or other batman related infos...
You can also use watch for to have periodic execution of the batman debug commands. Or use the poor mens method: while true; do clear; date; batctl meshif bat0 neighbors; sleep 1; done

(I've never encountered a worst spanning tree behavior with batman-adv so I'm not entirety sure, what you might see...

If you still have issues maybe draw a diagram with the physical and wireless connection but please verify the wireless mesh neighbors first...