Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a778e6d1 authored by Toshiaki Makita's avatar Toshiaki Makita Committed by David S. Miller
Browse files

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: default avatarToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Acked-by: default avatarVlad Yasevich <vyasevic@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 960b589f
Loading
Loading
Loading
Loading
+6 −19
Original line number Original line Diff line number Diff line
@@ -103,6 +103,7 @@ static void fdb_delete_local(struct net_bridge *br,
		if (op != p && ether_addr_equal(op->dev->dev_addr, addr) &&
		if (op != p && ether_addr_equal(op->dev->dev_addr, addr) &&
		    (!vid || nbp_vlan_find(op, vid))) {
		    (!vid || nbp_vlan_find(op, vid))) {
			f->dst = op;
			f->dst = op;
			f->added_by_user = 0;
			return;
			return;
		}
		}
	}
	}
@@ -111,6 +112,7 @@ static void fdb_delete_local(struct net_bridge *br,
	if (p && ether_addr_equal(br->dev->dev_addr, addr) &&
	if (p && ether_addr_equal(br->dev->dev_addr, addr) &&
	    (!vid || br_vlan_find(br, vid))) {
	    (!vid || br_vlan_find(br, vid))) {
		f->dst = NULL;
		f->dst = NULL;
		f->added_by_user = 0;
		return;
		return;
	}
	}


@@ -261,26 +263,11 @@ void br_fdb_delete_by_port(struct net_bridge *br,


			if (f->is_static && !do_all)
			if (f->is_static && !do_all)
				continue;
				continue;
			/*
			 * if multiple ports all have the same device address
			 * then when one port is deleted, assign
			 * the local entry to other port
			 */
			if (f->is_local) {
				struct net_bridge_port *op;
				list_for_each_entry(op, &br->port_list, list) {
					if (op != p &&
					    ether_addr_equal(op->dev->dev_addr,
							     f->addr.addr)) {
						f->dst = op;
						f->added_by_user = 0;
						goto skip_delete;
					}
				}
			}


			if (f->is_local)
				fdb_delete_local(br, p, f);
			else
				fdb_delete(br, f);
				fdb_delete(br, f);
		skip_delete: ;
		}
		}
	}
	}
	spin_unlock_bh(&br->hash_lock);
	spin_unlock_bh(&br->hash_lock);