History

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.

Arkadi Sharshevsky committed 9 years ago

Commit ff5cf101 parent 0baa10f1 file · +6 −24Browse files

Unified · Split

net/switchdev/switchdev.c+6−24
@@ -571,24 +571,17 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj, · 570 unmodified lines
571}571}
572EXPORT_SYMBOL_GPL(switchdev_port_obj_dump);572EXPORT_SYMBOL_GPL(switchdev_port_obj_dump);
573 573
574static RAW_NOTIFIER_HEAD(switchdev_notif_chain);574static ATOMIC_NOTIFIER_HEAD(switchdev_notif_chain);
575 575
576/**576/**
577 * register_switchdev_notifier - Register notifier577 * register_switchdev_notifier - Register notifier
578 * @nb: notifier_block578 * @nb: notifier_block
579 *579 *
580 * Register switch device notifier. This should be used by code580 * Register switch device notifier.
581 * which needs to monitor events happening in particular device.
582 * Return values are same as for atomic_notifier_chain_register().
583 */581 */
584int register_switchdev_notifier(struct notifier_block *nb)582int register_switchdev_notifier(struct notifier_block *nb)
585{583{
586 int err;584 return atomic_notifier_chain_register(&switchdev_notif_chain, nb);
587
588 rtnl_lock();
589 err = raw_notifier_chain_register(&switchdev_notif_chain, nb);
590 rtnl_unlock();
591 return err;
592}585}
593EXPORT_SYMBOL_GPL(register_switchdev_notifier);586EXPORT_SYMBOL_GPL(register_switchdev_notifier);
594 587
@@ -597,16 +590,10 @@ EXPORT_SYMBOL_GPL(register_switchdev_notifier); · 2 unmodified lines
597 * @nb: notifier_block590 * @nb: notifier_block
598 *591 *
599 * Unregister switch device notifier.592 * Unregister switch device notifier.
600 * Return values are same as for atomic_notifier_chain_unregister().
601 */593 */
602int unregister_switchdev_notifier(struct notifier_block *nb)594int unregister_switchdev_notifier(struct notifier_block *nb)
603{595{
604 int err;596 return atomic_notifier_chain_unregister(&switchdev_notif_chain, nb);
605
606 rtnl_lock();
607 err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb);
608 rtnl_unlock();
609 return err;
610}597}
611EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);598EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
612 599
@@ -616,18 +603,13 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier); · 3 unmodified lines
616 * @dev: port device603 * @dev: port device
617 * @info: notifier information data604 * @info: notifier information data
618 *605 *
619 * Call all network notifier blocks. This should be called by driver606 * Call all network notifier blocks.
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.
623 */607 */
624int call_switchdev_notifiers(unsigned long val, struct net_device *dev,608int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
625 struct switchdev_notifier_info *info)609 struct switchdev_notifier_info *info)
626{610{
627 ASSERT_RTNL();
628
629 info->dev = dev;611 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);
631}613}
632EXPORT_SYMBOL_GPL(call_switchdev_notifiers);614EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
633 615