From nobody Fri Oct 2 03:03:36 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 835E53F4105 for ; Wed, 5 Aug 2026 21:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965638; cv=none; b=ICmjtdxkQOtAtEMDx+jjaV/IhvH2Ow3iiLNVqF4nUSTXVMxly3GWh9Zw0v4m+A+6uHfwrepcMCFIX7qsOFYe6ieeRHWqK4DJvNTkjq2IG0wzPKTHwFB3xEosiESLUzj6bPJcgrtKTkLA4Q8WFwNbhq+BzvkVgZl7uYk6d2HywFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965638; c=relaxed/simple; bh=rEQB9j55XQ8igGPwemfS3N0gbAPOlhN3CcMoZha5xDg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o52XD2/0yd5f/GMbhY3iz1U0QDmIXUFEEvloHQo59zl5XRns6b9JcvEpyjc0BKAHjZ3om4cUIx151fn9X4Y1Vi42VH9TDqn6SdHQy/2WUQn7MF7f2VD6GhPikgPq3SyzDIZiqJ0j0R08KYl0ERXVlqbSoVh8lu9EMOnLS8X2bFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CP5DoTvD; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CP5DoTvD" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4956d1d9fb2so1348565e9.0 for ; Wed, 05 Aug 2026 14:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785965635; x=1786570435; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/sTTgLUY5GPNw6xzYiSteMCin6Bg9dthb3pni8zICBQ=; b=CP5DoTvDtUDS9t+rLHwHFXVMSzm6e7i6meibzfVrtZcJFit3uglaYOT8ge0uWNtFYO X1u4VJi0AxV/ZG7mm23K3oJKB1q4/X6auSzxaWNgxRtxHfScfzXGnl0nzjD+F/7i1iS0 T8vZ5CFBII4CmoinhVLuQlqX8qwyo5yNzLejnQB3HpfLx0JYSRwErU7MAA+HvCkTwrdF 0mxIb1y4WTlev5Xg4BO024EtKQYHchlFUePgnGEb+Jyj+JQBzQPyR2yoeKmjkOCAIhDa N1RyOfvn5f9/cWIxs7mAFZXpc2wMoCJw+0dOe6+TWrgB3h5Qp3GQZUa/ZW6wM76DO32u wvjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785965635; x=1786570435; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=/sTTgLUY5GPNw6xzYiSteMCin6Bg9dthb3pni8zICBQ=; b=PhMWgzFtjt7lUqM9pc7XIq7MugZ60pVpp6pDZjRAQyIwNPmLXNoSaugetEKdcdqQNV lYLEcTqvsNRlVQuEMFjmNrq9cWplzjQCiYzrvF01KlwCQt2a0D7Z5Gq5EtOiOuT1yy77 NcCLUPde2z6MqFGLuxBEdvSwkWqKnBet6cj2d3jUiwxOunjwk5D3i+hu+9GQxiqR1gIx WaltHpnuTrhH+3ria1DNMMPsqL3Wbe6jDI+ROfgDzddHBPANWH75sfDRW0hxKPXbqQLc lbERZbVzEonf78HnQstydQzqj9JctMNSZJBqSvbAPcTGEANr457gZ3+r4SDnzJj60vtK cqDQ== X-Forwarded-Encrypted: i=1; AHgh+RpP2vBfArwDyu2CVkN0q/+dI1OIrK/uU7K4MiINKj8itC24BVkjHYmzekg81RgT2suoN+KZ6fBFp/Hp70k=@vger.kernel.org X-Gm-Message-State: AOJu0YyEyjasJfn9sqfe7KaXb4IaF16LT8PWbPFGjrmXoFBAJ3bdo6Wt 1fdYfczTyUGzCb9v1QC9/GKFT04MzRKtvKJdQY8GJ3LuVqjp68SyH760 X-Gm-Gg: AR+sD11htXqkz5Z8Qr9ow5oQrUaMooeQUIGXGDCAk23qihnPd0wxtL083DKRedCSajV vyaorKtRrkDpfZOMOtFMPXp0NJQuQ298P/1OG7iJwJOsmPITlWQiG51KfGe2IcVKSz+laJlN6jW PFNmxri5i2yy+WB8tOPXWtAcn4GRnNR/ZvKHvnujtR0KaWospT8Qav5kM7DW94ijDJifFgE64Ba /TEcjDT1LlFFaKfierzlPwGZpwIfG3K/8lMG8EDEaLGmUZWtYcElcXvrmOpP/T3cph3BS8k5xzX C17L1R5mFPL/ZWX0KBG0lbyegLWqhiNgguQsYk3QnpjC8EWNxpiM5ZjQrJAcBB2zPTVZgR6zesp mWIPuZ6ToIzeP06/qCjmQc2Lo+CjdFH0CNa80bB0yKwQq7ppA/ZAAjNCKWID8v5cyRyiKT/4pNx u7b99xCsxGtC2rEjklCDP6K28PIBZ2v7ZhQxr+BfCVFek= X-Received: by 2002:a05:600c:b85:b0:495:4505:dad0 with SMTP id 5b1f17b1804b1-4994e7ba5efmr68556855e9.2.1785965634615; Wed, 05 Aug 2026 14:33:54 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:f900]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47ff7b18374sm409733f8f.23.2026.08.05.14.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 14:33:54 -0700 (PDT) From: Gustavo Luiz Duarte Date: Wed, 05 Aug 2026 22:33:01 +0100 Subject: [PATCH net-next 1/4] netconsole: add an address family to struct inet_addr Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-netcons_ipv6-v1-1-170a35b92da1@gmail.com> References: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> In-Reply-To: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Gustavo Luiz Duarte X-Mailer: b4 0.15.2 netconsole_target stores a single 'bool ipv6' to denote the target's address family. This makes it hard to detect conditions like "no address set" or ipv4/ipv6 mixup between local_ip and remote_ip. Add a 'family' field to inet_addr so each address stores its own address family: AF_UNSPEC while unset, else AF_INET or AF_INET6. Nothing reads the new field yet. The next patch switches the users over and removes the bool. No functional change. Signed-off-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 22 ++++++++++++++-------- include/linux/netpoll.h | 10 +++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 03913302328c..d615a9256787 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -212,7 +212,7 @@ struct netconsole_target { bool extended; bool release; struct netpoll np; - union inet_addr local_ip, remote_ip; + struct inet_addr local_ip, remote_ip; bool ipv6; u16 local_port, remote_port; u8 remote_mac[ETH_ALEN]; @@ -415,6 +415,7 @@ static int netcons_take_ipv6(struct netconsole_target *= nt, continue; /* Got the IP, let's return */ nt->local_ip.in6 =3D ifp->addr; + nt->local_ip.family =3D AF_INET6; err =3D 0; break; } @@ -456,6 +457,7 @@ static int netcons_take_ipv4(struct netconsole_target *= nt, } =20 nt->local_ip.ip =3D ifa->ifa_local; + nt->local_ip.family =3D AF_INET; np_info(np, "local IP %pI4\n", &nt->local_ip.ip); =20 return 0; @@ -731,7 +733,7 @@ static void netconsole_print_banner(struct netconsole_t= arget *nt) /* Parse the string and populate the `inet_addr` union. Return 0 if IPv4 is * populated, 1 if IPv6 is populated, and -1 upon failure. */ -static int netpoll_parse_ip_addr(const char *str, union inet_addr *addr) +static int netpoll_parse_ip_addr(const char *str, struct inet_addr *addr) { const char *end =3D NULL; int len; @@ -743,14 +745,18 @@ static int netpoll_parse_ip_addr(const char *str, uni= on inet_addr *addr) if (str[len - 1] =3D=3D '\n') len -=3D 1; =20 - if (in4_pton(str, len, (void *)addr, -1, &end) > 0 && - (!end || *end =3D=3D 0 || *end =3D=3D '\n')) + if (in4_pton(str, len, (void *)&addr->ip, -1, &end) > 0 && + (!end || *end =3D=3D 0 || *end =3D=3D '\n')) { + addr->family =3D AF_INET; return 0; + } =20 if (IS_ENABLED(CONFIG_IPV6) && - in6_pton(str, len, (void *)addr, -1, &end) > 0 && - (!end || *end =3D=3D 0 || *end =3D=3D '\n')) + in6_pton(str, len, (void *)&addr->in6, -1, &end) > 0 && + (!end || *end =3D=3D 0 || *end =3D=3D '\n')) { + addr->family =3D AF_INET6; return 1; + } =20 return -1; } @@ -858,7 +864,7 @@ static ssize_t local_ip_show(struct config_item *item, = char *buf) if (nt->ipv6) return sysfs_emit(buf, "%pI6c\n", &nt->local_ip.in6); else - return sysfs_emit(buf, "%pI4\n", &nt->local_ip); + return sysfs_emit(buf, "%pI4\n", &nt->local_ip.ip); } =20 static ssize_t remote_ip_show(struct config_item *item, char *buf) @@ -868,7 +874,7 @@ static ssize_t remote_ip_show(struct config_item *item,= char *buf) if (nt->ipv6) return sysfs_emit(buf, "%pI6c\n", &nt->remote_ip.in6); else - return sysfs_emit(buf, "%pI4\n", &nt->remote_ip); + return sysfs_emit(buf, "%pI4\n", &nt->remote_ip.ip); } =20 static ssize_t local_mac_show(struct config_item *item, char *buf) diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 1c6b1eec5efd..de97f001a0f9 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -16,9 +16,13 @@ #include #include =20 -union inet_addr { - __be32 ip; - struct in6_addr in6; +struct inet_addr { + /* Address family: AF_UNSPEC when unset, else AF_INET or AF_INET6 */ + u8 family; + union { + __be32 ip; + struct in6_addr in6; + }; }; =20 struct netpoll { --=20 2.55.0 From nobody Fri Oct 2 03:03:36 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 277363F6613 for ; Wed, 5 Aug 2026 21:33:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965640; cv=none; b=MyxYoo21T6hDRqOkYroPxL5DrUjD5eNRzb1c/0GPGLk1WXmXZ481Tj3AGUEq4WrsHAbzpEhu70mN9L+zMFdwFkGKnsN2qg+I6CtsKgi9y0HLbBi2GRFZCyg7joTmXPSpCzdG4Ky5g7XZfFIFc2maX+DE0z3pg2iIu/MUnwu8qh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965640; c=relaxed/simple; bh=SRHgQ8LmhKbU15IR2LbmMBf69OalgBE8SicBaXH+YP4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lgJirdyhMfPfc9fQdt8QjkXuf6RRit3MjvfXkgu/bZ48gDe+Q7BjAZHBspB6Y6l8frjiO/0NXyTwy0pgiMF4UdLSBOOiRxo6xclhOwJB6imI3Y69FjH9RdbvjDSqaCgnIGzBp6tuNZLvaFacsSKAq1ToSOKZHnkh+QqdprCO/70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QZea0EsW; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QZea0EsW" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-49552f516beso303345e9.1 for ; Wed, 05 Aug 2026 14:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785965636; x=1786570436; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EbdaXU49sEqhlpvM9echRpxckxR5PSfEdcrSDhpIaBU=; b=QZea0EsWA1yNELazimp/mhWu+SrDu8+tPgWC2jkHY4c5HI+GBzbSnqzP7K6AfySKRc uz9JJ9Z2UqqB6CIgwaa15KPkOEVxryYFK9OyrHH1KyiuSGpDYU5n72FqvDL3341Cv8VQ O3tZrJug9zPnxmVYIIXuei111x/en8QaHtif4aTWHSQDC/LmxKgJVpyuHLzSj+given9 5fIJJrbzOzzRgOHd94I5z8tbSm3h6srZECbmQsuuGybsg1CRugYL/gIFKPEvdi+3R7Wn oFSoxX1aXMvmimxqTvv3trqmqI2IlaFC8MFtMJ1NjxHsreBucgs0OJ6AC2HZfoo/iwM8 fy3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785965636; x=1786570436; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=EbdaXU49sEqhlpvM9echRpxckxR5PSfEdcrSDhpIaBU=; b=hFZT63nmXV77ffO+fqlvXmP+B4O4ctOAZN1Um3BZ5lWqra65sQSCRIvnAO4nzdq4jv /USJdougCV+MxO8zbj0RPifvci+h9RmrQlz2D1jCJQu9IcmLSKYSaKaWq+8P9mxB3Fnt kc06ouaepBpJSRpFPdjF0C0EqvrHRmvEtVBvmBM25U2dj0ccUdhOIrgSmGvOZQHmKa94 d/n2701/EYSz/ESDvd63hfb76MdsKMidcZpX6Ln8Ntm5E5TrdBQfe7nWhnK6v3nDXntR nbiBY/V8XQO6Kyd8nG/8MOBpvYmeFqACNo6JUwGqKTX/NZjdxM0UxhvMto/oXgbv6ZBf 9+kQ== X-Forwarded-Encrypted: i=1; AHgh+RpkvbRyfQkKTWc1vBtTVa1nHV8gVjiOzZn/gwBLQV4cW1Qe9Efyamahgjj5MUfZ1aTJSSjC4LWNo2lU8tM=@vger.kernel.org X-Gm-Message-State: AOJu0YwBQL642sV2tf+Bg1Ce3M5+/HdduRwOWdu334wpw3nHJ0s3mG4L Wg3YFKBgNQ585TFVjoCsgzJjWYzPCchpXyWvKGrvBOALKZaoDCx/TXSw X-Gm-Gg: AR+sD130iFxgJj+s8XWrAkJUjFMbqmXItq4dFS8y2g/ufmIPU/A5y3+bQMThTE//qIM 8c0f/IiK/mrZU69DVgzE7srXSJFuOM6k6qLfautc0rU9rCIFa/wFyJ5cWCfwZQTTS3y/3/0bHaD 5kWdNCzm+Q1SFN2m4CafUwiy8MJnvVNw3cT8q2TVW/mQCxL0+jlfRmfrmII9nHBbzONCnmsux/z 4ow4XrcU8WbIHQDMbhs21FkqA29FUxQXRCxaFU0OOXEkR6gLf0gsw4C+RzMHjKMOBrDgXvov8MB 0DtnsU0cAIg+1hle3BaWoKNH5jzVtvTqZKgZLQ/MAtiOlF/kWklkJJdm9UlzzsfGFSBB20flS8r cMJJq25wfff/OCsAZC0yCf4SfSJ8nSsp27nGphp0vizqmAwJPHsEcbuMqtmoLAdALOANNMcOwrP vYe2iLDzq0L8c2Lh8Ahm/+4hMAiMgCVaSUbaLJ6rhuSY8= X-Received: by 2002:a05:600c:1393:b0:495:650b:4c61 with SMTP id 5b1f17b1804b1-4994e7d0166mr73752165e9.3.1785965636167; Wed, 05 Aug 2026 14:33:56 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:f900]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47ff79b4bcbsm471041f8f.11.2026.08.05.14.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 14:33:55 -0700 (PDT) From: Gustavo Luiz Duarte Date: Wed, 05 Aug 2026 22:33:02 +0100 Subject: [PATCH net-next 2/4] netconsole: use the address family instead of the ipv6 flag Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-netcons_ipv6-v1-2-170a35b92da1@gmail.com> References: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> In-Reply-To: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Gustavo Luiz Duarte X-Mailer: b4 0.15.2 Now that we have the address family in inet_addr, use that and remove nt->ipv6. We no longer need netcons_local_ip_unset() to check that all bytes are zeroes, as that is now denoted by (family =3D=3D AF_UNSPEC). Signed-off-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 82 ++++++++++++++------------------------------= ---- 1 file changed, 23 insertions(+), 59 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index d615a9256787..070bae7b4fd7 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -181,7 +181,6 @@ enum target_state { * local_mac (read-only) * @local_ip: Source IP address of the target (read-write). * @remote_ip: Destination IP address of the target (read-write). - * @ipv6: Whether the target addresses are IPv6 (read-write). * @local_port: Source UDP port of the target (read-write). * @remote_port: Destination UDP port of the target (read-write). * @remote_mac: Destination ethernet address of the target (read-write). @@ -213,7 +212,6 @@ struct netconsole_target { bool release; struct netpoll np; struct inet_addr local_ip, remote_ip; - bool ipv6; u16 local_port, remote_port; u8 remote_mac[ETH_ALEN]; /* protected by target_list_lock; +1 gives scnprintf() room for its @@ -463,23 +461,6 @@ static int netcons_take_ipv4(struct netconsole_target = *nt, return 0; } =20 -/* - * Test whether the caller left nt->local_ip unset, so that - * netcons_netpoll_setup() should auto-populate it from the egress device. - * - * nt->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 =E2=80= =94 - * 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 netconsole_target *nt) -{ - if (nt->ipv6) - return ipv6_addr_any(&nt->local_ip.in6); - return !nt->local_ip.ip; -} - static int netcons_netpoll_setup(struct netconsole_target *nt) { struct net *net =3D current->nsproxy->net_ns; @@ -525,16 +506,13 @@ static int netcons_netpoll_setup(struct netconsole_ta= rget *nt) rtnl_lock(); } =20 - if (netcons_local_ip_unset(nt)) { - if (!nt->ipv6) { - err =3D netcons_take_ipv4(nt, ndev); - if (err) - goto put; - } else { + if (nt->local_ip.family =3D=3D AF_UNSPEC) { + if (nt->remote_ip.family =3D=3D AF_INET6) err =3D netcons_take_ipv6(nt, ndev); - if (err) - goto put; - } + else + err =3D netcons_take_ipv4(nt, ndev); + if (err) + goto put; ip_overwritten =3D true; } =20 @@ -716,22 +694,22 @@ static void netconsole_print_banner(struct netconsole= _target *nt) struct netpoll *np =3D &nt->np; =20 np_info(np, "local port %d\n", nt->local_port); - if (nt->ipv6) + if (nt->local_ip.family =3D=3D AF_INET6) np_info(np, "local IPv6 address %pI6c\n", &nt->local_ip.in6); else np_info(np, "local IPv4 address %pI4\n", &nt->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", nt->remote_port); - if (nt->ipv6) + if (nt->remote_ip.family =3D=3D AF_INET6) np_info(np, "remote IPv6 address %pI6c\n", &nt->remote_ip.in6); else np_info(np, "remote IPv4 address %pI4\n", &nt->remote_ip.ip); np_info(np, "remote ethernet address %pM\n", nt->remote_mac); } =20 -/* Parse the string and populate the `inet_addr` union. Return 0 if IPv4 is - * populated, 1 if IPv6 is populated, and -1 upon failure. +/* Parse the string and populate the `inet_addr` struct. Return 0 on succe= ss + * and -1 upon failure. */ static int netpoll_parse_ip_addr(const char *str, struct inet_addr *addr) { @@ -755,7 +733,7 @@ static int netpoll_parse_ip_addr(const char *str, struc= t inet_addr *addr) in6_pton(str, len, (void *)&addr->in6, -1, &end) > 0 && (!end || *end =3D=3D 0 || *end =3D=3D '\n')) { addr->family =3D AF_INET6; - return 1; + return 0; } =20 return -1; @@ -861,7 +839,7 @@ static ssize_t local_ip_show(struct config_item *item, = char *buf) { struct netconsole_target *nt =3D to_target(item); =20 - if (nt->ipv6) + if (nt->local_ip.family =3D=3D AF_INET6) return sysfs_emit(buf, "%pI6c\n", &nt->local_ip.in6); else return sysfs_emit(buf, "%pI4\n", &nt->local_ip.ip); @@ -871,7 +849,7 @@ static ssize_t remote_ip_show(struct config_item *item,= char *buf) { struct netconsole_target *nt =3D to_target(item); =20 - if (nt->ipv6) + if (nt->remote_ip.family =3D=3D AF_INET6) return sysfs_emit(buf, "%pI6c\n", &nt->remote_ip.in6); else return sysfs_emit(buf, "%pI4\n", &nt->remote_ip.ip); @@ -1219,7 +1197,6 @@ static ssize_t local_ip_store(struct config_item *ite= m, const char *buf, { struct netconsole_target *nt =3D to_target(item); ssize_t ret =3D -EINVAL; - int ipv6; =20 dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { @@ -1228,10 +1205,8 @@ static ssize_t local_ip_store(struct config_item *it= em, const char *buf, goto out_unlock; } =20 - ipv6 =3D netpoll_parse_ip_addr(buf, &nt->local_ip); - if (ipv6 =3D=3D -1) + if (netpoll_parse_ip_addr(buf, &nt->local_ip) < 0) goto out_unlock; - nt->ipv6 =3D !!ipv6; =20 ret =3D count; out_unlock: @@ -1244,7 +1219,6 @@ static ssize_t remote_ip_store(struct config_item *it= em, const char *buf, { struct netconsole_target *nt =3D to_target(item); ssize_t ret =3D -EINVAL; - int ipv6; =20 dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { @@ -1253,10 +1227,8 @@ static ssize_t remote_ip_store(struct config_item *i= tem, const char *buf, goto out_unlock; } =20 - ipv6 =3D netpoll_parse_ip_addr(buf, &nt->remote_ip); - if (ipv6 =3D=3D -1) + if (netpoll_parse_ip_addr(buf, &nt->remote_ip) < 0) goto out_unlock; - nt->ipv6 =3D !!ipv6; =20 ret =3D count; out_unlock: @@ -2067,7 +2039,7 @@ static void netpoll_udp_checksum(struct netconsole_ta= rget *nt, =20 /* check needs to be set, since it will be consumed in csum_partial */ udph->check =3D 0; - if (nt->ipv6) + if (nt->remote_ip.family =3D=3D AF_INET6) udph->check =3D csum_ipv6_magic(&nt->local_ip.in6, &nt->remote_ip.in6, udp_len, IPPROTO_UDP, @@ -2108,7 +2080,7 @@ static void push_eth(struct netconsole_target *nt, st= ruct sk_buff *skb) skb_reset_mac_header(skb); ether_addr_copy(eth->h_source, np->dev->dev_addr); ether_addr_copy(eth->h_dest, nt->remote_mac); - if (nt->ipv6) + if (nt->remote_ip.family =3D=3D AF_INET6) eth->h_proto =3D htons(ETH_P_IPV6); else eth->h_proto =3D htons(ETH_P_IP); @@ -2177,7 +2149,7 @@ static int netpoll_send_udp(struct netconsole_target = *nt, const char *msg, WARN_ON_ONCE(!irqs_disabled()); =20 udp_len =3D len + sizeof(struct udphdr); - if (nt->ipv6) + if (nt->remote_ip.family =3D=3D AF_INET6) ip_len =3D udp_len + sizeof(struct ipv6hdr); else ip_len =3D udp_len + sizeof(struct iphdr); @@ -2193,7 +2165,7 @@ static int netpoll_send_udp(struct netconsole_target = *nt, const char *msg, skb_put(skb, len); =20 push_udp(nt, skb, len); - if (nt->ipv6) + if (nt->remote_ip.family =3D=3D AF_INET6) push_ipv6(nt, skb, len); else push_ipv4(nt, skb, len); @@ -2513,10 +2485,8 @@ __releases(&target_list_lock) static int netconsole_parser_cmdline(struct netconsole_target *nt, char *o= pt) { struct netpoll *np =3D &nt->np; - bool ipversion_set =3D false; char *cur =3D opt; char *delim; - int ipv6; =20 if (*cur !=3D '@') { delim =3D strchr(cur, '@'); @@ -2530,16 +2500,12 @@ static int netconsole_parser_cmdline(struct netcons= ole_target *nt, char *opt) cur++; =20 if (*cur !=3D '/') { - ipversion_set =3D true; delim =3D strchr(cur, '/'); if (!delim) goto parse_failed; *delim =3D 0; - ipv6 =3D netpoll_parse_ip_addr(cur, &nt->local_ip); - if (ipv6 < 0) + if (netpoll_parse_ip_addr(cur, &nt->local_ip) < 0) goto parse_failed; - else - nt->ipv6 =3D (bool)ipv6; cur =3D delim; } cur++; @@ -2581,13 +2547,11 @@ static int netconsole_parser_cmdline(struct netcons= ole_target *nt, char *opt) if (!delim) goto parse_failed; *delim =3D 0; - ipv6 =3D netpoll_parse_ip_addr(cur, &nt->remote_ip); - if (ipv6 < 0) + if (netpoll_parse_ip_addr(cur, &nt->remote_ip) < 0) goto parse_failed; - else if (ipversion_set && nt->ipv6 !=3D (bool)ipv6) + if (nt->local_ip.family !=3D AF_UNSPEC && + nt->local_ip.family !=3D nt->remote_ip.family) goto parse_failed; - else - nt->ipv6 =3D (bool)ipv6; cur =3D delim + 1; =20 if (*cur !=3D 0) { --=20 2.55.0 From nobody Fri Oct 2 03:03:36 2026 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 803D03F328C for ; Wed, 5 Aug 2026 21:34:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965643; cv=none; b=sEJs9+4lKv5KpMpRNgMVRRgow/m4WPxBCrTZc7ZGvR19HJ7esFUNFtTxvzeVEpAoAQjxWDR+VXzl2JmBbXfH7vA5SP9HlPjwlVVbcj5qlia9AgoYPTmj8obDdMu3Xgn7vt1KdCzZWmt3bwFVGRiE+qZ1p2XmYNMoM0LhRVYKJAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965643; c=relaxed/simple; bh=3h1H6/5bkUMyJ+rgH68Twa/JWbPZ0mMggnwjy3rrOhA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kwkzu1efOCadLTkLb3fw7zyvCfIonsEKqtMx4tJbIp1RWypZSwrnH8TWvcERxlEB9IIoUkU4swqpcH2v1fWetUreDd9sLaI95YWxD0WDNdvp96VrL0txpHXMB3mFYEiXo9AmFujeXb38Q1EFxHrmyVpGo8qcIlfwcFsYSiybKOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I9mNpbWJ; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I9mNpbWJ" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-69848c9462aso212869a12.2 for ; Wed, 05 Aug 2026 14:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785965638; x=1786570438; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wIL+DgBYUTpJ57QMSvObczLCrJeLPUMZswlx2+I7z/I=; b=I9mNpbWJylgedLjOHFA8Ns+GDzFGoiMFD/XbBCLTFAvcSELZuiAqQNRSxm6N7ixjYR UKQEainfKSNvzN2X23BavZH0XSLcs7IgBgNj0PRXPixfEo+7UyB1Sn8PlhlQ3YVR3mMh w/FdZ1PxokdlgBR74z2kwtqc7n4W2mgOyU3tC0axItfgQHSfb463QCE2iuCWAvHYreqc 9KbRmeRanb/jUGbruv1YimU22AsI8gqVQayr3262f+yKMhgpAijpeEKKZfhIx73Xf/JN p4RnDfpYBm1Qd6DVPl8YNRra5XxnD6sWI1UhGNfDMHobAc+pRRxZbqBuGqYvyLhMist3 eRmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785965638; x=1786570438; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=wIL+DgBYUTpJ57QMSvObczLCrJeLPUMZswlx2+I7z/I=; b=P1raAXkB9dvviJWRCNOeNLA01FaKJUjxEuRm6Z24CgT1U5XlLlySUASBX2qfC9ZShH CRv00QjxXsFiyvWEpC3iAEtFMDNv6gd2tqs241ErBB7cf0Dii/cxZiJEHp+jrVzyjK5T vLY/a6sp+ExEWoELhDKPrnRtm9FQoP+go46Koi93p7I/dgcNgCo3/gvjZia5tN7rQ4yg aTRoQiY3xeeEE3N+4/FMfDyEbqDHWoLDBCyiUemVA9UBMFXT3BOl0+7zOzH4a0UlhJZ3 qyJ3CKHy0sMt1L5mHDzC4uPPdFGP3hj3i8egi2shghlhA5PSszsPqeQdmc7Y78XpwBSM XOkQ== X-Forwarded-Encrypted: i=1; AHgh+RpzC8qstQ8qj5rgQQw7A20Wq7/A8E2GMJ+TFxcZSXzxz6B37JMHJ43gYVKCWvswSMhTNXmL0tZIkCpJ2T4=@vger.kernel.org X-Gm-Message-State: AOJu0YzKTFOBsmLo/rnyljnRo2JmDzE9+F8WwbaD6niG0NiaM/cVoidW k/gx9Nj2ubBDTCvmV5Q/eh74jTcR/7210VCxuB5DMj0DCaM3BPftwkcB X-Gm-Gg: AR+sD11DzBSrD1s2Egtge5Md92+ValqekQcmRwzc64yAwLK1N8/E+HkCQ6D2ZNucEwq sKmtBahONEGuimM5O6WFXGPuhgkYwze4GOvItKP+abZnNsyU04vEW7b19CBAOo1EBx5hYclnDL0 +fcqDY5syTyoxIhAJD+m6qWy/pI1+9ccSLXlOoD0I4nS1uC3bDB3jew9q+osFr8nwnrcRfT39Z0 X1PGvPI6jlCrZQycDIAplPEFKKtFtCVdAsK0ryCvvHBSxs4J8ZEPGrx2p203L/zZGKT2fpkwqmY 0fHv7UmMzRjw//AmxKMXU5Yvw/3qdCJO0M7+U8+AM/w5ri3AJBH7iJ/kYr/Hy3yIEk2s4N+9B6H BV5n9215kl+OF1+29oXqISK/75dNsF3GwFUA2fQl4hidVGJzz/E+8in6x/mIMjpjynWPJDiSDPV 7Lo2Vvs5NF8KqJJ2cutE76Ep+5zj5nfAeTCXUUE5pzq5E= X-Received: by 2002:a05:6402:4509:b0:698:8785:650 with SMTP id 4fb4d7f45d1cf-6a14f0e0c47mr2906037a12.1.1785965638477; Wed, 05 Aug 2026 14:33:58 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:f900]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a196420794sm50844a12.24.2026.08.05.14.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 14:33:57 -0700 (PDT) From: Gustavo Luiz Duarte Date: Wed, 05 Aug 2026 22:33:03 +0100 Subject: [PATCH net-next 3/4] netconsole: reject enabling a target with no remote IP address Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-netcons_ipv6-v1-3-170a35b92da1@gmail.com> References: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> In-Reply-To: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Gustavo Luiz Duarte X-Mailer: b4 0.15.2 The command-line path already requires a remote address, but if a user creates a dynamic target and enables it without setting a remote address, we currently try sending netconsole traffic to "0.0.0.0". Refuse to enable a target if the remote address is unset. Signed-off-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 070bae7b4fd7..a41b0a5ce64f 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -471,6 +471,12 @@ static int netcons_netpoll_setup(struct netconsole_tar= get *nt) int err; =20 rtnl_lock(); + if (nt->remote_ip.family =3D=3D AF_UNSPEC) { + np_err(np, "remote IP address not configured, aborting\n"); + err =3D -EDESTADDRREQ; + goto unlock; + } + if (np->dev_name[0]) ndev =3D __dev_get_by_name(net, np->dev_name); else if (is_valid_ether_addr(np->dev_mac)) --=20 2.55.0 From nobody Fri Oct 2 03:03:36 2026 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF5AA3F58E9 for ; Wed, 5 Aug 2026 21:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965647; cv=none; b=oD+kAAof6sU4Kn61BRP9S5z7+qeJ6eululNPsQQi2cj+9/XBf0rXFJueja+pF9wtygTY7xYdyLkw4To3jQbyROij2h8kyOvDfs/P8u5FjRidz7Ilby1QNcWrq2CDgwgR4HMJYGLHv3CBxTz+hCd1M3YNghonOAyLH8KgRYKfjvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785965647; c=relaxed/simple; bh=FGgluiktpHdf3B4SPyK+DId9DH5gItlJ0mTuiRzLNSg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oXFWGTRfBuaUzNN9RRjlZwnIJBc5XbZ/8aZB4zLkGc9wifdy6Nt8ywhWyDfw94i7zfmly69y48+a8LF6c/OmgzT1h8O/20ASTpnfewRMcT+es3btKq1PGBrL7PVuEjgGIbNAE1G/aYFMNw/tb1vagXDatfBc38dvhG7+7gD5jfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QAgeCi0z; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QAgeCi0z" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-c15c1f1be0bso15914966b.1 for ; Wed, 05 Aug 2026 14:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785965641; x=1786570441; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rJHHerLHfpSc4Hf/fzZ5kWsOzDljmksdIXKZK1qFD5I=; b=QAgeCi0zykHYWkEDvFfWwGt2YXsXKI+SCXMGLlRjFPTTnGZe7OS+OhL5flID1gTW4D bJ0L6y5PruCTU5NJqV1UtikwkbBwMazT7RIM1G2oFTCVTGGH5S01wCkHCI9uUD7OuE62 TSZtkjFgSlER0tmnlN2ZjiEtsm/0Jh6I9s4h+SwQjuh7PreFzJhS8XDsdk2Y9e8iSil8 bBotn+4c6SA1orvH7N88+5I4Q/N15vrqBBkCOMgxRYQvZHGBnUs9hN1JCKv8k22/E20l Y8bEqKLJuiTQQp/mRhAlqThm4UmUinXQ4olD7IoZGzkKg6m3MVPkDM7ZztyXzLuY1oM6 HKPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785965641; x=1786570441; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rJHHerLHfpSc4Hf/fzZ5kWsOzDljmksdIXKZK1qFD5I=; b=CwQPBCG8BjcvoViKdK6O6KW1N0k6TEOJ5Ry2dygJDJJvG2ATRggn4Mo2gymut3yEpZ BNuvfNYSnynhtUsJlQ6AGFEhEyyqdoMNp+MLROKL0tILD43k9XEaYOt4r1tkvMyA8aMU 9n/mL6wXOcswmk0V1/kItfuErLhcqavwQfzlORt6x6nCSs3qnAKz/EMMRe/+c0x7mJJb tFAt9YCzw19+F5lFtqdbybi42qbKLbTkao8uBSN7tSto9LvDuO0qTOknVk/bfRDqXsYM mc0Nj6veuAtPe30ZVET4JGJWXZwoxjTvZ9q2XYfHwwX2TfgGhRuK3z2OO0aKnr7WriUj L4Fw== X-Forwarded-Encrypted: i=1; AHgh+RpRnYXr8JWYpAIHqO1/34LG9jmVwhcx1tLrX2K4lDHatopmEp2mYtcOnDiOI7lSUWD8pNUqDRSHTb3B7qc=@vger.kernel.org X-Gm-Message-State: AOJu0YzOCK++D1PySCLiJYu9t5OLRgVn753ZjozHAWDfGNoOF2UZR694 L1k4ABMSnfAFIH5WduBwx/DA3LkUhsEfPpKL6GeWErwayr97oNUECNrH X-Gm-Gg: AR+sD12zr2zGBrtq37vb1jqtpZyBRvl0C+NqOhVDiWaw45d0h3hCbsmIQO2cXXnCipD kh/pIemNQ8qCviqtig3QQ1DYDfbFYBMBWc8i97Ytuxs7oZUvtF8VYCrc7MvS08pasx5ZkRjMcG/ Dz2/CRE9UPGksKqTZnVF8eTk1WbySfmRXmUvPw4pI8HDh2WoMJWkZ5cy4qEZKd4KBytigpH+mE0 0ovsqZX06hjzR/ISEZZ2b0qx2czxp09r2ow+sTsK1lY+1G8aHK9qJBf4VEyDck6xmL+7UTo4QyS NDxnGNtvGdOXwUGrkVBCFw3oreQQrgec9vUa5D5e5CPybWsJ63PZXN+foXyDRw5Zy3bdTy6nFG0 i4UV7JYgYfsjY+mNgW35uUQcQFZvJhIBgt+5F49L2CBp2jywC0SAsdpl7OeHHpqdSkhHGUypzB/ as7QiLfN8aFUaoP6LLBJLAkIEyYiyg7ScerO8nq4lgqiY= X-Received: by 2002:a17:907:60cd:b0:c15:e0d3:3fd8 with SMTP id a640c23a62f3a-c2039f1442cmr252854066b.3.1785965641011; Wed, 05 Aug 2026 14:34:01 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:f900]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2036428e08sm179836366b.48.2026.08.05.14.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 14:33:59 -0700 (PDT) From: Gustavo Luiz Duarte Date: Wed, 05 Aug 2026 22:33:04 +0100 Subject: [PATCH net-next 4/4] netconsole: reject a target mixing IPv4 and IPv6 addresses Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260805-netcons_ipv6-v1-4-170a35b92da1@gmail.com> References: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> In-Reply-To: <20260805-netcons_ipv6-v1-0-170a35b92da1@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Gustavo Luiz Duarte X-Mailer: b4 0.15.2 The local_ip and remote_ip configfs attributes are written independently and nothing stops a user from mixing ipv4 and ipv6. This leads to an ipv4 address being zero-extended into an ipv6 header or an ipv6 address being truncated to its first 4 bytes for an ipv4 header. The command-line parser already refuses such a mismatch. This adds a similar check when a dynamic target is being enabled. Signed-off-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index a41b0a5ce64f..69621705d68d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -477,6 +477,13 @@ static int netcons_netpoll_setup(struct netconsole_tar= get *nt) goto unlock; } =20 + if (nt->local_ip.family !=3D AF_UNSPEC && + nt->local_ip.family !=3D nt->remote_ip.family) { + np_err(np, "local and remote IP address families differ, aborting\n"); + err =3D -EINVAL; + goto unlock; + } + if (np->dev_name[0]) ndev =3D __dev_get_by_name(net, np->dev_name); else if (is_valid_ether_addr(np->dev_mac)) --=20 2.55.0