From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D470481FCC; Thu, 2 Jul 2026 12:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782994860; cv=none; b=q9cH0JGJvOsnfhc+BfoHkP9yQFWauz+/xRob+as5Pk7ae6WuQSzvV6XWINPyc0AT7kueHTqM9MezZuOp6PWg0L7sFe8dlDBpnBlaE7kKDnlqqNW0sYPT6jFOBnlCE/9ASvkZSu6SUo8jszbTu1OpSD8/c4zZRXM5Li2BC+vfMP0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782994860; c=relaxed/simple; bh=5ecIHtebbkqnGtf3pYnZrHLXspo/K3PM9LfcktKyQTI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kWSokQHrsIExQzP//+hgqREOLTqeYKaJVaamFwQocferlLuxRW5l4iXyLM1qIz4IjePNP7DLpC1vzD9LGrcRqNKEjDRwksu7Xy6/HZ5Lgnlk2rjkCEzjGqLfLagAIoYX/Imxtu+vdgRADsJZHa+EGZAGm7Iq63PvoI5nbiNCCJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=ZGL3XDkK; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="ZGL3XDkK" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=ll9z2sCbWgIzbIAudTgtnycIY+OY2vjBIYoVtkD1jI8=; b=ZGL3XDkKQ8YvdoZAEUupcRzYPT RP8EjwdKSlcXdeFJYKeTVljzl/QuMGudjKQ6emYh5kujlJ2CUz8RVQmSC8DTt2Ouc7JjCQ346PJEh m1Q9jrgw2xH6+E2ao8U9GJZ4zR0I3HRquK8mpzsY1gzad6HMfJ0rqkicne0GBO9zrUZuOxP91jEgk aJtpyjziDcexRn96Qez7A6IqNoZOcpp7OTHUHNhckK1hQdpHqyYlkRlR65utXl0RpgrwKC+fc5x9L kGhfLqVmuROwGoKpB5YTgDhdvV5ZEkxd3jC5L8+BzH66dcBEb0t5W34YeaOqlp4MLDSdcCKN+DUO+ fFiCogVw==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wfGPW-008cRQ-17; Thu, 02 Jul 2026 12:20:54 +0000 From: Breno Leitao Date: Thu, 02 Jul 2026 05:19:51 -0700 Subject: [PATCH net-next v2 7/8] netconsole: move local_port / remote_port from struct netpoll to netconsole_target Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260702-netconsole_move_more-v2-7-1ebedd921dcb@debian.org> References: <20260702-netconsole_move_more-v2-0-1ebedd921dcb@debian.org> In-Reply-To: <20260702-netconsole_move_more-v2-0-1ebedd921dcb@debian.org> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn Cc: netdev@vger.kernel.org, asantostc@gmail.com, gustavold@gmail.com, linux-kernel@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7725; i=leitao@debian.org; h=from:subject:message-id; bh=5ecIHtebbkqnGtf3pYnZrHLXspo/K3PM9LfcktKyQTI=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqRleFb3CcL5+5eJMLnUZ8XtwtXNaT4dcBIvj56 p8eEeaeIXeJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCakZXhQAKCRA1o5Of/Hh3 beTuD/9C061eTYbuWfvX5sq1xJseTITV8fIsUJgv33t1Tws7gFGMlUXZBpxnOgdWEbg0kGSPX2x /DQX+Hr5x5ZupUUPumwEXPlEtlPahwtBbjiZf/Rw3Y11WWRYfXBsLknDGfcz/M6NpvO2wFFvTqr wpAxJvlnbcUUcEGdGDHi5XNywu1MjlMm3qGNQ9SNeABdmWoeC+QSSKDqqtl8QgfRXyMSq5HLO/6 m/E/LTpbUJytgj62JiWDtQDEqBtB4gApQbVdgqiCEXbStMpMZOUAV3Y2QG3tGitpfzHoRi8opc6 emgE0QVR+TOgLdmo1piiTdjVDVoDsZyT2xhclw42b2iHX9wNcDV8LFVlCjEVysHYru+VHPdqN1M Ab6lZqgNUN36a37PbKN3afXsk6hcfcfa4mJQFxPS0J5wdbzJd29a2g37SY+P0iTiMMVz+t4LO4a xDHL/N3MZx5LFsEI9BahQsKHhc+kYtLvvSg8343DaW/xc6/oKsUFV2etiheRrP5dJagh+nPBbvp khB2UfQLYPesjPNtpGtAX/OSWwmB/7ZigarxiIOJerpwKIPVQjOc1PHYlSQZLszT9miVxgJe9hj MFZeUN2IB/Vye3oDMbzI+ICwRUIwm5fK3ExMxruFzv+58tTGhDRXWRMQBH8UwBvkNIW0Zul9Ua6 8GA2O8WsBOG/Pug== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao The source and destination UDP ports live in struct netpoll but are netconsole configuration. No other netpoll user (bonding, team, vlan, bridge, macvlan, dsa) touches np->local_port or np->remote_port; they only use the netpoll TX/forwarding path. Only netconsole's UDP framing and its configfs/cmdline interface read these fields. Move both into struct netconsole_target and convert the three helpers that read them - push_udp(), netconsole_print_banner() and netconsole_parser_cmdline() - to take the netconsole_target. The configfs show/store handlers already have the target in hand. No functional change; the local_port / remote_port sysfs attributes are unchanged. Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 47 ++++++++++++++++++++++++++--------------------- include/linux/netpoll.h | 1 - 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index bfa5fdac9600b..75d50630a31ab 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -175,12 +175,12 @@ enum target_state { * @np: The netpoll structure for this target. * Contains the other userspace visible parameters: * dev_name (read-write) - * local_port (read-write) - * remote_port (read-write) * local_ip (read-write) * remote_ip (read-write) * local_mac (read-only) * remote_mac (read-write) + * @local_port: Source UDP port of the target (read-write). + * @remote_port: Destination UDP port of the target (read-write). * @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 @@ -208,6 +208,7 @@ struct netconsole_target { bool extended; bool release; struct netpoll np; + u16 local_port, remote_port; /* protected by target_list_lock; +1 gives scnprintf() room for its * NUL terminator so a full MAX_PRINT_CHUNK payload is not truncated */ @@ -461,8 +462,8 @@ static struct netconsole_target *alloc_and_init(void) nt->np.name = "netconsole"; strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); - nt->np.local_port = 6665; - nt->np.remote_port = 6666; + nt->local_port = 6665; + nt->remote_port = 6666; eth_broadcast_addr(nt->np.remote_mac); nt->state = STATE_DISABLED; INIT_WORK(&nt->resume_wq, process_resume_target); @@ -498,16 +499,18 @@ static void netconsole_process_cleanups_core(void) mutex_unlock(&target_cleanup_list_lock); } -static void netconsole_print_banner(struct netpoll *np) +static void netconsole_print_banner(struct netconsole_target *nt) { - np_info(np, "local port %d\n", np->local_port); + struct netpoll *np = &nt->np; + + np_info(np, "local port %d\n", nt->local_port); if (np->ipv6) np_info(np, "local IPv6 address %pI6c\n", &np->local_ip.in6); else 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 @@ -630,12 +633,12 @@ static ssize_t dev_name_show(struct config_item *item, char *buf) static ssize_t local_port_show(struct config_item *item, char *buf) { - return sysfs_emit(buf, "%d\n", to_target(item)->np.local_port); + return sysfs_emit(buf, "%d\n", to_target(item)->local_port); } 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) @@ -825,7 +828,7 @@ static ssize_t enabled_store(struct config_item *item, * Skip netconsole_parser_cmdline() -- all the attributes are * already configured via configfs. Just print them out. */ - netconsole_print_banner(&nt->np); + netconsole_print_banner(nt); /* Initialise the skb pool before netpoll_setup() so the pool * is valid as soon as nt->np.dev becomes visible to @@ -964,7 +967,7 @@ static ssize_t local_port_store(struct config_item *item, const char *buf, goto out_unlock; } - ret = kstrtou16(buf, 10, &nt->np.local_port); + ret = kstrtou16(buf, 10, &nt->local_port); if (ret < 0) goto out_unlock; ret = count; @@ -986,7 +989,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; @@ -1862,8 +1865,9 @@ static void netpoll_udp_checksum(struct netpoll *np, struct sk_buff *skb, udph->check = CSUM_MANGLED_0; } -static void push_udp(struct netpoll *np, struct sk_buff *skb, int len) +static void push_udp(struct netconsole_target *nt, struct sk_buff *skb, int len) { + struct netpoll *np = &nt->np; struct udphdr *udph; int udp_len; @@ -1873,8 +1877,8 @@ static void push_udp(struct netpoll *np, struct sk_buff *skb, int len) skb_reset_transport_header(skb); udph = udp_hdr(skb); - udph->source = htons(np->local_port); - udph->dest = htons(np->remote_port); + udph->source = htons(nt->local_port); + udph->dest = htons(nt->remote_port); udph->len = htons(udp_len); netpoll_udp_checksum(np, skb, len); @@ -1970,7 +1974,7 @@ static int netpoll_send_udp(struct netconsole_target *nt, const char *msg, skb_copy_to_linear_data(skb, msg, len); skb_put(skb, len); - push_udp(np, skb, len); + push_udp(nt, skb, len); if (np->ipv6) push_ipv6(np, skb, len); else @@ -2288,8 +2292,9 @@ __releases(&target_list_lock) spin_unlock_irqrestore(&target_list_lock, flags); } -static int netconsole_parser_cmdline(struct netpoll *np, char *opt) +static int netconsole_parser_cmdline(struct netconsole_target *nt, char *opt) { + struct netpoll *np = &nt->np; bool ipversion_set = false; char *cur = opt; char *delim; @@ -2300,7 +2305,7 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt) if (!delim) goto parse_failed; *delim = 0; - if (kstrtou16(cur, 10, &np->local_port)) + if (kstrtou16(cur, 10, &nt->local_port)) goto parse_failed; cur = delim; } @@ -2347,7 +2352,7 @@ static int netconsole_parser_cmdline(struct netpoll *np, 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; } @@ -2373,7 +2378,7 @@ static int netconsole_parser_cmdline(struct netpoll *np, char *opt) goto parse_failed; } - netconsole_print_banner(np); + netconsole_print_banner(nt); return 0; @@ -2411,7 +2416,7 @@ static struct netconsole_target *alloc_param_target(char *target_config, } /* Parse parameters and setup netpoll */ - err = netconsole_parser_cmdline(&nt->np, target_config); + err = netconsole_parser_cmdline(nt, target_config); if (err) goto fail; diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index f377fdf7839ca..5ca79fa7d9431 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -35,7 +35,6 @@ struct netpoll { union inet_addr local_ip, remote_ip; bool ipv6; - u16 local_port, remote_port; u8 remote_mac[ETH_ALEN]; }; -- 2.53.0-Meta