Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Network event notifiers
0004  *
0005  *  Authors:
0006  *      Tom Tucker             <tom@opengridcomputing.com>
0007  *      Steve Wise             <swise@opengridcomputing.com>
0008  *
0009  *  Fixes:
0010  */
0011 
0012 #include <linux/rtnetlink.h>
0013 #include <linux/notifier.h>
0014 #include <linux/export.h>
0015 #include <net/netevent.h>
0016 
0017 static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
0018 
0019 /**
0020  *  register_netevent_notifier - register a netevent notifier block
0021  *  @nb: notifier
0022  *
0023  *  Register a notifier to be called when a netevent occurs.
0024  *  The notifier passed is linked into the kernel structures and must
0025  *  not be reused until it has been unregistered. A negative errno code
0026  *  is returned on a failure.
0027  */
0028 int register_netevent_notifier(struct notifier_block *nb)
0029 {
0030     return atomic_notifier_chain_register(&netevent_notif_chain, nb);
0031 }
0032 EXPORT_SYMBOL_GPL(register_netevent_notifier);
0033 
0034 /**
0035  *  unregister_netevent_notifier - unregister a netevent notifier block
0036  *  @nb: notifier
0037  *
0038  *  Unregister a notifier previously registered by
0039  *  register_neigh_notifier(). The notifier is unlinked into the
0040  *  kernel structures and may then be reused. A negative errno code
0041  *  is returned on a failure.
0042  */
0043 
0044 int unregister_netevent_notifier(struct notifier_block *nb)
0045 {
0046     return atomic_notifier_chain_unregister(&netevent_notif_chain, nb);
0047 }
0048 EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
0049 
0050 /**
0051  *  call_netevent_notifiers - call all netevent notifier blocks
0052  *      @val: value passed unmodified to notifier function
0053  *      @v:   pointer passed unmodified to notifier function
0054  *
0055  *  Call all neighbour notifier blocks.  Parameters and return value
0056  *  are as for notifier_call_chain().
0057  */
0058 
0059 int call_netevent_notifiers(unsigned long val, void *v)
0060 {
0061     return atomic_notifier_call_chain(&netevent_notif_chain, val, v);
0062 }
0063 EXPORT_SYMBOL_GPL(call_netevent_notifiers);