From: Stephen Hemminger Date: Tue, 17 Jun 2008 23:10:06 +0000 (-0700) Subject: bridge: make bridge address settings sticky X-Git-Tag: v2.6.27-rc1~969^2~301 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92c0574f11598c8036f81e27d2e8bdd6eed7d76d;p=linux-2.6 bridge: make bridge address settings sticky Normally, the bridge just chooses the smallest mac address as the bridge id and mac address of bridge device. But if the administrator has explictly set the interface address then don't change it. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index a6ffc6c2a6..d9449df7ca 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -87,6 +87,7 @@ static int br_set_mac_address(struct net_device *dev, void *p) spin_lock_bh(&br->lock); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); br_stp_change_bridge_id(br, addr->sa_data); + br->flags |= BR_SET_MAC_ADDR; spin_unlock_bh(&br->lock); return 0; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 83ff5861c2..8593c9f6a3 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -92,6 +92,8 @@ struct net_bridge struct hlist_head hash[BR_HASH_SIZE]; struct list_head age_list; unsigned long feature_mask; + unsigned long flags; +#define BR_SET_MAC_ADDR 0x00000001 /* STP */ bridge_id designated_root; diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c index 1a4e5c37a0..9a52ac5b45 100644 --- a/net/bridge/br_stp_if.c +++ b/net/bridge/br_stp_if.c @@ -214,6 +214,10 @@ void br_stp_recalculate_bridge_id(struct net_bridge *br) const unsigned char *addr = br_mac_zero; struct net_bridge_port *p; + /* user has chosen a value so keep it */ + if (br->flags & BR_SET_MAC_ADDR) + return; + list_for_each_entry(p, &br->port_list, list) { if (addr == br_mac_zero || memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)