Skip to content

Commit

Permalink
bridge: notify applications if address of bridge device changes
Browse files Browse the repository at this point in the history
The mac address of the bridge device may be changed when a new interface
is added to the bridge. If this happens, then the bridge needs to call
the network notifiers to tickle any other systems that care. Since bridge
can be a module, this also means exporting the notifier function.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
stephen hemminger authored and davem330 committed Mar 28, 2011
1 parent 8628bd8 commit edf947f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion net/bridge/br_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
{
struct net_bridge_port *p;
int err = 0;
bool changed_addr;

/* Don't allow bridging non-ethernet like devices */
if ((dev->flags & IFF_LOOPBACK) ||
Expand Down Expand Up @@ -446,7 +447,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
list_add_rcu(&p->list, &br->port_list);

spin_lock_bh(&br->lock);
br_stp_recalculate_bridge_id(br);
changed_addr = br_stp_recalculate_bridge_id(br);
br_features_recompute(br);

if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) &&
Expand All @@ -456,6 +457,9 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)

br_ifinfo_notify(RTM_NEWLINK, p);

if (changed_addr)
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);

dev_set_mtu(br->dev, br_min_mtu(br));

kobject_uevent(&p->kobj, KOBJ_ADD);
Expand Down
2 changes: 1 addition & 1 deletion net/bridge/br_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ extern void br_stp_disable_bridge(struct net_bridge *br);
extern void br_stp_set_enabled(struct net_bridge *br, unsigned long val);
extern void br_stp_enable_port(struct net_bridge_port *p);
extern void br_stp_disable_port(struct net_bridge_port *p);
extern void br_stp_recalculate_bridge_id(struct net_bridge *br);
extern bool br_stp_recalculate_bridge_id(struct net_bridge *br);
extern void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *a);
extern void br_stp_set_bridge_priority(struct net_bridge *br,
u16 newprio);
Expand Down
9 changes: 6 additions & 3 deletions net/bridge/br_stp_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr)
static const unsigned short br_mac_zero_aligned[ETH_ALEN >> 1];

/* called under bridge lock */
void br_stp_recalculate_bridge_id(struct net_bridge *br)
bool br_stp_recalculate_bridge_id(struct net_bridge *br)
{
const unsigned char *br_mac_zero =
(const unsigned char *)br_mac_zero_aligned;
Expand All @@ -222,8 +222,11 @@ void br_stp_recalculate_bridge_id(struct net_bridge *br)

}

if (compare_ether_addr(br->bridge_id.addr, addr))
br_stp_change_bridge_id(br, addr);
if (compare_ether_addr(br->bridge_id.addr, addr) == 0)
return false; /* no change */

br_stp_change_bridge_id(br, addr);
return true;
}

/* called under bridge lock */
Expand Down
1 change: 1 addition & 0 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@ int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
ASSERT_RTNL();
return raw_notifier_call_chain(&netdev_chain, val, dev);
}
EXPORT_SYMBOL(call_netdevice_notifiers);

/* When > 0 there are consumers of rx skb time stamps */
static atomic_t netstamp_needed = ATOMIC_INIT(0);
Expand Down

0 comments on commit edf947f

Please sign in to comment.