mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 01:09:38 -05:00
net: bridge: Add support for calling FDB external learning under rcu
This is done as a preparation to moving the switchdev notifier chain to be atomic. The FDB external learning should be called under rtnl or rcu. Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3922285d96
commit
0baa10fff2
3 changed files with 8 additions and 4 deletions
|
@ -121,7 +121,7 @@ static struct notifier_block br_device_notifier = {
|
||||||
.notifier_call = br_device_event
|
.notifier_call = br_device_event
|
||||||
};
|
};
|
||||||
|
|
||||||
/* called with RTNL */
|
/* called with RTNL or RCU */
|
||||||
static int br_switchdev_event(struct notifier_block *unused,
|
static int br_switchdev_event(struct notifier_block *unused,
|
||||||
unsigned long event, void *ptr)
|
unsigned long event, void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ static int br_switchdev_event(struct notifier_block *unused,
|
||||||
struct switchdev_notifier_fdb_info *fdb_info;
|
struct switchdev_notifier_fdb_info *fdb_info;
|
||||||
int err = NOTIFY_DONE;
|
int err = NOTIFY_DONE;
|
||||||
|
|
||||||
p = br_port_get_rtnl(dev);
|
p = br_port_get_rtnl_rcu(dev);
|
||||||
if (!p)
|
if (!p)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
|
@ -1075,7 +1075,6 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
|
||||||
struct net_bridge_fdb_entry *fdb;
|
struct net_bridge_fdb_entry *fdb;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
ASSERT_RTNL();
|
|
||||||
spin_lock_bh(&br->hash_lock);
|
spin_lock_bh(&br->hash_lock);
|
||||||
|
|
||||||
head = &br->hash[br_mac_hash(addr, vid)];
|
head = &br->hash[br_mac_hash(addr, vid)];
|
||||||
|
@ -1110,7 +1109,6 @@ int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p,
|
||||||
struct net_bridge_fdb_entry *fdb;
|
struct net_bridge_fdb_entry *fdb;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
ASSERT_RTNL();
|
|
||||||
spin_lock_bh(&br->hash_lock);
|
spin_lock_bh(&br->hash_lock);
|
||||||
|
|
||||||
fdb = br_fdb_find(br, addr, vid);
|
fdb = br_fdb_find(br, addr, vid);
|
||||||
|
|
|
@ -284,6 +284,12 @@ static inline struct net_bridge_port *br_port_get_rtnl(const struct net_device *
|
||||||
rtnl_dereference(dev->rx_handler_data) : NULL;
|
rtnl_dereference(dev->rx_handler_data) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct net_bridge_port *br_port_get_rtnl_rcu(const struct net_device *dev)
|
||||||
|
{
|
||||||
|
return br_port_exists(dev) ?
|
||||||
|
rcu_dereference_rtnl(dev->rx_handler_data) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct net_bridge {
|
struct net_bridge {
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
spinlock_t hash_lock;
|
spinlock_t hash_lock;
|
||||||
|
|
Loading…
Add table
Reference in a new issue