[2/2] fff-network: Replace ETH0MAC by replacement based on ROUTERMAC

Submitted by Adrian Schmutzler on Dec. 22, 2017, 5:03 p.m.

Details

Message ID 1513962185-3621-2-git-send-email-freifunk@adrianschmutzler.de
State Superseded
Headers show

Commit Message

Adrian Schmutzler Dec. 22, 2017, 5:03 p.m.
All ONE_PORT devices except mr3020 use phy0 (w2mesh) for the
ROUTERMAC. Thus, instead of evaluating w2ap's MAC address,
we can just use the flipped ROUTERMAC for ETH0MAC.

This should also work for the mr3020, which uses eth0.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

---

This replaces the patches
- fff-network: Evaluate ETH0MAC based on ROUTERMAC
- fff-network: Move ETH0MAC to network.*

In contrast to the former, we now use the newly introduced
function and can start the MAC replacement immediately (without
the ETH0MAC being set).
---
 .../fff/fff-network/files/usr/sbin/configurenetwork        | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
index 7f34d6f..272da13 100755
--- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
+++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
@@ -150,7 +150,7 @@  if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [ "$FO
         uci set network.mesh.ifname="bat0"
         uci set network.wan.ifname="eth1" #eth1 because it is default in config file
         uci set network.ethmesh.ifname="$SWITCHDEV"
-        ETH0MAC="w2ap"
+        fixMac "$(macFlipLocalBit "$ROUTERMAC")" "eth0" "eth0" "1"
     fi
     uci commit network
 fi
@@ -165,18 +165,6 @@  if [ -n "$ROUTERMAC" ]; then
     fixMac "$ROUTERMAC" "br-mesh" "mesh"
 fi
 
-if [[ -n "$ETH0MAC" ]]; then
-        echo "Fixing MAC on eth0"
-        sleep 10
-        NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
-        uci set network.eth0.macaddr=$NEW_MACADDR
-        uci commit network
-        ifconfig eth0 down
-        ifconfig eth0 hw ether $NEW_MACADDR
-        ifconfig eth0 up
-        /etc/init.d/network restart
-fi
-
 if uci get network.mesh.ip6addr
 then
     echo "IPv6 for mesh is set already"

Comments

Adrian Schmutzler Dec. 27, 2017, 1:15 p.m.
Getestet auf WR841 und AC-Mesh.

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>


> -----Original Message-----
> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
> Of Adrian Schmutzler
> Sent: Freitag, 22. Dezember 2017 18:03
> To: franken-dev@freifunk.net
> Subject: [PATCH 2/2] fff-network: Replace ETH0MAC by replacement based
> on ROUTERMAC
> 
> All ONE_PORT devices except mr3020 use phy0 (w2mesh) for the
> ROUTERMAC. Thus, instead of evaluating w2ap's MAC address, we can just
> use the flipped ROUTERMAC for ETH0MAC.
> 
> This should also work for the mr3020, which uses eth0.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> ---
> 
> This replaces the patches
> - fff-network: Evaluate ETH0MAC based on ROUTERMAC
> - fff-network: Move ETH0MAC to network.*
> 
> In contrast to the former, we now use the newly introduced function and
can
> start the MAC replacement immediately (without the ETH0MAC being set).
> ---
>  .../fff/fff-network/files/usr/sbin/configurenetwork        | 14
+-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> index 7f34d6f..272da13 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -150,7 +150,7 @@ if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get
> network.$SWITCHDEV.ifname || [ "$FO
>          uci set network.mesh.ifname="bat0"
>          uci set network.wan.ifname="eth1" #eth1 because it is default in
config
> file
>          uci set network.ethmesh.ifname="$SWITCHDEV"
> -        ETH0MAC="w2ap"
> +        fixMac "$(macFlipLocalBit "$ROUTERMAC")" "eth0" "eth0" "1"
>      fi
>      uci commit network
>  fi
> @@ -165,18 +165,6 @@ if [ -n "$ROUTERMAC" ]; then
>      fixMac "$ROUTERMAC" "br-mesh" "mesh"
>  fi
> 
> -if [[ -n "$ETH0MAC" ]]; then
> -        echo "Fixing MAC on eth0"
> -        sleep 10
> -        NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
> -        uci set network.eth0.macaddr=$NEW_MACADDR
> -        uci commit network
> -        ifconfig eth0 down
> -        ifconfig eth0 hw ether $NEW_MACADDR
> -        ifconfig eth0 up
> -        /etc/init.d/network restart
> -fi
> -
>  if uci get network.mesh.ip6addr
>  then
>      echo "IPv6 for mesh is set already"
> --
> 2.7.4
> 
> --
> franken-dev mailing list
> franken-dev@freifunk.net
> http://lists.freifunk.net/mailman/listinfo/franken-dev-freifunk.net
Tim Niemeyer Dec. 31, 2017, 3:07 p.m.
Hi Adrian

Am Freitag, den 22.12.2017, 18:03 +0100 schrieb Adrian Schmutzler:
> All ONE_PORT devices except mr3020 use phy0 (w2mesh) for the
> ROUTERMAC. Thus, instead of evaluating w2ap's MAC address,
> we can just use the flipped ROUTERMAC for ETH0MAC.
> 
> This should also work for the mr3020, which uses eth0.
> 
> Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
> 
> ---
> 
> This replaces the patches
> - fff-network: Evaluate ETH0MAC based on ROUTERMAC
> - fff-network: Move ETH0MAC to network.*
> 
> In contrast to the former, we now use the newly introduced
> function and can start the MAC replacement immediately (without
> the ETH0MAC being set).
> ---
>  .../fff/fff-network/files/usr/sbin/configurenetwork        | 14 +---
> ----------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork
> index 7f34d6f..272da13 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -150,7 +150,7 @@ if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get
> network.$SWITCHDEV.ifname || [ "$FO
>          uci set network.mesh.ifname="bat0"
>          uci set network.wan.ifname="eth1" #eth1 because it is
> default in config file
>          uci set network.ethmesh.ifname="$SWITCHDEV"
> -        ETH0MAC="w2ap"
> +        fixMac "$(macFlipLocalBit "$ROUTERMAC")" "eth0" "eth0" "1"
Wenn ich das richtig verstanden habe ist da ein kleiner Fehler drin. Es
soll beim interface (also das UCI Ding) nicht eth0 sondern ethmesh
sein.

Hier brauch man entsprechend meiner Anmerkung aus 1/2 nur noch:
----
if [ -z "$ETHMESHMAC" ]; then
    ETHMESHMAC="$(macFlipLocalBit "$ROUTERMAC")"
fi
----
machen.

>      fi
>      uci commit network
>  fi
> @@ -165,18 +165,6 @@ if [ -n "$ROUTERMAC" ]; then
>      fixMac "$ROUTERMAC" "br-mesh" "mesh"
>  fi
>  
> -if [[ -n "$ETH0MAC" ]]; then
> -        echo "Fixing MAC on eth0"
> -        sleep 10
> -        NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
> -        uci set network.eth0.macaddr=$NEW_MACADDR
Ich weiß, hier hast du das her, aber ich glaube das ist auch falsch,
denn zuvor wurde ja extra das network.ethmesh.ifname gesetzt.

> -        uci commit network
> -        ifconfig eth0 down
> -        ifconfig eth0 hw ether $NEW_MACADDR
> -        ifconfig eth0 up
> -        /etc/init.d/network restart
> -fi
> -
>  if uci get network.mesh.ip6addr
>  then
>      echo "IPv6 for mesh is set already"
> -- 
> 2.7.4
>