From cb6dc4729982c2e1b9c4373d58296533f24ca8ef Mon Sep 17 00:00:00 2001 From: lemoer Date: Sun, 24 Apr 2016 19:16:30 +0200 Subject: [PATCH] gluon-core: interfaces with forbidden mac are not configured anymore. --- .../upgrade/320-gluon-client-bridge-wireless | 8 ++------ .../files/usr/lib/lua/gluon/util.lua | 7 ++++--- .../320-gluon-mesh-batman-adv-core-wireless | 20 ++++++------------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless b/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless index dc516a9c..34d8f3b6 100755 --- a/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless +++ b/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless @@ -21,13 +21,9 @@ local function configure_client(config, radio, index, suffix) uci:delete('wireless', name) - if index == 0 then - macaddr = util.generate_mac(0) - elseif index == 1 then - macaddr = util.generate_mac(3) - end + macaddr = util.generate_mac(3*index) - if config then + if config and macaddr then uci:section('wireless', 'wifi-iface', name, { device = radio, diff --git a/package/gluon-core/files/usr/lib/lua/gluon/util.lua b/package/gluon-core/files/usr/lib/lua/gluon/util.lua index 006c9300..0b6d91bb 100644 --- a/package/gluon-core/files/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/files/usr/lib/lua/gluon/util.lua @@ -93,11 +93,12 @@ function generate_mac(i) m1 = nixio.bit.bor(m1, 0x02) -- set locally administered bit m1 = nixio.bit.band(m1, 0xFE) -- unset the multicast bit - -- It's necessary that the last bits of the mac do - -- not vary on a single interface, since some chips are using + -- It's necessary that the first 45 bits of the mac do + -- not vary on a single hardware interface, since some chips are using -- a hardware mac filter. (e.g 'ramips-rt305x') - i = i % 0x08 -- max allowed value is 0x07 + if i > 7 then return nil end -- max allowed id (0b111) + m6 = nixio.bit.band(m6, 0xF8) -- zero the last three bits (space needed for counting) m6 = m6 + i -- add virtual interface id diff --git a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless index 900c05e1..bc77428f 100755 --- a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless +++ b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless @@ -29,7 +29,9 @@ local function configure_ibss(config, radio, index, suffix, disabled) uci:delete('network', name .. '_vlan') uci:delete('wireless', name) - if config then + macaddr = util.generate_mac(3*index+2) + + if config and macaddr then if config.vlan then uci:section('network', 'interface', name, { @@ -53,12 +55,6 @@ local function configure_ibss(config, radio, index, suffix, disabled) ) end - if index == 0 then - macaddr = util.generate_mac(2) - elseif index == 1 then - macaddr = util.generate_mac(5) - end - uci:section('wireless', 'wifi-iface', name, { device = radio, @@ -83,7 +79,9 @@ local function configure_mesh(config, radio, index, suffix, disabled) uci:delete('network', name) uci:delete('wireless', name) - if config then + macaddr = util.generate_mac(3*index+1) + + if config and macaddr then uci:section('network', 'interface', name, { proto = 'batadv', @@ -91,12 +89,6 @@ local function configure_mesh(config, radio, index, suffix, disabled) } ) - if index == 0 then - macaddr = util.generate_mac(1) - elseif index == 1 then - macaddr = util.generate_mac(4) - end - uci:section('wireless', 'wifi-iface', name, { device = radio,