Skip to content

Commit

Permalink
Merge pull request #726 from G10h4ck/batadv-ifmacaddresses
Browse files Browse the repository at this point in the history
Batman-adv enable meshing over ethernet replaces #703 #724
  • Loading branch information
G10h4ck authored Jun 25, 2020
2 parents 57565ec + 60e4cf2 commit 5b3a34d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/lime-proto-batadv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define Package/$(PKG_NAME)
CATEGORY:=LiMe
MAINTAINER:=Gioacchino Mazzurco <[email protected]>
URL:=http://libremesh.org
DEPENDS:=+lime-system +lua +libuci-lua +kmod-batman-adv +kmod-dummy
DEPENDS:=+lime-system +lua +libuci-lua +kmod-batman-adv
PKGARCH:=all
endef

Expand Down
36 changes: 20 additions & 16 deletions packages/lime-proto-batadv/files/usr/lib/lua/lime/proto/batadv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ function batadv.configure(args)
uci:save(cfg_file)
lan.setup_interface("bat0", nil)

--! Avoid dmesg flooding caused by BLA. Create a dummy0 interface with
--! custom MAC, as dummy0 is created very soon on boot it is added as
--! first and then main interface to batman so BLA messages are sent
--! from that MAC avoiding generating warning like:
--! br-lan: received packet on bat0 with own address as source address
local owrtInterfaceName = network.limeIfNamePrefix.."batadv_dummy_if"
local dummyMac = network.primary_mac(); dummyMac[1] = "aa"
uci:set("network", owrtInterfaceName, "interface")
uci:set("network", owrtInterfaceName, "ifname", "dummy0")
uci:set("network", owrtInterfaceName, "macaddr", table.concat(dummyMac, ":"))
uci:set("network", owrtInterfaceName, "proto", batadv.ifc_proto)
uci:set("network", owrtInterfaceName, batadv.type_option, "bat0")
uci:save("network")

-- enable alfred on bat0 if installed
if utils.is_installed("alfred") then
uci:set("alfred", "alfred", "batmanif", "bat0")
Expand All @@ -78,7 +64,6 @@ end
function batadv.setup_interface(ifname, args)
if not args["specific"] then
if ifname:match("^wlan%d+.ap") then return end
if ifname:match("^eth") then return end
end

local vlanId = args[2] or "%N1"
Expand All @@ -95,9 +80,28 @@ function batadv.setup_interface(ifname, args)
local owrtInterfaceName, _, owrtDeviceName = network.createVlanIface(ifname, vlanId, nameSuffix, vlanProto)

local uci = config.get_uci_cursor()
uci:set("network", owrtDeviceName, "mtu", mtu)
uci:set("network", owrtInterfaceName, "proto", batadv.ifc_proto)
uci:set("network", owrtInterfaceName, batadv.type_option, "bat0")

if ifname:match("^eth") then
--! TODO: Use DSA to check if ethernet device is capable of bigger MTU
--! reducing it
mtu = network.MTU_ETH_WITH_VLAN

--! Avoid dmesg flooding caused by BLA with messages like "br-lan:
--! received packet on bat0 with own address as source address".
--! Tweak MAC address for each of the interfaces used by Batman-adv
--! 00 + Locally administered unicast .. 2 bytes from interface name
--! .. 3 bytes from main interface
local id = utils.get_id(ifname)
local vMacaddr = network.primary_mac();
vMacaddr[1] = "02"
vMacaddr[2] = id[2]
vMacaddr[3] = id[3]
uci:set("network", owrtDeviceName, "macaddr", table.concat(vMacaddr, ":"))
end

uci:set("network", owrtDeviceName, "mtu", mtu)
uci:save("network")
end

Expand Down
6 changes: 0 additions & 6 deletions packages/lime-proto-batadv/tests/test_batadv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ describe('LiMe proto Batman-adv #protobatadv', function()
assert.is.equal('1', uci:get('network', 'bat0', 'bridge_loop_avoidance'))
assert.is.equal('0', uci:get('network', 'bat0', 'multicast_mode'))

assert.is.equal('batadv_hardif', uci:get("network", "lm_net_batadv_dummy_if", "proto"))
assert.is.equal('bat0', uci:get("network", "lm_net_batadv_dummy_if", "master"))

-- anygw is disabled
assert.is_nil(uci:get('network', 'bat0', 'distributed_arp_table'))
assert.is_nil(uci:get('network', 'bat0', 'gw_mode'))
Expand Down Expand Up @@ -58,9 +55,6 @@ describe('LiMe proto Batman-adv #protobatadv', function()

assert.is.equal('1', uci:get('batman-adv', 'bat0', 'bridge_loop_avoidance'))
assert.is.equal('0', uci:get('batman-adv', 'bat0', 'multicast_mode'))

assert.is.equal('batadv', uci:get("network", "lm_net_batadv_dummy_if", "proto"))
assert.is.equal('bat0', uci:get("network", "lm_net_batadv_dummy_if", "mesh"))
end)

before_each('', function()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ currUptime="$(get_uptime)"

candidateAddresses="$(
for iface in $(ls /sys/class/net/) ; do
echo ${iface} | grep -q '^dummy' && continue
ls /sys/class/net/${iface}/upper_bat? &> /dev/null || continue
ping6 -c 2 ff02::1%${iface} 2> /dev/null | \
Expand Down

0 comments on commit 5b3a34d

Please sign in to comment.