浏览代码

[NET]: Replace CONFIG_NET_DEBUG with sysctl.

Covert network warning messages from a compile time to runtime choice.
Removes kernel config option and replaces it with new /proc/sys/net/core/warnings.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stephen Hemminger 18 年之前
父节点
当前提交
a2a316fd06
共有 6 个文件被更改,包括 25 次插入14 次删除
  1. 9 0
      Documentation/filesystems/proc.txt
  2. 1 0
      include/linux/sysctl.h
  3. 5 7
      include/net/sock.h
  4. 0 7
      net/Kconfig
  5. 8 0
      net/core/sysctl_net_core.c
  6. 2 0
      net/core/utils.c

+ 9 - 0
Documentation/filesystems/proc.txt

@@ -1421,6 +1421,15 @@ fewer messages that will be written. Message_burst controls when messages will
 be dropped.  The  default  settings  limit  warning messages to one every five
 be dropped.  The  default  settings  limit  warning messages to one every five
 seconds.
 seconds.
 
 
+warnings
+--------
+
+This controls console messages from the networking stack that can occur because
+of problems on the network like duplicate address or bad checksums. Normally,
+this should be enabled, but if the problem persists the messages can be
+disabled.
+
+
 netdev_max_backlog
 netdev_max_backlog
 ------------------
 ------------------
 
 

+ 1 - 0
include/linux/sysctl.h

@@ -290,6 +290,7 @@ enum
 	NET_CORE_BUDGET=19,
 	NET_CORE_BUDGET=19,
 	NET_CORE_AEVENT_ETIME=20,
 	NET_CORE_AEVENT_ETIME=20,
 	NET_CORE_AEVENT_RSEQTH=21,
 	NET_CORE_AEVENT_RSEQTH=21,
+	NET_CORE_WARNINGS=22,
 };
 };
 
 
 /* /proc/sys/net/ethernet */
 /* /proc/sys/net/ethernet */

+ 5 - 7
include/net/sock.h

@@ -1334,14 +1334,12 @@ extern int sock_get_timestampns(struct sock *, struct timespec __user *);
 /* 
 /* 
  *	Enable debug/info messages 
  *	Enable debug/info messages 
  */
  */
+extern int net_msg_warn;
+#define NETDEBUG(fmt, args...) \
+	do { if (net_msg_warn) printk(fmt,##args); } while (0)
 
 
-#ifdef CONFIG_NETDEBUG
-#define NETDEBUG(fmt, args...)	printk(fmt,##args)
-#define LIMIT_NETDEBUG(fmt, args...) do { if (net_ratelimit()) printk(fmt,##args); } while(0)
-#else
-#define NETDEBUG(fmt, args...)	do { } while (0)
-#define LIMIT_NETDEBUG(fmt, args...) do { } while(0)
-#endif
+#define LIMIT_NETDEBUG(fmt, args...) \
+	do { if (net_msg_warn && net_ratelimit()) printk(fmt,##args); } while(0)
 
 
 /*
 /*
  * Macros for sleeping on a socket. Use them like this:
  * Macros for sleeping on a socket. Use them like this:

+ 0 - 7
net/Kconfig

@@ -27,13 +27,6 @@ if NET
 
 
 menu "Networking options"
 menu "Networking options"
 
 
-config NETDEBUG
-	bool "Network packet debugging"
-	help
-	  You can say Y here if you want to get additional messages useful in
-	  debugging bad packets, but can overwhelm logs under denial of service
-	  attacks.
-
 source "net/packet/Kconfig"
 source "net/packet/Kconfig"
 source "net/unix/Kconfig"
 source "net/unix/Kconfig"
 source "net/xfrm/Kconfig"
 source "net/xfrm/Kconfig"

+ 8 - 0
net/core/sysctl_net_core.c

@@ -136,6 +136,14 @@ ctl_table core_table[] = {
 		.mode		= 0644,
 		.mode		= 0644,
 		.proc_handler	= &proc_dointvec
 		.proc_handler	= &proc_dointvec
 	},
 	},
+	{
+		.ctl_name	= NET_CORE_WARNINGS,
+		.procname	= "warnings",
+		.data		= &net_msg_warn,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec
+	},
 	{ .ctl_name = 0 }
 	{ .ctl_name = 0 }
 };
 };
 
 

+ 2 - 0
net/core/utils.c

@@ -32,6 +32,8 @@
 
 
 int net_msg_cost = 5*HZ;
 int net_msg_cost = 5*HZ;
 int net_msg_burst = 10;
 int net_msg_burst = 10;
+int net_msg_warn = 1;
+EXPORT_SYMBOL(net_msg_warn);
 
 
 /*
 /*
  * All net warning printk()s should be guarded by this function.
  * All net warning printk()s should be guarded by this function.