netevent.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Network event notifiers
  3. *
  4. * Authors:
  5. * Tom Tucker <tom@opengridcomputing.com>
  6. * Steve Wise <swise@opengridcomputing.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. *
  13. * Fixes:
  14. */
  15. #include <linux/rtnetlink.h>
  16. #include <linux/notifier.h>
  17. #include <net/netevent.h>
  18. static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
  19. /**
  20. * register_netevent_notifier - register a netevent notifier block
  21. * @nb: notifier
  22. *
  23. * Register a notifier to be called when a netevent occurs.
  24. * The notifier passed is linked into the kernel structures and must
  25. * not be reused until it has been unregistered. A negative errno code
  26. * is returned on a failure.
  27. */
  28. int register_netevent_notifier(struct notifier_block *nb)
  29. {
  30. int err;
  31. err = atomic_notifier_chain_register(&netevent_notif_chain, nb);
  32. return err;
  33. }
  34. EXPORT_SYMBOL_GPL(register_netevent_notifier);
  35. /**
  36. * netevent_unregister_notifier - unregister a netevent notifier block
  37. * @nb: notifier
  38. *
  39. * Unregister a notifier previously registered by
  40. * register_neigh_notifier(). The notifier is unlinked into the
  41. * kernel structures and may then be reused. A negative errno code
  42. * is returned on a failure.
  43. */
  44. int unregister_netevent_notifier(struct notifier_block *nb)
  45. {
  46. return atomic_notifier_chain_unregister(&netevent_notif_chain, nb);
  47. }
  48. EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
  49. /**
  50. * call_netevent_notifiers - call all netevent notifier blocks
  51. * @val: value passed unmodified to notifier function
  52. * @v: pointer passed unmodified to notifier function
  53. *
  54. * Call all neighbour notifier blocks. Parameters and return value
  55. * are as for notifier_call_chain().
  56. */
  57. int call_netevent_notifiers(unsigned long val, void *v)
  58. {
  59. return atomic_notifier_call_chain(&netevent_notif_chain, val, v);
  60. }
  61. EXPORT_SYMBOL_GPL(call_netevent_notifiers);