Skip to content

Commit a2a316f

Browse files
Stephen HemmingerDavid S. Miller
authored andcommitted
[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>
1 parent ae40eb1 commit a2a316f

File tree

6 files changed

+25
-14
lines changed

6 files changed

+25
-14
lines changed

Documentation/filesystems/proc.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,15 @@ fewer messages that will be written. Message_burst controls when messages will
14211421
be dropped. The default settings limit warning messages to one every five
14221422
seconds.
14231423

1424+
warnings
1425+
--------
1426+
1427+
This controls console messages from the networking stack that can occur because
1428+
of problems on the network like duplicate address or bad checksums. Normally,
1429+
this should be enabled, but if the problem persists the messages can be
1430+
disabled.
1431+
1432+
14241433
netdev_max_backlog
14251434
------------------
14261435

include/linux/sysctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ enum
290290
NET_CORE_BUDGET=19,
291291
NET_CORE_AEVENT_ETIME=20,
292292
NET_CORE_AEVENT_RSEQTH=21,
293+
NET_CORE_WARNINGS=22,
293294
};
294295

295296
/* /proc/sys/net/ethernet */

include/net/sock.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,14 +1334,12 @@ extern int sock_get_timestampns(struct sock *, struct timespec __user *);
13341334
/*
13351335
* Enable debug/info messages
13361336
*/
1337+
extern int net_msg_warn;
1338+
#define NETDEBUG(fmt, args...) \
1339+
do { if (net_msg_warn) printk(fmt,##args); } while (0)
13371340

1338-
#ifdef CONFIG_NETDEBUG
1339-
#define NETDEBUG(fmt, args...) printk(fmt,##args)
1340-
#define LIMIT_NETDEBUG(fmt, args...) do { if (net_ratelimit()) printk(fmt,##args); } while(0)
1341-
#else
1342-
#define NETDEBUG(fmt, args...) do { } while (0)
1343-
#define LIMIT_NETDEBUG(fmt, args...) do { } while(0)
1344-
#endif
1341+
#define LIMIT_NETDEBUG(fmt, args...) \
1342+
do { if (net_msg_warn && net_ratelimit()) printk(fmt,##args); } while(0)
13451343

13461344
/*
13471345
* Macros for sleeping on a socket. Use them like this:

net/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ if NET
2727

2828
menu "Networking options"
2929

30-
config NETDEBUG
31-
bool "Network packet debugging"
32-
help
33-
You can say Y here if you want to get additional messages useful in
34-
debugging bad packets, but can overwhelm logs under denial of service
35-
attacks.
36-
3730
source "net/packet/Kconfig"
3831
source "net/unix/Kconfig"
3932
source "net/xfrm/Kconfig"

net/core/sysctl_net_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ ctl_table core_table[] = {
136136
.mode = 0644,
137137
.proc_handler = &proc_dointvec
138138
},
139+
{
140+
.ctl_name = NET_CORE_WARNINGS,
141+
.procname = "warnings",
142+
.data = &net_msg_warn,
143+
.maxlen = sizeof(int),
144+
.mode = 0644,
145+
.proc_handler = &proc_dointvec
146+
},
139147
{ .ctl_name = 0 }
140148
};
141149

net/core/utils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
int net_msg_cost = 5*HZ;
3434
int net_msg_burst = 10;
35+
int net_msg_warn = 1;
36+
EXPORT_SYMBOL(net_msg_warn);
3537

3638
/*
3739
* All net warning printk()s should be guarded by this function.

0 commit comments

Comments
 (0)