Commit 92c0574f authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

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: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 43aa1920
...@@ -87,6 +87,7 @@ static int br_set_mac_address(struct net_device *dev, void *p) ...@@ -87,6 +87,7 @@ static int br_set_mac_address(struct net_device *dev, void *p)
spin_lock_bh(&br->lock); spin_lock_bh(&br->lock);
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
br_stp_change_bridge_id(br, addr->sa_data); br_stp_change_bridge_id(br, addr->sa_data);
br->flags |= BR_SET_MAC_ADDR;
spin_unlock_bh(&br->lock); spin_unlock_bh(&br->lock);
return 0; return 0;
......
...@@ -92,6 +92,8 @@ struct net_bridge ...@@ -92,6 +92,8 @@ struct net_bridge
struct hlist_head hash[BR_HASH_SIZE]; struct hlist_head hash[BR_HASH_SIZE];
struct list_head age_list; struct list_head age_list;
unsigned long feature_mask; unsigned long feature_mask;
unsigned long flags;
#define BR_SET_MAC_ADDR 0x00000001
/* STP */ /* STP */
bridge_id designated_root; bridge_id designated_root;
......
...@@ -214,6 +214,10 @@ void br_stp_recalculate_bridge_id(struct net_bridge *br) ...@@ -214,6 +214,10 @@ void br_stp_recalculate_bridge_id(struct net_bridge *br)
const unsigned char *addr = br_mac_zero; const unsigned char *addr = br_mac_zero;
struct net_bridge_port *p; 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) { list_for_each_entry(p, &br->port_list, list) {
if (addr == br_mac_zero || if (addr == br_mac_zero ||
memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0) memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment