From d638359215f728c85c3ac5f5ee80f1b80ccff4cd Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 19 Jul 2014 18:40:12 +0200 Subject: [PATCH] Explicitly set the WAN MAC address on all models where WAN is a VLAN device Also move it to gluon-mesh-batman-adv, as mesh_on_wan is the only feature that needs a unique MAC address on the WAN interface. --- .../upgrade/core/initial/011-gluon-network | 17 ---------------- .../upgrade/mesh-batman-adv/invariant/010-wan | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100755 package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/010-wan diff --git a/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network b/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network index 851a8dc4..916a55fe 100755 --- a/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network +++ b/package/gluon-core/files/lib/gluon/upgrade/core/initial/011-gluon-network @@ -1,12 +1,7 @@ #!/usr/bin/lua local sysconfig = require 'gluon.sysconfig' -local platform = require 'gluon.platform' - local uci = require('luci.model.uci').cursor() -local util = require 'luci.util' - -local nixio = require 'nixio' uci:delete('network', 'lan') @@ -20,17 +15,5 @@ uci:section('network', 'interface', 'wan', } ) - -if platform.match('ar71xx', 'generic', {'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}) then - -- fix up duplicate mac addresses - local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)') - m1 = nixio.bit.bor(tonumber(m1, 16), 0x02) - m4 = (tonumber(m4, 16)+1) % 0x100 - m6 = (tonumber(m6, 16)+1) % 0x100 - local wanaddr = string.format('%02x:%s:%s:%02x:%s:%02x', m1, m2, m3, m4, m5, m6) - - uci:set('network', 'wan', 'macaddr', wanaddr) -end - uci:save('network') uci:commit('network') diff --git a/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/010-wan b/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/010-wan new file mode 100755 index 00000000..3b6611cc --- /dev/null +++ b/package/gluon-mesh-batman-adv/files/lib/gluon/upgrade/mesh-batman-adv/invariant/010-wan @@ -0,0 +1,20 @@ +#!/usr/bin/lua + +local nixio = require 'nixio' +local sysconfig = require 'gluon.sysconfig' +local uci = require('luci.model.uci').cursor() + + +if sysconfig.wan_ifname:match('%.') and not uci:get('network', 'wan', 'macaddr') then + -- fix up duplicate mac addresses + local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)') + m1 = nixio.bit.bor(tonumber(m1, 16), 0x02) + m4 = (tonumber(m4, 16)+1) % 0x100 + m6 = (tonumber(m6, 16)+1) % 0x100 + local wanaddr = string.format('%02x:%s:%s:%02x:%s:%02x', m1, m2, m3, m4, m5, m6) + + uci:set('network', 'wan', 'macaddr', wanaddr) +end + +uci:save('network') +uci:commit('network')