netevent.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
  18. /**
  19. * register_netevent_notifier - register a netevent notifier block
  20. * @nb: notifier
  21. *
  22. * Register a notifier to be called when a netevent occurs.
  23. * The notifier passed is linked into the kernel structures and must
  24. * not be reused until it has been unregistered. A negative errno code
  25. * is returned on a failure.
  26. */
  27. int register_netevent_notifier(struct notifier_block *nb)
  28. {
  29. int err;
  30. err = atomic_notifier_chain_register(&netevent_notif_chain, nb);
  31. return err;
  32. }
  33. /**
  34. * netevent_unregister_notifier - unregister a netevent notifier block
  35. * @nb: notifier
  36. *
  37. * Unregister a notifier previously registered by
  38. * register_neigh_notifier(). The notifier is unlinked into the
  39. * kernel structures and may then be reused. A negative errno code
  40. * is returned on a failure.
  41. */
  42. int unregister_netevent_notifier(struct notifier_block *nb)
  43. {
  44. return atomic_notifier_chain_unregister(&netevent_notif_chain, nb);
  45. }
  46. /**
  47. * call_netevent_notifiers - call all netevent notifier blocks
  48. * @val: value passed unmodified to notifier function
  49. * @v: pointer passed unmodified to notifier function
  50. *
  51. * Call all neighbour notifier blocks. Parameters and return value
  52. * are as for notifier_call_chain().
  53. */
  54. int call_netevent_notifiers(unsigned long val, void *v)
  55. {
  56. return atomic_notifier_call_chain(&netevent_notif_chain, val, v);
  57. }
  58. EXPORT_SYMBOL_GPL(register_netevent_notifier);
  59. EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
  60. EXPORT_SYMBOL_GPL(call_netevent_notifiers);