瀏覽代碼

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>
James Chapman 15 年之前
父節點
當前提交
f408e0ce40
共有 2 個文件被更改,包括 12 次插入2 次删除
  1. 8 0
      include/linux/genetlink.h
  2. 4 2
      net/netlink/genetlink.c

+ 8 - 0
include/linux/genetlink.h

@@ -80,4 +80,12 @@ enum {
 
 
 #define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
 #define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
 
 
+#ifdef __KERNEL__
+
+/* All generic netlink requests are serialized by a global lock.  */
+extern void genl_lock(void);
+extern void genl_unlock(void);
+
+#endif /* __KERNEL__ */
+
 #endif	/* __LINUX_GENERIC_NETLINK_H */
 #endif	/* __LINUX_GENERIC_NETLINK_H */

+ 4 - 2
net/netlink/genetlink.c

@@ -20,15 +20,17 @@
 
 
 static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */
 static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */
 
 
-static inline void genl_lock(void)
+void genl_lock(void)
 {
 {
 	mutex_lock(&genl_mutex);
 	mutex_lock(&genl_mutex);
 }
 }
+EXPORT_SYMBOL(genl_lock);
 
 
-static inline void genl_unlock(void)
+void genl_unlock(void)
 {
 {
 	mutex_unlock(&genl_mutex);
 	mutex_unlock(&genl_mutex);
 }
 }
+EXPORT_SYMBOL(genl_unlock);
 
 
 #define GENL_FAM_TAB_SIZE	16
 #define GENL_FAM_TAB_SIZE	16
 #define GENL_FAM_TAB_MASK	(GENL_FAM_TAB_SIZE - 1)
 #define GENL_FAM_TAB_MASK	(GENL_FAM_TAB_SIZE - 1)