aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>2014-02-07 02:48:24 -0500
committerDavid S. Miller <davem@davemloft.net>2014-02-10 17:34:34 -0500
commita778e6d1a51faaafa6a3a3cef9bee11c3bd47f9f (patch)
tree9506ceeb6f8a4cdd7ad18b507d6130d240cb8471 /net
parent960b589f86c74ce582922fcb996103271081f4de (diff)
bridge: Properly check if local fdb entry can be deleted in br_fdb_delete_by_port
br_fdb_delete_by_port() doesn't care about vlan and mac address of the bridge device. As the check is almost the same as mac address changing, slightly modify fdb_delete_local() and use it. Note that we can always set added_by_user to 0 in fdb_delete_local() because - br_fdb_delete_by_port() calls fdb_delete_local() for local entries regardless of its added_by_user. In this case, we have to check if another port has the same address and vlan, and if found, we have to create the entry (by changing dst). This is kernel-added entry, not user-added. - br_fdb_changeaddr() doesn't call fdb_delete_local() for user-added entry. Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Acked-by: Vlad Yasevich <vyasevic@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/bridge/br_fdb.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 15bf13d0b543..43e54d1ae956 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -103,6 +103,7 @@ static void fdb_delete_local(struct net_bridge *br,
103 if (op != p && ether_addr_equal(op->dev->dev_addr, addr) && 103 if (op != p && ether_addr_equal(op->dev->dev_addr, addr) &&
104 (!vid || nbp_vlan_find(op, vid))) { 104 (!vid || nbp_vlan_find(op, vid))) {
105 f->dst = op; 105 f->dst = op;
106 f->added_by_user = 0;
106 return; 107 return;
107 } 108 }
108 } 109 }
@@ -111,6 +112,7 @@ static void fdb_delete_local(struct net_bridge *br,
111 if (p && ether_addr_equal(br->dev->dev_addr, addr) && 112 if (p && ether_addr_equal(br->dev->dev_addr, addr) &&
112 (!vid || br_vlan_find(br, vid))) { 113 (!vid || br_vlan_find(br, vid))) {
113 f->dst = NULL; 114 f->dst = NULL;
115 f->added_by_user = 0;
114 return; 116 return;
115 } 117 }
116 118
@@ -261,26 +263,11 @@ void br_fdb_delete_by_port(struct net_bridge *br,
261 263
262 if (f->is_static && !do_all) 264 if (f->is_static && !do_all)
263 continue; 265 continue;
264 /*
265 * if multiple ports all have the same device address
266 * then when one port is deleted, assign
267 * the local entry to other port
268 */
269 if (f->is_local) {
270 struct net_bridge_port *op;
271 list_for_each_entry(op, &br->port_list, list) {
272 if (op != p &&
273 ether_addr_equal(op->dev->dev_addr,
274 f->addr.addr)) {
275 f->dst = op;
276 f->added_by_user = 0;
277 goto skip_delete;
278 }
279 }
280 }
281 266
282 fdb_delete(br, f); 267 if (f->is_local)
283 skip_delete: ; 268 fdb_delete_local(br, p, f);
269 else
270 fdb_delete(br, f);
284 } 271 }
285 } 272 }
286 spin_unlock_bh(&br->hash_lock); 273 spin_unlock_bh(&br->hash_lock);