diff options
author | stephen hemminger <shemminger@vyatta.com> | 2011-12-08 02:17:49 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-08 19:40:28 -0500 |
commit | 43598813386f6205edf3c21f1fe97f731ccb4f15 (patch) | |
tree | e08befb899b76681fac2af8acb13150b0b74d44f /net/bridge | |
parent | 31e8a49c161b00c648e960903512c9cbaee777b1 (diff) |
bridge: add local MAC address to forwarding table (v2)
If user has configured a MAC address that is not one of the existing
ports of the bridge, then we need to add a special entry in the forwarding
table. This forwarding table entry has no outgoing port so it has to be
treated a little differently. The special entry is reported by the netlink
interface with ifindex of bridge, but ignored by the old interface since there
is no usable way to put it in the ABI.
Reported-by: Koki Sanagi <sanagi.koki@jp.fujitsu.com>
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge')
-rw-r--r-- | net/bridge/br_device.c | 7 | ||||
-rw-r--r-- | net/bridge/br_fdb.c | 20 | ||||
-rw-r--r-- | net/bridge/br_forward.c | 2 | ||||
-rw-r--r-- | net/bridge/br_private.h | 1 |
4 files changed, 25 insertions, 5 deletions
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index a3754ac262c3..71773b014e0c 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
@@ -170,8 +170,11 @@ static int br_set_mac_address(struct net_device *dev, void *p) | |||
170 | return -EINVAL; | 170 | return -EINVAL; |
171 | 171 | ||
172 | spin_lock_bh(&br->lock); | 172 | spin_lock_bh(&br->lock); |
173 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); | 173 | if (compare_ether_addr(dev->dev_addr, addr->sa_data)) { |
174 | br_stp_change_bridge_id(br, addr->sa_data); | 174 | memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); |
175 | br_fdb_change_mac_address(br, addr->sa_data); | ||
176 | br_stp_change_bridge_id(br, addr->sa_data); | ||
177 | } | ||
175 | br->flags |= BR_SET_MAC_ADDR; | 178 | br->flags |= BR_SET_MAC_ADDR; |
176 | spin_unlock_bh(&br->lock); | 179 | spin_unlock_bh(&br->lock); |
177 | 180 | ||
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index b6ae60b08d46..a1429afca443 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c | |||
@@ -127,6 +127,18 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr) | |||
127 | spin_unlock_bh(&br->hash_lock); | 127 | spin_unlock_bh(&br->hash_lock); |
128 | } | 128 | } |
129 | 129 | ||
130 | void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr) | ||
131 | { | ||
132 | struct net_bridge_fdb_entry *f; | ||
133 | |||
134 | /* If old entry was unassociated with any port, then delete it. */ | ||
135 | f = __br_fdb_get(br, br->dev->dev_addr); | ||
136 | if (f && f->is_local && !f->dst) | ||
137 | fdb_delete(br, f); | ||
138 | |||
139 | fdb_insert(br, NULL, newaddr); | ||
140 | } | ||
141 | |||
130 | void br_fdb_cleanup(unsigned long _data) | 142 | void br_fdb_cleanup(unsigned long _data) |
131 | { | 143 | { |
132 | struct net_bridge *br = (struct net_bridge *)_data; | 144 | struct net_bridge *br = (struct net_bridge *)_data; |
@@ -250,7 +262,7 @@ int br_fdb_test_addr(struct net_device *dev, unsigned char *addr) | |||
250 | ret = 0; | 262 | ret = 0; |
251 | else { | 263 | else { |
252 | fdb = __br_fdb_get(port->br, addr); | 264 | fdb = __br_fdb_get(port->br, addr); |
253 | ret = fdb && fdb->dst->dev != dev && | 265 | ret = fdb && fdb->dst && fdb->dst->dev != dev && |
254 | fdb->dst->state == BR_STATE_FORWARDING; | 266 | fdb->dst->state == BR_STATE_FORWARDING; |
255 | } | 267 | } |
256 | rcu_read_unlock(); | 268 | rcu_read_unlock(); |
@@ -282,6 +294,10 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf, | |||
282 | if (has_expired(br, f)) | 294 | if (has_expired(br, f)) |
283 | continue; | 295 | continue; |
284 | 296 | ||
297 | /* ignore pseudo entry for local MAC address */ | ||
298 | if (!f->dst) | ||
299 | continue; | ||
300 | |||
285 | if (skip) { | 301 | if (skip) { |
286 | --skip; | 302 | --skip; |
287 | continue; | 303 | continue; |
@@ -468,7 +484,7 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br, | |||
468 | ndm->ndm_pad2 = 0; | 484 | ndm->ndm_pad2 = 0; |
469 | ndm->ndm_flags = 0; | 485 | ndm->ndm_flags = 0; |
470 | ndm->ndm_type = 0; | 486 | ndm->ndm_type = 0; |
471 | ndm->ndm_ifindex = fdb->dst->dev->ifindex; | 487 | ndm->ndm_ifindex = fdb->dst ? fdb->dst->dev->ifindex : br->dev->ifindex; |
472 | ndm->ndm_state = fdb_to_nud(fdb); | 488 | ndm->ndm_state = fdb_to_nud(fdb); |
473 | 489 | ||
474 | NLA_PUT(skb, NDA_LLADDR, ETH_ALEN, &fdb->addr); | 490 | NLA_PUT(skb, NDA_LLADDR, ETH_ALEN, &fdb->addr); |
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index ee64287f1290..61f65344e711 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c | |||
@@ -98,7 +98,7 @@ static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb) | |||
98 | /* called with rcu_read_lock */ | 98 | /* called with rcu_read_lock */ |
99 | void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) | 99 | void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) |
100 | { | 100 | { |
101 | if (should_deliver(to, skb)) { | 101 | if (to && should_deliver(to, skb)) { |
102 | __br_deliver(to, skb); | 102 | __br_deliver(to, skb); |
103 | return; | 103 | return; |
104 | } | 104 | } |
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 4027029aa5e4..89969080c384 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -348,6 +348,7 @@ extern void br_fdb_fini(void); | |||
348 | extern void br_fdb_flush(struct net_bridge *br); | 348 | extern void br_fdb_flush(struct net_bridge *br); |
349 | extern void br_fdb_changeaddr(struct net_bridge_port *p, | 349 | extern void br_fdb_changeaddr(struct net_bridge_port *p, |
350 | const unsigned char *newaddr); | 350 | const unsigned char *newaddr); |
351 | extern void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr); | ||
351 | extern void br_fdb_cleanup(unsigned long arg); | 352 | extern void br_fdb_cleanup(unsigned long arg); |
352 | extern void br_fdb_delete_by_port(struct net_bridge *br, | 353 | extern void br_fdb_delete_by_port(struct net_bridge *br, |
353 | const struct net_bridge_port *p, int do_all); | 354 | const struct net_bridge_port *p, int do_all); |