Re: [PATCH net-next 4/9] netconsole: move netpoll_local_ip_unset() as netcons_local_ip_unset()
From: Gustavo Luiz Duarte <hidden>
Date: 2026-07-27 23:49:58
Also in:
lkml
On Fri, Jul 24, 2026 at 4:05 PM Breno Leitao [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Move netpoll_local_ip_unset() from netpoll to netconsole and rename it to netcons_local_ip_unset(); The body is otherwise unchanged, only the comment's setup-function reference is updated. Signed-off-by: Breno Leitao <leitao@debian.org> --- drivers/net/netconsole.c | 19 ++++++++++++++++++- include/linux/netpoll.h | 1 - net/core/netpoll.c | 18 ------------------ 3 files changed, 18 insertions(+), 20 deletions(-)diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 3a7a2cafc6276..70f9c5bfb3720 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c@@ -351,6 +351,23 @@ static void netconsole_skb_pool_flush(struct netconsole_target *nt) skb_queue_purge_reason(&nt->skb_pool, SKB_CONSUMED); } +/* + * Test whether the caller left np->local_ip unset, so that + * netcons_netpoll_setup() should auto-populate it from the egress device. + * + * np->local_ip is a union of __be32 (IPv4) and struct in6_addr (IPv6), + * so an IPv6 address whose first 4 bytes are zero (e.g. ::1, ::2, + * IPv4-mapped ::ffff:a.b.c.d) must not be tested via the IPv4 arm — + * doing so would misclassify a caller-supplied address as unset and + * silently overwrite it with whatever address the device exposes. + */ +static bool netcons_local_ip_unset(const struct netpoll *np) +{ + if (np->ipv6) + return ipv6_addr_any(&np->local_ip.in6); + return !np->local_ip.ip; +}
This whole checking if it is all zeroes in netcons_local_ip_unset() looks very cumbersome. Perhaps instead of storing 'bool ipv6' we could have something like 'u8 family', which would contain AF_INET for ipv4, AF_INET6 for ipv6, or AF_UNSPEC if unset. But that would be another patch separate from this refactoring, so for this patch: Reviewed-by: Gustavo Luiz Duarte <redacted>