bridge: fix getting the mac address from the first member device
authorFelix Fietkau <nbd@openwrt.org>
Tue, 26 Jun 2012 23:32:07 +0000 (01:32 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 26 Jun 2012 23:32:07 +0000 (01:32 +0200)
bridge.c

index 361b409b8de9167fb340fa625d94c5d981446603..d29c3c0ccc49d061b71a9adb76711e0477e329ee 100644 (file)
--- a/bridge.c
+++ b/bridge.c
@@ -109,11 +109,17 @@ bridge_reset_primary(struct bridge_state *bst)
        bst->primary_port = NULL;
        bst->dev.settings.flags &= ~DEV_OPT_MACADDR;
        vlist_for_each_element(&bst->members, bm, node) {
+               uint8_t *macaddr;
+
                if (!bm->present)
                        continue;
 
                bst->primary_port = bm;
-               memcpy(bst->dev.settings.macaddr, bm->dev.dev->settings.macaddr, 6);
+               if (bm->dev.dev->settings.flags & DEV_OPT_MACADDR)
+                       macaddr = bm->dev.dev->settings.macaddr;
+               else
+                       macaddr = bm->dev.dev->orig_settings.macaddr;
+               memcpy(bst->dev.settings.macaddr, macaddr, 6);
                bst->dev.settings.flags |= DEV_OPT_MACADDR;
                return;
        }