public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: add sysctl ndisc_debug
@ 2025-06-24 12:51 Wang Liang
  2025-06-24 14:31 ` Ido Schimmel
  0 siblings, 1 reply; 3+ messages in thread
From: Wang Liang @ 2025-06-24 12:51 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, horms, dsahern
  Cc: yuehaibing, zhangchangzhong, wangliang74, netdev, linux-kernel

Ipv6 ndisc uses ND_PRINTK to print logs. However it only works when
ND_DEBUG was set in the compilation phase. This patch adds sysctl
ndisc_debug, so we can change the print switch when system is running and
get ipv6 ndisc log to debug.

Signed-off-by: Wang Liang <wangliang74@huawei.com>
---
 include/net/ndisc.h        | 5 ++---
 net/ipv6/ndisc.c           | 3 +++
 net/ipv6/sysctl_net_ipv6.c | 7 +++++++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 3c88d5bc5eed..481a7fc5d5c1 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -60,12 +60,11 @@ enum {
 
 #include <net/neighbour.h>
 
-/* Set to 3 to get tracing... */
-#define ND_DEBUG 1
+extern u8 ndisc_debug;
 
 #define ND_PRINTK(val, level, fmt, ...)				\
 do {								\
-	if (val <= ND_DEBUG)					\
+	if (val <= ndisc_debug)					\
 		net_##level##_ratelimited(fmt, ##__VA_ARGS__);	\
 } while (0)
 
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index ecb5c4b8518f..be4bb72b1d61 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -83,6 +83,9 @@ static void pndisc_destructor(struct pneigh_entry *n);
 static void pndisc_redo(struct sk_buff *skb);
 static int ndisc_is_multicast(const void *pkey);
 
+u8 ndisc_debug = 1;
+EXPORT_SYMBOL_GPL(ndisc_debug);
+
 static const struct neigh_ops ndisc_generic_ops = {
 	.family =		AF_INET6,
 	.solicit =		ndisc_solicit,
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index d2cd33e2698d..c0968f0c5d00 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -247,6 +247,13 @@ static struct ctl_table ipv6_rotable[] = {
 		.proc_handler	= proc_dointvec,
 	},
 #endif /* CONFIG_NETLABEL */
+	{
+		.procname	= "ndisc_debug",
+		.data		= &ndisc_debug,
+		.maxlen		= sizeof(u8),
+		.mode		= 0644,
+		.proc_handler	= proc_dou8vec_minmax
+	},
 };
 
 static int __net_init ipv6_sysctl_net_init(struct net *net)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-27  1:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24 12:51 [PATCH net-next] net: add sysctl ndisc_debug Wang Liang
2025-06-24 14:31 ` Ido Schimmel
2025-06-27  1:13   ` Wang Liang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox