Skip to content

Commit f408e0c

Browse files
j-c-hdavem330
authored andcommitted
netlink: Export genl_lock() API for use by modules
This lets kernel modules which use genl netlink APIs serialize netlink processing. Signed-off-by: James Chapman <jchapman@katalix.com> Reviewed-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0d76751 commit f408e0c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

include/linux/genetlink.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,12 @@ enum {
8080

8181
#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
8282

83+
#ifdef __KERNEL__
84+
85+
/* All generic netlink requests are serialized by a global lock. */
86+
extern void genl_lock(void);
87+
extern void genl_unlock(void);
88+
89+
#endif /* __KERNEL__ */
90+
8391
#endif /* __LINUX_GENERIC_NETLINK_H */

net/netlink/genetlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020

2121
static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */
2222

23-
static inline void genl_lock(void)
23+
void genl_lock(void)
2424
{
2525
mutex_lock(&genl_mutex);
2626
}
27+
EXPORT_SYMBOL(genl_lock);
2728

28-
static inline void genl_unlock(void)
29+
void genl_unlock(void)
2930
{
3031
mutex_unlock(&genl_mutex);
3132
}
33+
EXPORT_SYMBOL(genl_unlock);
3234

3335
#define GENL_FAM_TAB_SIZE 16
3436
#define GENL_FAM_TAB_MASK (GENL_FAM_TAB_SIZE - 1)

0 commit comments

Comments
 (0)