blob: bc738504ab4a85a1f3ceff06a4bde0ad2b8716aa [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Thomas Graf482a8522005-11-10 02:25:56 +01002#ifndef __LINUX_GENERIC_NETLINK_H
3#define __LINUX_GENERIC_NETLINK_H
4
David Howells607ca462012-10-13 10:46:48 +01005#include <uapi/linux/genetlink.h>
Thomas Graf482a8522005-11-10 02:25:56 +01006
James Chapmanf408e0c2010-04-02 06:19:05 +00007
8/* All generic netlink requests are serialized by a global lock. */
9extern void genl_lock(void);
10extern void genl_unlock(void);
WANG Cong320f5ea2012-07-24 13:44:01 +080011#ifdef CONFIG_LOCKDEP
Yaowei Bai61d03532015-10-08 21:28:54 +080012extern bool lockdep_genl_is_held(void);
Pravin B Shelar86b13092011-11-10 19:14:51 -080013#endif
James Chapmanf408e0c2010-04-02 06:19:05 +000014
Johannes Bergee1c24422015-01-16 11:37:14 +010015/* for synchronisation between af_netlink and genetlink */
16extern atomic_t genl_sk_destructing_cnt;
17extern wait_queue_head_t genl_sk_destructing_waitq;
18
Jesse Grossb4e16612011-11-19 16:21:37 -080019/**
20 * rcu_dereference_genl - rcu_dereference with debug checking
21 * @p: The pointer to read, prior to dereferencing
22 *
23 * Do an rcu_dereference(p), but check caller either holds rcu_read_lock()
24 * or genl mutex. Note : Please prefer genl_dereference() or rcu_dereference()
25 */
26#define rcu_dereference_genl(p) \
27 rcu_dereference_check(p, lockdep_genl_is_held())
28
29/**
30 * genl_dereference - fetch RCU pointer when updates are prevented by genl mutex
31 * @p: The pointer to read, prior to dereferencing
32 *
33 * Return the value of the specified RCU-protected pointer, but omit
Paul E. McKenney632a5c12017-11-27 09:23:24 -080034 * the READ_ONCE(), because caller holds genl mutex.
Jesse Grossb4e16612011-11-19 16:21:37 -080035 */
36#define genl_dereference(p) \
37 rcu_dereference_protected(p, lockdep_genl_is_held())
38
Neil Hormane9412c32012-05-29 09:30:41 +000039#define MODULE_ALIAS_GENL_FAMILY(family)\
40 MODULE_ALIAS_NET_PF_PROTO_NAME(PF_NETLINK, NETLINK_GENERIC, "-family-" family)
41
Thomas Graf482a8522005-11-10 02:25:56 +010042#endif /* __LINUX_GENERIC_NETLINK_H */