Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2016 09:04:14 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300721 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201605260904.u4Q94EXw054893@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu May 26 09:04:14 2016
New Revision: 300721
URL: https://svnweb.freebsd.org/changeset/base/300721

Log:
  Add support for runtime modifiable module parameters in the LinuxKPI.
  
  Linux module parameters have a permissions value. If any write bits
  are set we are allowed to modify the module parameter runtime. Reflect
  this when creating the static SYSCTL nodes.
  
  Sponsored by:	Mellanox Technologies
  MFC after:	1 week

Modified:
  head/sys/compat/linuxkpi/common/include/linux/moduleparam.h

Modified: head/sys/compat/linuxkpi/common/include/linux/moduleparam.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/moduleparam.h	Thu May 26 08:47:06 2016	(r300720)
+++ head/sys/compat/linuxkpi/common/include/linux/moduleparam.h	Thu May 26 09:04:14 2016	(r300721)
@@ -44,77 +44,81 @@
 #define	LINUXKPI_PARAM_PREFIX	/* empty prefix is the default */
 #endif
 
+#ifndef LINUXKPI_PARAM_PERM
+#define	LINUXKPI_PARAM_PERM(perm) (((perm) & 0222) ? CTLFLAG_RWTUN : CTLFLAG_RDTUN)
+#endif
+
 #define	LINUXKPI_PARAM_CONCAT_SUB(a,b,c,d) a##b##c##d
 #define	LINUXKPI_PARAM_CONCAT(...) LINUXKPI_PARAM_CONCAT_SUB(__VA_ARGS__)
 #define	LINUXKPI_PARAM_PASS(...) __VA_ARGS__
 #define	LINUXKPI_PARAM_DESC(name) LINUXKPI_PARAM_CONCAT(linuxkpi_,LINUXKPI_PARAM_PREFIX,name,_desc)
 #define	LINUXKPI_PARAM_NAME(name) LINUXKPI_PARAM_CONCAT(LINUXKPI_PARAM_PREFIX,name,,)
 
-#define	LINUXKPI_PARAM_bool(name, var)					\
+#define	LINUXKPI_PARAM_bool(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_BOOL(LINUXKPI_PARAM_PARENT, OID_AUTO,\
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
 	LINUXKPI_PARAM_DESC(name)))
 
-#define	LINUXKPI_PARAM_byte(name, var)					\
+#define	LINUXKPI_PARAM_byte(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_U8(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
 	LINUXKPI_PARAM_DESC(name)))
 
-#define	LINUXKPI_PARAM_short(name, var)					\
+#define	LINUXKPI_PARAM_short(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_S16(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
-        LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
 	LINUXKPI_PARAM_DESC(name)))
 
-#define	LINUXKPI_PARAM_ushort(name, var)				\
+#define	LINUXKPI_PARAM_ushort(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_U16(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
 	LINUXKPI_PARAM_DESC(name)))
 
-#define	LINUXKPI_PARAM_int(name, var)					\
+#define	LINUXKPI_PARAM_int(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_INT(LINUXKPI_PARAM_PARENT, OID_AUTO,	\
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0,\
 	LINUXKPI_PARAM_DESC(name)))
 
-#define	LINUXKPI_PARAM_uint(name, var)					\
+#define	LINUXKPI_PARAM_uint(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_UINT(LINUXKPI_PARAM_PARENT, OID_AUTO, \
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
 	LINUXKPI_PARAM_DESC(name)))
 
-#define	LINUXKPI_PARAM_long(name, var)					\
+#define	LINUXKPI_PARAM_long(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_LONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
 	LINUXKPI_PARAM_DESC(name)))
 
-#define	LINUXKPI_PARAM_ulong(name, var)					\
+#define	LINUXKPI_PARAM_ulong(name, var, perm)				\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_ULONG(LINUXKPI_PARAM_PARENT, OID_AUTO, \
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, &(var), 0,		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), &(var), 0, \
 	LINUXKPI_PARAM_DESC(name)))
 
 #define	module_param_string(name, str, len, perm)			\
 	extern const char LINUXKPI_PARAM_DESC(name)[];			\
 	LINUXKPI_PARAM_PASS(SYSCTL_STRING(LINUXKPI_PARAM_PARENT, OID_AUTO, \
-	LINUXKPI_PARAM_NAME(name), CTLFLAG_RDTUN, (str), (len),		\
+	LINUXKPI_PARAM_NAME(name), LINUXKPI_PARAM_PERM(perm), (str), (len), \
 	LINUXKPI_PARAM_DESC(name)))
 
 #define	module_param_named(name, var, type, mode)	\
-	LINUXKPI_PARAM_##type(name, var)
+	LINUXKPI_PARAM_##type(name, var, mode)
 
 #define	module_param(var, type, mode)	\
-	LINUXKPI_PARAM_##type(var, var)
+	LINUXKPI_PARAM_##type(var, var, mode)
 
 #define	module_param_named_unsafe(name, var, type, mode) \
-	LINUXKPI_PARAM_##type(name, var)
+	LINUXKPI_PARAM_##type(name, var, mode)
 
 #define	module_param_unsafe(var, type, mode) \
-	LINUXKPI_PARAM_##type(var, var)
+	LINUXKPI_PARAM_##type(var, var, mode)
 
 #define	module_param_array(var, type, addr_argc, mode)
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605260904.u4Q94EXw054893>