netevent.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Network event notifiers
  4. *
  5. * Authors:
  6. * Tom Tucker <[email protected]>
  7. * Steve Wise <[email protected]>
  8. *
  9. * Fixes:
  10. */
  11. #include <linux/rtnetlink.h>
  12. #include <linux/notifier.h>
  13. #include <linux/export.h>
  14. #include <net/netevent.h>
  15. static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
  16. /**
  17. * register_netevent_notifier - register a netevent notifier block
  18. * @nb: notifier
  19. *
  20. * Register a notifier to be called when a netevent occurs.
  21. * The notifier passed is linked into the kernel structures and must
  22. * not be reused until it has been unregistered. A negative errno code
  23. * is returned on a failure.
  24. */
  25. int register_netevent_notifier(struct notifier_block *nb)
  26. {
  27. return atomic_notifier_chain_register(&netevent_notif_chain, nb);
  28. }
  29. EXPORT_SYMBOL_GPL(register_netevent_notifier);
  30. /**
  31. * unregister_netevent_notifier - unregister a netevent notifier block
  32. * @nb: notifier
  33. *
  34. * Unregister a notifier previously registered by
  35. * register_neigh_notifier(). The notifier is unlinked into the
  36. * kernel structures and may then be reused. A negative errno code
  37. * is returned on a failure.
  38. */
  39. int unregister_netevent_notifier(struct notifier_block *nb)
  40. {
  41. return atomic_notifier_chain_unregister(&netevent_notif_chain, nb);
  42. }
  43. EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
  44. /**
  45. * call_netevent_notifiers - call all netevent notifier blocks
  46. * @val: value passed unmodified to notifier function
  47. * @v: pointer passed unmodified to notifier function
  48. *
  49. * Call all neighbour notifier blocks. Parameters and return value
  50. * are as for notifier_call_chain().
  51. */
  52. int call_netevent_notifiers(unsigned long val, void *v)
  53. {
  54. return atomic_notifier_call_chain(&netevent_notif_chain, val, v);
  55. }
  56. EXPORT_SYMBOL_GPL(call_netevent_notifiers);