Skip to content

Commit ff5cf10

Browse files
Arkadi Sharshevskydavem330
authored andcommitted
net: switchdev: Change notifier chain to be atomic
In order to use the switchdev notifier chain for FDB sync with the device it has to be changed to atomic. The is done because the bridge can learn new FDBs in atomic context. Signed-off-by: Arkadi Sharshevsky <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Reviewed-by: Ivan Vecera <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Ivan Vecera <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0baa10f commit ff5cf10

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

net/switchdev/switchdev.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -571,24 +571,17 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj,
571571
}
572572
EXPORT_SYMBOL_GPL(switchdev_port_obj_dump);
573573

574-
static RAW_NOTIFIER_HEAD(switchdev_notif_chain);
574+
static ATOMIC_NOTIFIER_HEAD(switchdev_notif_chain);
575575

576576
/**
577577
* register_switchdev_notifier - Register notifier
578578
* @nb: notifier_block
579579
*
580-
* Register switch device notifier. This should be used by code
581-
* which needs to monitor events happening in particular device.
582-
* Return values are same as for atomic_notifier_chain_register().
580+
* Register switch device notifier.
583581
*/
584582
int register_switchdev_notifier(struct notifier_block *nb)
585583
{
586-
int err;
587-
588-
rtnl_lock();
589-
err = raw_notifier_chain_register(&switchdev_notif_chain, nb);
590-
rtnl_unlock();
591-
return err;
584+
return atomic_notifier_chain_register(&switchdev_notif_chain, nb);
592585
}
593586
EXPORT_SYMBOL_GPL(register_switchdev_notifier);
594587

@@ -597,16 +590,10 @@ EXPORT_SYMBOL_GPL(register_switchdev_notifier);
597590
* @nb: notifier_block
598591
*
599592
* Unregister switch device notifier.
600-
* Return values are same as for atomic_notifier_chain_unregister().
601593
*/
602594
int unregister_switchdev_notifier(struct notifier_block *nb)
603595
{
604-
int err;
605-
606-
rtnl_lock();
607-
err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb);
608-
rtnl_unlock();
609-
return err;
596+
return atomic_notifier_chain_unregister(&switchdev_notif_chain, nb);
610597
}
611598
EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
612599

@@ -616,18 +603,13 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
616603
* @dev: port device
617604
* @info: notifier information data
618605
*
619-
* Call all network notifier blocks. This should be called by driver
620-
* when it needs to propagate hardware event.
621-
* Return values are same as for atomic_notifier_call_chain().
622-
* rtnl_lock must be held.
606+
* Call all network notifier blocks.
623607
*/
624608
int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
625609
struct switchdev_notifier_info *info)
626610
{
627-
ASSERT_RTNL();
628-
629611
info->dev = dev;
630-
return raw_notifier_call_chain(&switchdev_notif_chain, val, info);
612+
return atomic_notifier_call_chain(&switchdev_notif_chain, val, info);
631613
}
632614
EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
633615

0 commit comments

Comments
 (0)