blob: f17ccd291d3902a94ebd31653959851203402468 [file] [log] [blame]
Tom Tucker792d1932006-07-30 20:43:26 -07001/*
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
16#include <linux/rtnetlink.h>
17#include <linux/notifier.h>
Paul Gortmakerbc3b2d72011-07-15 11:47:34 -040018#include <linux/export.h>
Adrian Bunk94b83412007-07-05 17:06:21 -070019#include <net/netevent.h>
Tom Tucker792d1932006-07-30 20:43:26 -070020
21static ATOMIC_NOTIFIER_HEAD(netevent_notif_chain);
22
23/**
24 * register_netevent_notifier - register a netevent notifier block
25 * @nb: notifier
26 *
27 * Register a notifier to be called when a netevent occurs.
28 * The notifier passed is linked into the kernel structures and must
29 * not be reused until it has been unregistered. A negative errno code
30 * is returned on a failure.
31 */
32int register_netevent_notifier(struct notifier_block *nb)
33{
34 int err;
35
36 err = atomic_notifier_chain_register(&netevent_notif_chain, nb);
37 return err;
38}
Eric Dumazet9e34a5b2010-07-09 21:22:04 +000039EXPORT_SYMBOL_GPL(register_netevent_notifier);
Tom Tucker792d1932006-07-30 20:43:26 -070040
41/**
42 * netevent_unregister_notifier - unregister a netevent notifier block
43 * @nb: notifier
44 *
45 * Unregister a notifier previously registered by
46 * register_neigh_notifier(). The notifier is unlinked into the
47 * kernel structures and may then be reused. A negative errno code
48 * is returned on a failure.
49 */
50
51int unregister_netevent_notifier(struct notifier_block *nb)
52{
53 return atomic_notifier_chain_unregister(&netevent_notif_chain, nb);
54}
Eric Dumazet9e34a5b2010-07-09 21:22:04 +000055EXPORT_SYMBOL_GPL(unregister_netevent_notifier);
Tom Tucker792d1932006-07-30 20:43:26 -070056
57/**
58 * call_netevent_notifiers - call all netevent notifier blocks
59 * @val: value passed unmodified to notifier function
60 * @v: pointer passed unmodified to notifier function
61 *
62 * Call all neighbour notifier blocks. Parameters and return value
63 * are as for notifier_call_chain().
64 */
65
66int call_netevent_notifiers(unsigned long val, void *v)
67{
68 return atomic_notifier_call_chain(&netevent_notif_chain, val, v);
69}
Tom Tucker792d1932006-07-30 20:43:26 -070070EXPORT_SYMBOL_GPL(call_netevent_notifiers);