Skip to content

Commit

Permalink
batadv proto randomize mac addresses of included interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ilario authored and G10h4ck committed Jun 12, 2020
1 parent 0ef3a26 commit 4ed70e5
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 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 @@ -94,10 +80,20 @@ function batadv.setup_interface(ifname, args)

local owrtInterfaceName, _, owrtDeviceName = network.createVlanIface(ifname, vlanId, nameSuffix, vlanProto)

--! Avoid dmesg flooding caused by BLA with messages like "br-lan:
--! received packet on bat0 with own address as source address".
--! Randomize MAC address for each of the interfaces included in Batman-adv.
local id = utils.get_id(ifname)
local randomMac = network.primary_mac();
randomMac[1] = id[1]
randomMac[2] = id[2]
randomMac[3] = id[3]

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")
uci:set("network", owrtDeviceName, "macaddr", table.concat(randomMac, ":"))
uci:save("network")
end

Expand Down

0 comments on commit 4ed70e5

Please sign in to comment.