162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Network event notifiers 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Authors: 662306a36Sopenharmony_ci * Tom Tucker <tom@opengridcomputing.com> 762306a36Sopenharmony_ci * Steve Wise <swise@opengridcomputing.com> 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * Fixes: 1062306a36Sopenharmony_ci */ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/rtnetlink.h> 1362306a36Sopenharmony_ci#include <linux/notifier.h> 1462306a36Sopenharmony_ci#include <linux/export.h> 1562306a36Sopenharmony_ci#include <net/netevent.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistatic ATOMIC_NOTIFIER_HEAD(netevent_notif_chain); 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci/** 2062306a36Sopenharmony_ci * register_netevent_notifier - register a netevent notifier block 2162306a36Sopenharmony_ci * @nb: notifier 2262306a36Sopenharmony_ci * 2362306a36Sopenharmony_ci * Register a notifier to be called when a netevent occurs. 2462306a36Sopenharmony_ci * The notifier passed is linked into the kernel structures and must 2562306a36Sopenharmony_ci * not be reused until it has been unregistered. A negative errno code 2662306a36Sopenharmony_ci * is returned on a failure. 2762306a36Sopenharmony_ci */ 2862306a36Sopenharmony_ciint register_netevent_notifier(struct notifier_block *nb) 2962306a36Sopenharmony_ci{ 3062306a36Sopenharmony_ci return atomic_notifier_chain_register(&netevent_notif_chain, nb); 3162306a36Sopenharmony_ci} 3262306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(register_netevent_notifier); 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/** 3562306a36Sopenharmony_ci * unregister_netevent_notifier - unregister a netevent notifier block 3662306a36Sopenharmony_ci * @nb: notifier 3762306a36Sopenharmony_ci * 3862306a36Sopenharmony_ci * Unregister a notifier previously registered by 3962306a36Sopenharmony_ci * register_neigh_notifier(). The notifier is unlinked into the 4062306a36Sopenharmony_ci * kernel structures and may then be reused. A negative errno code 4162306a36Sopenharmony_ci * is returned on a failure. 4262306a36Sopenharmony_ci */ 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciint unregister_netevent_notifier(struct notifier_block *nb) 4562306a36Sopenharmony_ci{ 4662306a36Sopenharmony_ci return atomic_notifier_chain_unregister(&netevent_notif_chain, nb); 4762306a36Sopenharmony_ci} 4862306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(unregister_netevent_notifier); 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci/** 5162306a36Sopenharmony_ci * call_netevent_notifiers - call all netevent notifier blocks 5262306a36Sopenharmony_ci * @val: value passed unmodified to notifier function 5362306a36Sopenharmony_ci * @v: pointer passed unmodified to notifier function 5462306a36Sopenharmony_ci * 5562306a36Sopenharmony_ci * Call all neighbour notifier blocks. Parameters and return value 5662306a36Sopenharmony_ci * are as for notifier_call_chain(). 5762306a36Sopenharmony_ci */ 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ciint call_netevent_notifiers(unsigned long val, void *v) 6062306a36Sopenharmony_ci{ 6162306a36Sopenharmony_ci return atomic_notifier_call_chain(&netevent_notif_chain, val, v); 6262306a36Sopenharmony_ci} 6362306a36Sopenharmony_ciEXPORT_SYMBOL_GPL(call_netevent_notifiers); 64