mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: "David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	 Andrew Lunn <andrew+netdev@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 gustavold@gmail.com, asantostc@gmail.com,
	Breno Leitao <leitao@debian.org>,
	 kernel-team@meta.com
Subject: [PATCH 8/9] netconsole: move remote_port from struct netpoll to netconsole_target
Date: Sun, 24 May 2026 09:12:24 -0700	[thread overview]
Message-ID: <20260524-netconsole_move_more-v1-8-909d1ab398b4@debian.org> (raw)
In-Reply-To: <20260524-netconsole_move_more-v1-0-909d1ab398b4@debian.org>

The UDP destination port used to build outgoing log packets is pure
netconsole configuration. net/core/netpoll.c never reads it, and
no other struct netpoll consumer touches it.

Add remote_port to struct netconsole_target, drop it from struct
netpoll, and update alloc_and_init(), the remote_port_show /
remote_port_store configfs handlers, push_udp(),
netconsole_print_banner() and netconsole_parser_cmdline() to read
it from nt-> rather than np->. The struct netconsole_target *
parameter threaded through these helpers by the previous patch
already gives them access to the new home.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 14 ++++++++------
 include/linux/netpoll.h  |  1 -
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index a4f34560cee5..32e2a925f915 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -177,6 +177,7 @@ enum target_state {
  *		that netpoll core still reads (local_ip, remote_ip, ipv6,
  *		dev_name, dev_mac).
  * @local_port:	UDP source port used to build outgoing log packets.
+ * @remote_port:	UDP destination port used to build outgoing log packets.
  * @buf:	The buffer used to send the full msg to the network stack
  * @resume_wq:	Workqueue to resume deactivated target
  * @skb_pool:	Per-target fallback skb pool consulted by find_skb() when
@@ -205,6 +206,7 @@ struct netconsole_target {
 	bool			release;
 	struct netpoll		np;
 	u16			local_port;
+	u16			remote_port;
 	/* protected by target_list_lock */
 	char			buf[MAX_PRINT_CHUNK];
 	struct work_struct	resume_wq;
@@ -430,7 +432,7 @@ static struct netconsole_target *alloc_and_init(void)
 	nt->np.name = "netconsole";
 	strscpy(nt->np.dev_name, "eth0", IFNAMSIZ);
 	nt->local_port = 6665;
-	nt->np.remote_port = 6666;
+	nt->remote_port = 6666;
 	eth_broadcast_addr(nt->np.remote_mac);
 	nt->state = STATE_DISABLED;
 	INIT_WORK(&nt->resume_wq, process_resume_target);
@@ -479,7 +481,7 @@ static void netconsole_print_banner(struct netconsole_target *nt)
 		np_info(np, "local IPv4 address %pI4\n", &np->local_ip.ip);
 	np_info(np, "interface name '%s'\n", np->dev_name);
 	np_info(np, "local ethernet address '%pM'\n", np->dev_mac);
-	np_info(np, "remote port %d\n", np->remote_port);
+	np_info(np, "remote port %d\n", nt->remote_port);
 	if (np->ipv6)
 		np_info(np, "remote IPv6 address %pI6c\n", &np->remote_ip.in6);
 	else
@@ -607,7 +609,7 @@ static ssize_t local_port_show(struct config_item *item, char *buf)
 
 static ssize_t remote_port_show(struct config_item *item, char *buf)
 {
-	return sysfs_emit(buf, "%d\n", to_target(item)->np.remote_port);
+	return sysfs_emit(buf, "%d\n", to_target(item)->remote_port);
 }
 
 static ssize_t local_ip_show(struct config_item *item, char *buf)
@@ -958,7 +960,7 @@ static ssize_t remote_port_store(struct config_item *item,
 		goto out_unlock;
 	}
 
-	ret = kstrtou16(buf, 10, &nt->np.remote_port);
+	ret = kstrtou16(buf, 10, &nt->remote_port);
 	if (ret < 0)
 		goto out_unlock;
 	ret = count;
@@ -1800,7 +1802,7 @@ static void push_udp(struct netconsole_target *nt, struct sk_buff *skb, int len)
 
 	udph = udp_hdr(skb);
 	udph->source = htons(nt->local_port);
-	udph->dest = htons(np->remote_port);
+	udph->dest = htons(nt->remote_port);
 	udph->len = htons(udp_len);
 
 	netpoll_udp_checksum(np, skb, len);
@@ -2274,7 +2276,7 @@ static int netconsole_parser_cmdline(struct netconsole_target *nt, char *opt)
 		*delim = 0;
 		if (*cur == ' ' || *cur == '\t')
 			np_info(np, "warning: whitespace is not allowed\n");
-		if (kstrtou16(cur, 10, &np->remote_port))
+		if (kstrtou16(cur, 10, &nt->remote_port))
 			goto parse_failed;
 		cur = delim;
 	}
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index dcea36713720..12467a45929e 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -33,7 +33,6 @@ struct netpoll {
 
 	union inet_addr local_ip, remote_ip;
 	bool ipv6;
-	u16 remote_port;
 	u8 remote_mac[ETH_ALEN];
 };
 

-- 
2.54.0


  parent reply	other threads:[~2026-05-24 16:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-24 16:12 [PATCH 0/9] netconsole: stop charging every netpoll user for netconsole-only state Breno Leitao
2026-05-24 16:12 ` [PATCH 1/9] netpoll: export refill_skbs(), refill_skbs_work_handler(), skb_pool_flush() Breno Leitao
2026-05-24 16:12 ` [PATCH 2/9] netconsole: take over skb pool lifecycle from netpoll Breno Leitao
2026-05-24 16:12 ` [PATCH 3/9] netconsole: move refill_skbs_work_handler() " Breno Leitao
2026-05-24 16:12 ` [PATCH 4/9] netconsole: move refill_skbs() and skb-pool sizing macros " Breno Leitao
2026-05-24 16:12 ` [PATCH 5/9] netconsole: move skb_pool_flush() " Breno Leitao
2026-05-24 16:12 ` [PATCH 6/9] netconsole: move skb_pool / refill_wq from struct netpoll to netconsole_target Breno Leitao
2026-05-24 16:12 ` [PATCH 7/9] netconsole: move local_port " Breno Leitao
2026-05-24 16:12 ` Breno Leitao [this message]
2026-05-24 16:12 ` [PATCH 9/9] netconsole: move remote_mac " Breno Leitao
2026-05-27  2:00 ` [PATCH 0/9] netconsole: stop charging every netpoll user for netconsole-only state Jakub Kicinski
2026-05-27  9:07   ` Breno Leitao
2026-05-27 13:22     ` Breno Leitao
2026-05-27 22:59       ` Jakub Kicinski

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=20260524-netconsole_move_more-v1-8-909d1ab398b4@debian.org \
    --to=leitao@debian.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=asantostc@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavold@gmail.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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®