base-files: set MAC for bridge ports (devices) instead of bridge itself
authorRafał Miłecki <rafal@milecki.pl>
Mon, 14 Jun 2021 18:18:14 +0000 (20:18 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Tue, 22 Jun 2021 06:10:05 +0000 (08:10 +0200)
This restores the original config_generate behaviour. With MAC set for
bridged devices the bridge automatically gets its MAC adjusted (it picks
the lowest MAC of bridged devices).

This fixes confusing interfaces setup (bridge ports not having custom
MAC assigned).

Reported-by: Koen Vandeputte <koen.vandeputte@citymesh.com>
Fixes: c2139eef279e ("base-files: simplify setting device MAC")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit c8d8eb9d13fc6fc8b394a620c27995ee71d29c4d)

package/base-files/files/bin/config_generate

index 0dca5549e8a91749217d959b543a16f1258b0af0..b3752c5430870ecb540b033ea1b8a1eb15c0f87f 100755 (executable)
@@ -114,9 +114,17 @@ generate_network() {
                        add network device
                        set network.@device[-1].name='br-$1'
                        set network.@device[-1].type='bridge'
-                       set network.@device[-1].macaddr='$macaddr'
                EOF
                for port in $ports; do uci add_list network.@device[-1].ports="$port"; done
+               [ -n "macaddr" ] && {
+                       for port in $ports; do
+                               uci -q batch <<-EOF
+                                       add network device
+                                       set network.@device[-1].name='$port'
+                                       set network.@device[-1].macaddr='$macaddr'
+                               EOF
+                       done
+               }
                device=br-$1
                type=
                macaddr=""