Skip to content

Commit

Permalink
lime-proto-{bmx6, batadv} now uses 802.1ad vlan (depend on newer netifd)
Browse files Browse the repository at this point in the history
  • Loading branch information
G10h4ck authored and frank95 committed Aug 9, 2014
1 parent 1b7b1ab commit 92b731d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 41 deletions.
62 changes: 34 additions & 28 deletions packages/lime-proto-batadv/src/batadv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,48 @@ batadv = {}

function batadv.setup_interface(ifname, args)
if ifname:match("^wlan%d_ap") then return end
if not args[2] then return end

local owrtDeviceName = network.limeIfNamePrefix..ifname.."_batadv_dev"
local owrtInterfaceName = network.limeIfNamePrefix..ifname.."_batadv_if"
local linuxBaseIfname = ifname
local vlanId = args[2]
local linux802adIfName = ifname.."."..vlanId

local interface = network.limeIfNamePrefix..ifname.."_batadv"
local owrtFullIfname = ifname
local mtu = 1500
local mtu = 1532
if linuxBaseIfname:match("^eth") then mtu = 1496 end

local uci = libuci:cursor()
uci:set("network", interface, "interface")
uci:set("network", interface, "proto", "batadv")
uci:set("network", interface, "mesh", "bat0")

if ifname:match("^wlan") then
owrtFullIfname = "@"..network.limeIfNamePrefix..owrtFullIfname
mtu = 1532
end
if args[2] then
owrtFullIfname = owrtFullIfname..network.vlanSeparator..args[2]
if ifname:match("^eth") then
mtu = 1496

-- BEGIN
-- Workaround to http://www.libre-mesh.org/issues/32
-- We create a new macaddress for ethernet vlan interface
-- We use 000049 Unicast MAC prefix reserved by Apricot Ltd
-- We change the 7nt bit to 1 to give it locally administered meaning
-- Then use it as the new mac address prefix "02:00:49"
local vlanMacAddr = network.get_mac(ifname)
vlanMacAddr[1] = "02"
vlanMacAddr[2] = "00"
vlanMacAddr[3] = "49"
uci:set("network", interface, "macaddr", table.concat(vlanMacAddr, ":"))
--- END
end
uci:set("network", owrtDeviceName, "device")
uci:set("network", owrtDeviceName, "type", "8021ad")
uci:set("network", owrtDeviceName, "name", linux802adIfName)
uci:set("network", owrtDeviceName, "ifname", linuxBaseIfname)
uci:set("network", owrtDeviceName, "vid", vlanId)

uci:set("network", owrtInterfaceName, "interface")
uci:set("network", owrtInterfaceName, "proto", "batadv")
uci:set("network", owrtInterfaceName, "mesh", "bat0")
uci:set("network", owrtInterfaceName, "ifname", linux802adIfName)
uci:set("network", owrtInterfaceName, "mtu", mtu)

-- BEGIN
-- Workaround to http://www.libre-mesh.org/issues/32
-- We create a new macaddress for ethernet vlan interface
-- We use 000049 Unicast MAC prefix reserved by Apricot Ltd
-- We change the 7nt bit to 1 to give it locally administered meaning
-- Then use it as the new mac address prefix "02:00:49"
if linuxBaseIfname:match("^eth") then
local vlanMacAddr = network.get_mac(linuxBaseIfname)
vlanMacAddr[1] = "02"
vlanMacAddr[2] = "00"
vlanMacAddr[3] = "49"
uci:set("network", owrtInterfaceName, "macaddr", table.concat(vlanMacAddr, ":"))
end
--- END

uci:set("network", interface, "ifname", owrtFullIfname)
uci:set("network", interface, "mtu", mtu)
uci:save("network")
end

Expand Down
34 changes: 21 additions & 13 deletions packages/lime-proto-bmx6/src/bmx6.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@ bmx6 = {}

function bmx6.setup_interface(ifname, args)
if ifname:match("^wlan%d_ap") then return end
if not args[2] then return end

local interface = network.limeIfNamePrefix..ifname.."_bmx6"
local owrtFullIfname = ifname
if args[2] then owrtFullIfname = owrtFullIfname..network.vlanSeparator..args[2] end
local owrtDeviceName = network.limeIfNamePrefix..ifname.."_bmx6_dev"
local owrtInterfaceName = network.limeIfNamePrefix..ifname.."_bmx6_if"
local linuxBaseIfname = ifname
local vlanId = args[2]
local linux802adIfName = ifname.."."..vlanId

local uci = libuci:cursor()

uci:set("bmx6", interface, "dev")
uci:set("bmx6", interface, "dev", owrtFullIfname)
uci:save("bmx6")
uci:set("network", owrtDeviceName, "device")
uci:set("network", owrtDeviceName, "type", "8021ad")
uci:set("network", owrtDeviceName, "name", linux802adIfName)
uci:set("network", owrtDeviceName, "ifname", linuxBaseIfname)
uci:set("network", owrtDeviceName, "vid", vlanId)

-- This must go here because @ notation is not supported by bmx6 but is needed by netifd
if ifname:match("^wlan") then owrtFullIfname = "@lm_"..owrtFullIfname end
uci:set("network", owrtInterfaceName, "interface")
uci:set("network", owrtInterfaceName, "ifname", linux802adIfName)
uci:set("network", owrtInterfaceName, "proto", "none")
uci:set("network", owrtInterfaceName, "auto", "1")
uci:set("network", owrtInterfaceName, "mtu", "1398")

uci:set("network", interface, "interface")
uci:set("network", interface, "ifname", owrtFullIfname)
uci:set("network", interface, "proto", "none")
uci:set("network", interface, "auto", "1")
uci:set("network", interface, "mtu", "1398")
uci:save("network")

uci:set("bmx6", owrtInterfaceName, "dev")
uci:set("bmx6", owrtInterfaceName, "dev", linux802adIfName)

uci:save("bmx6")
end

function bmx6.clean()
Expand Down

0 comments on commit 92b731d

Please sign in to comment.