From: Wang Liang <wangliang74@huawei.com>
To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
<pabeni@redhat.com>, <horms@kernel.org>, <dsahern@kernel.org>
Cc: <yuehaibing@huawei.com>, <zhangchangzhong@huawei.com>,
<wangliang74@huawei.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH net-next] net: add sysctl ndisc_debug
Date: Tue, 24 Jun 2025 20:51:15 +0800 [thread overview]
Message-ID: <20250624125115.3926152-1-wangliang74@huawei.com> (raw)
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
next reply other threads:[~2025-06-24 12:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 12:51 Wang Liang [this message]
2025-06-24 14:31 ` Ido Schimmel
2025-06-27 1:13 ` Wang Liang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250624125115.3926152-1-wangliang74@huawei.com \
--to=wangliang74@huawei.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yuehaibing@huawei.com \
--cc=zhangchangzhong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®