From nobody Tue Sep 29 08:22:55 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 593CE36403C for ; Mon, 10 Aug 2026 16:47:46 +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=1786380468; cv=none; b=DHNzHYsjY4FZOvHywIyhfrx6YePc1DE6CQsvNXxm5KCyHt4orZ/HYKZ5W5/1qjYsRWXw2j5gDhRLncWwwNd890tWS2Qb3tNSAtGMIt5RceRRdqAEftMh+CMW4ycVGPv4VMOGR27mghK8yoJWHTJ2HLmLOptjdvTvxaZdZSgkHGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380468; c=relaxed/simple; bh=Oo8YmQRgiTmOCrg5RSPtjsxDBofKu2mN03t7WY6Z2+4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s7FH3WPo7WMsYVJ2DxTvFoCFDTSImMR4hnr1oydcJ3tRXxhkLcB8rjiUPzMXQN+heyex2HvI8hT/nxwZkY8T3uP5a2t2Sd3xyPqCuS1PdpUPrQEBiiW/7/x9Uz/iS0iafcs1nA9PNp6z6cijELVsjxWdVLYuEMX6995ujp9vQcU= 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=gMcNi4Wz; 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="gMcNi4Wz" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4954c08a7c8so1312945e9.3 for ; Mon, 10 Aug 2026 09:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786380464; x=1786985264; 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=QUij+bPWme5H0Y1xcQFrN7EqbdY3sRjm1DhYj2MYjvM=; b=gMcNi4Wz7fBtCNSs/+e9evIxHqSu0G/E/Q1Lvukza1FV6WQj9PGg3nD/V/CU20bp2Z R8IyJwA9sjnlmaplVI3nKTMCf3x8xT/iguxeuU5ZpVcccIFHUUpV7nWiZZhobiRsjF2m n6Z+nFUkRZNMsUYJRu4U5XO69bLlOb3K1M9HP7ACvXJJ03hQOxamA1qHp59rjzzvR8KP c9rwUmv/b3Tua/yvs312FDI+We5OfGEsR6U+OnuIfa60oGkvnWSYXnFr9exbD9Btd9Jv gBzxNY3oFPOVXnH0u7t9vN6Psg5b6+6eA42U+xam35L0imfUGhC9+7alBJ2xdXcjYWQo sIDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786380464; x=1786985264; 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=QUij+bPWme5H0Y1xcQFrN7EqbdY3sRjm1DhYj2MYjvM=; b=MWNdKW6lnYgarMuOWu1MJh1o/GmNfHdCxtp9bXpfSZ+s+raJBf6rW9bVqvxtaU67MC hfySxPxBpbGRHcvSPIYUz0j6sVMRoJLBc5FAeGQza6g0ZyQjE0Pw+X20kZmZvnmLv7Hb otzFSr18PkX9Cu0SVPglvPqm3awJW77pCp+pdQXRz7UyYTd0FvD+B41565G+3ApoH+Wh OCEcmgWoI5zFAnpToDBSC0ZZT5sqHB0SwGtV6ZNN2e3ENTdv8/5GaUa/yCp/snJgrb1B 3cO5WqpQnx9fLJAZpSFGCaaipNv2mC8oibT0h2NqWV3MvsobgKdyQpWLfSrNGkY9JafN rx4A== X-Forwarded-Encrypted: i=1; AHgh+Rr3N9d3yGUWW3zky7NAKSZzUcQoQIcWLfyd+NDeI/LRl8oGF/ojscGpqzqsxyLFwr2C0RpxpYvS+zfqI2k=@vger.kernel.org X-Gm-Message-State: AOJu0Yxq3CbxU0Po2YD8XM3mwXgtv36L+I3yxy3yV+UShntB1g4uFFXw 6aUcPjnHuH7hPvqPVJ6Uf2ySroqb/+8/orvkr10xODLELRk2Mx1aamgB X-Gm-Gg: AR+sD10piiGsJoTfFiLoZ4/ibDloK86D6p1R58a7v5yo5HoOrSeS5Tg0AAGjILb6GpJ NSyK0OQk0MiDGei4+bF+828YHeIcE7dJxW+cIID/2GJp0XaUYi/p/8Wj+LVF9GuJ076GRxle7IY Ttghp5XT6isbK7VUWLit8QVOkzT1k/ow4+fYEhucA6FP3SkkOAcGMFhKMSrDex0lYAE6IeN/pht S0GyWBXlDt+Xn/ttAAE3VbgsAjoiKKM0zN6PKDNnJcXMrAQD21ZxJix7F8HmGy8wVXkMXwB09uP 7wtkADdKQmBO/EmqTzu0E6Jyw5WAo25iKrW6VSh3hRm1OsE2bVvva1LooaAPnNoylZJvfPzMYl/ 5XRMgQfjhP4AVW/yPQY8py/Ncd3yWU0AXdbXlrEHxDt9Dtiek2WGIMNy2vQGizZ8EpjNZqz4+B1 Pufz5mm/3JJU5B4N5d8StaGzC9KDf+7jjXIVYgTK/ux2I= X-Received: by 2002:a05:600c:3b14:b0:499:5b0f:72b with SMTP id 5b1f17b1804b1-4995b0f077amr185982305e9.1.1786380464356; Mon, 10 Aug 2026 09:47:44 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:692b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499740c46efsm5426185e9.4.2026.08.10.09.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 09:47:43 -0700 (PDT) From: Gustavo Luiz Duarte Date: Mon, 10 Aug 2026 17:47:25 +0100 Subject: [PATCH net-next v2 1/6] 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: <20260810-netcons_ipv6-v2-1-3d4fc987a90f@gmail.com> References: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@gmail.com> In-Reply-To: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@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 Reviewed-by: Breno Leitao --- drivers/net/netconsole.c | 24 +++++++++++++++--------- include/linux/netpoll.h | 10 +++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 03913302328c..94a662c7369a 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; @@ -728,10 +730,10 @@ static void netconsole_print_banner(struct netconsole= _target *nt) 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 +/* Parse the string and populate the `inet_addr` struct. 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 Tue Sep 29 08:22:55 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 4EE0A42C4FD for ; Mon, 10 Aug 2026 16:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380470; cv=none; b=MF4rR+K2cwG0RcLch01ykF7z1OXvoS0YNFU8BRKGiqs86cwNaYHImjzvSfI+7K1uV6Qb2UxXv97Euhe3gJIyo6SCVocy2xcsJEbEV6YwtOxijkyocvOCId3u85qAjIsDEh8vVJIGORMTIikQk4j0oiVtkWdbh88lPqyHFTHiSA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380470; c=relaxed/simple; bh=cpY+DK8gqI4J4uNkwtOBFgqQE1dbJzW2yuwhWHHyOb4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XXVRmkhDnoBEC9QRCth9uiUREYPp7WUqkPN6BaFC5nenVBFHd2xl4wpfcHD6Ul1P7bVglYHtkJQGvx7fo49lgEhZSxTu6iNCEps7/rGOz3J9xvkg8td+26qW5PkpoR4IO7tNUxihGE4XAxvbiC2ujxhi8oRi75e7r8MZYGFG8VE= 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=YjW9HW1L; arc=none smtp.client-ip=209.85.221.45 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="YjW9HW1L" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4731f5ffa74so166606f8f.1 for ; Mon, 10 Aug 2026 09:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786380466; x=1786985266; 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=bvt91xN9n0oGfvLTCrwPfmjNKYb15JHWKisk1UsqQAA=; b=YjW9HW1LEft1jDnM75Wzlsv76CmT+PIxJI/pHC4iELExYIuqBuoOAYVMBCNzWFKwaF 2L25q53kvywNj1LRfBz+Lvyxon5KD7uj5UzXX+CRA+JRB7DTFVdRQ/mEGp6gxOobs+7l /KmNk/Q9IOH9Hbv9Coire7orl841X/wByrnrLiw7GeT63+0eTPCaBfkbJOBOdAGd485u XS8/MQea4F+mPZlvUcVkKlZtdgXeURvBJH8dbkjTHwrpH1F751q8AdN4NLEdG2/pLeFL 7818nztMpesF7A7v24TM2S7fSaBEGvjqV8YlxXP/lYbulgleQ1c5GXQbiOeQncJOBb3Y oFZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786380466; x=1786985266; 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=bvt91xN9n0oGfvLTCrwPfmjNKYb15JHWKisk1UsqQAA=; b=L5AU6WH33hMzVOcv1mwLSb3ZvuY2nZFHkEFn+gDAEDwILp6uCmQU/0wNvD1Vz9Bfnw z6waQTfQEy1NOd3t8BqY08CUcWFatk7/44O5ZeSfqm1HYx+f5Rtf+aTKyzH15KlXa8x/ HDZ2szK88iuCBPeYP4gdmgdXixqiSMRs+ZF2sSHJszZwBnnOiNYddiPcV/a4vOUqOY1B RQHQYLGox4E4aVl4ajph6SW/gNKMuetKOJRGT5tHz17w1tfSzipn5AlhWugHMOMVyceJ IUEvrs73zM5qZEHoaidTa8+UJqIrr0H8Mvi30/lMbM9NlM4Uq3/3SmG1uUgFVoZRoftX jkDg== X-Forwarded-Encrypted: i=1; AHgh+RoopKbQYKmpr54uZ9kf/xRadB7EkhI8BM03hGjxbIYqMPPWM+UtfP5rPBzEDAHfhkChpMsP7CVBdCl3XLw=@vger.kernel.org X-Gm-Message-State: AOJu0YwM8HN1CiHBEd8i5oyVL4WlHcQiW6NCoKVuuluZv/SzCU4lzIo0 iUETXRSj7caMTK8iZVsAd/bhZ6pyoNhm7zZYeRURo7httT0GOvtlXSTa X-Gm-Gg: AR+sD12aQJcrGxV3I9ywUeBGpMLRZvJvN9jq2xtmopFmwMRoXJ7AKDONE+e1J/DudYF q4VodmAYA3V+9x7P97JBLL+RCBkXzsYL63HFurH6mpS9x+unSvbSCtw2XlYp40QOr+p+YPr/v6+ cb9RoUG59p3EKxsdd98tHKytrKT7sZy+2h/4xVWzCKzlnbLVi8KqtSaTQQ2WKVFVF8n09/g3/bB SVWdiWDW52QqUMMr1+dYCWgMLIWCdCbsQya4LGeCW3FrELVm6L+2RqZh03b3WyAuvW45H4ElaRK N1uZaqCnA2NStgo2PcXwhGof39ma9JpVAeNVvx7Xx4ZiEv7AuPA353Z6Gzw44xbCUJRofhAg6Z9 nacxxSNizO0J/XKLBAGoITwRrgfZZ5WjzUfKbN53Or10+a7h+jWnzYccc4/V4MC0BPr0bcX2Wb/ RtTCzJ0+l5AHgmnv4CGUD7MyKPHxo7MhHBihHQiKWG1IDNYtJ3W7LZNQ== X-Received: by 2002:a05:600c:3594:b0:495:4126:1e55 with SMTP id 5b1f17b1804b1-4994e7bd084mr293278315e9.2.1786380466115; Mon, 10 Aug 2026 09:47:46 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:692b]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499740c1f61sm4713355e9.5.2026.08.10.09.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 09:47:45 -0700 (PDT) From: Gustavo Luiz Duarte Date: Mon, 10 Aug 2026 17:47:26 +0100 Subject: [PATCH net-next v2 2/6] 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: <20260810-netcons_ipv6-v2-2-3d4fc987a90f@gmail.com> References: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@gmail.com> In-Reply-To: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@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 Reviewed-by: Breno Leitao --- 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 94a662c7369a..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` struct. 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 Tue Sep 29 08:22:55 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 E4C8441A554 for ; Mon, 10 Aug 2026 16:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380472; cv=none; b=UM6Z2w3OyKnsA8bMoGAjQSiFNIHanCS3/Sb1QdAGIyGCB6GtKg6VC08Lwjp2M28Dc7Z7ehxqz7dK5XqFXLodCFSDQuON+Z1PFt19TUppJfLM0SmVNsSeqirg30SfzrRExsh6xcY2Unkrd7fVN+c+I4RH1PoyzWojPWZV/LOgo18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380472; c=relaxed/simple; bh=1Ix4cH5WpoP0sr0eZNs4ONQeMfV1yLSYSj7etDIUkHA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hyX6aGoYDyiNHH/bl/qby0i1uH7nex9zixT0DfRqzNrOeJHYkL7leF/3Cp0p/hqy7vOV7IVs4NvHRQfnJF2eoHMTRQF8iA2W9x7iBtRr9rbFFFYoNE+IUHlgYTeYb+dTp6JUS6Wo9W8gZ4fELqsdoZtLclQVxBfkSURcws0Udww= 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=YzF/6isy; arc=none smtp.client-ip=209.85.128.46 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="YzF/6isy" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4994d41ceb9so3274985e9.2 for ; Mon, 10 Aug 2026 09:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786380468; x=1786985268; 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=LOT5/upoFX5/j7dRMQa+9jiolueDHmK+W74PXWUhiTk=; b=YzF/6isy202q2hhWrKsaDALbZM41MVRKGfbHxxNXpJ/ePCSDJ68yHZN7cGQoo79hgk cvmpc1AG6fIqnYzzJ5KmaGIl7qw92dAhScDj3WsGBJTnhFDV6mWn0CrZ2DFzQa7pIx1W XYb17Du33sskDTb0ObPbtrzzxD5lIrybRhOsifP5BKcEa0ELSO2ND2VqOalEpQta2nV6 QBXi5WysYTy9QMGlB+fIqW2RV7FvVfCRjkly8w4DgRGMbfiC24NP45+Cx8mVqDitubMk uPYlfxwOusL5bQSXzCkWAuMx/yDNSGs55OSYuLgXAYQRQdJMBv7dQ5TcnDr2JILsLKI/ QSdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786380468; x=1786985268; 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=LOT5/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dCasPpuLU1H 5F50Ea/718RDG92SANkmBw3qaPP7r5lzrnuIrPM4hIAtA= X-Received: by 2002:a5d:5c82:0:b0:481:3db3:8eb with SMTP id ffacd0b85a97d-4813db3093fmr9641910f8f.1.1786380468431; Mon, 10 Aug 2026 09:47:48 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:692b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021f90f8sm32487116f8f.26.2026.08.10.09.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 09:47:47 -0700 (PDT) From: Gustavo Luiz Duarte Date: Mon, 10 Aug 2026 17:47:27 +0100 Subject: [PATCH net-next v2 3/6] 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: <20260810-netcons_ipv6-v2-3-3d4fc987a90f@gmail.com> References: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@gmail.com> In-Reply-To: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@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 Reviewed-by: Breno Leitao --- drivers/net/netconsole.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 070bae7b4fd7..7fcdff53b3a4 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -470,6 +470,11 @@ static int netcons_netpoll_setup(struct netconsole_tar= get *nt) bool ip_overwritten =3D false; int err; =20 + if (nt->remote_ip.family =3D=3D AF_UNSPEC) { + np_err(np, "remote IP address not configured, aborting\n"); + return -EDESTADDRREQ; + } + rtnl_lock(); if (np->dev_name[0]) ndev =3D __dev_get_by_name(net, np->dev_name); --=20 2.55.0 From nobody Tue Sep 29 08:22:55 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 1AEAB42D76A for ; Mon, 10 Aug 2026 16:47:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380473; cv=none; b=rl55rXVcmlg5Czwnt7pc9BOYORfODHS1zootbTwJReGtLktsXe6DrGxjVDab7eVARZe4a90eNmlV3lEOY0TmmusmpEOwAplLFX5FDRAGA/scvXENdJTuYc3VJvJpezk6zInP3xTKjd6RN4Y7HYMxHm3/CotRkcMpqJ1gtWjg4h0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380473; c=relaxed/simple; bh=XcdFhWSjpZ8I1EIIuQNMMN7Zy0MPKSEdmoyU+VFfNMg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hcJCpOeDEgQQMhp39Ekka3Wmxai8gqWJ3nkUDSdhLM7sY4T2Gjz/Lv0aO2YWhC9qtd7AO9q+NZpuhlEpdiNCV+wfjAM6DtV+6W46giuvCyOXIFfL56cExwFlG7FpCQGbv9dlB3jEzojU8Ef7WIxTspDZ+vtH1SRFpAL+ADvgXWE= 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=WW3zCKck; arc=none smtp.client-ip=209.85.221.44 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="WW3zCKck" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4706f016316so166922f8f.3 for ; Mon, 10 Aug 2026 09:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786380470; x=1786985270; 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=Lb5+5JTC9yhaPKpWNbGAJrFXvPh/cPi2R9FXngaeHD4=; b=WW3zCKcke63q0GO2C+CsKnxGf2PCGjErAAl4/ODYxJibWkar0Usmzxh4T1n6US0Y9A UBlSJmUfzH80U4i1yg792j2MYUB7F57FZwOJBuRbhauDReKpl2G0ufoDF8xcT8OdK6Qv xBmM2lrGSy8bejbW0Gmq+leIoVSyGLviVYL1hUmtwbmpqBl88vcZZDhSCjHv4Ptt38Yk GIxqjcYivjVymbIIL5Soc/kh4mlFQHX5AqeGnmPoBi7p/7KGcHfA3OJ6EJmPtU0Zwz4Y XG8O25oBx3NOD1f2qkXpdXTsJbWMIaK8lY51vd7btnR8iM9LK7eqmGioPUaWbMOcGtdc AA9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786380470; x=1786985270; 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=Lb5+5JTC9yhaPKpWNbGAJrFXvPh/cPi2R9FXngaeHD4=; b=fbUyzmRv830hkwQm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nqEiJ5HPkeWmUdaIE3Q== X-Received: by 2002:a05:6000:290a:b0:47f:7526:5a0 with SMTP id ffacd0b85a97d-47fec47628bmr32828119f8f.0.1786380470283; Mon, 10 Aug 2026 09:47:50 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:692b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021f9182sm37080011f8f.28.2026.08.10.09.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 09:47:49 -0700 (PDT) From: Gustavo Luiz Duarte Date: Mon, 10 Aug 2026 17:47:28 +0100 Subject: [PATCH net-next v2 4/6] 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: <20260810-netcons_ipv6-v2-4-3d4fc987a90f@gmail.com> References: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@gmail.com> In-Reply-To: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@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 Reviewed-by: Breno Leitao --- drivers/net/netconsole.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 7fcdff53b3a4..054c39066043 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -475,6 +475,12 @@ static int netcons_netpoll_setup(struct netconsole_tar= get *nt) return -EDESTADDRREQ; } =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"); + return -EINVAL; + } + rtnl_lock(); if (np->dev_name[0]) ndev =3D __dev_get_by_name(net, np->dev_name); --=20 2.55.0 From nobody Tue Sep 29 08:22:55 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 2F0DF42D75C for ; Mon, 10 Aug 2026 16:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380476; cv=none; b=SMq+Pm3tl9tzHTua1RqRPdFxJ2PwsbLJ5kYuvtbqUlP5XbGfFGtQDLv3K+R2YXkq3RCMnfuAVtpZrJLOEjlEmG9dw/F2GhXxsq3qqBIEya7/faOjxfEH8873QDPJnwWGTKHI3+2eAuwQmoVFivEDs73vl7THVLhaUk1/YmkDSiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380476; c=relaxed/simple; bh=Nf8019ikvXpuawmVRnTiH/eAUfA2qq1dCBgswbuW8v0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XWEfkRc3nx9A1vv7n4n1S0N2UohFKqsAx/CfEJS1+E9MG/tDRBuMo7Zl7I+ewvLQvsflpLA4FTOdp2ecQu7e4P1mkWwDJ+7kI3XjLl1zoNpEYrVq7JikIsn812MstY6xBQ8Tc642I2vaD+FbpVds//eXNMsuJogda4mRQbhJAZg= 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=pqus/4u2; arc=none smtp.client-ip=209.85.128.53 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="pqus/4u2" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4996c452e95so740285e9.0 for ; Mon, 10 Aug 2026 09:47:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786380472; x=1786985272; 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=Dwa/MBE6L/+MukVwCaR5+lFDiikCNLSp9oEd4ORAtSk=; b=pqus/4u2Bhb+RNQdsN07NmCAea9L+1OrkbclnCd2o/VNDSdemzSJd4hF76JngKfiyc cA+MnURyl8NETEdnjcjTKZAEy9X4pw5KiOznYpehr0K3UulG4QGnNrvrrxNJ0UkRKTo3 HnCA6e9J+ZV9EKvMygT23gVmIiC1NHixNvPzgRYt5tyQDsJNk7SXQSfrnIK8x5nlbxk6 R5uwIljG1N3c9y/BB5UNXa+ctRwxnCn6n2JmnK5dMS7mSyrWast8ZybhMQQdC+N1C4JI qFI4eb3NNx72hsrL3ZNVHHiNZamW0IMlDByJOy/ooNaK8N9ALof0RiR3MVeP9+DgNZTf AWkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786380472; x=1786985272; 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=Dwa/MBE6L/+MukVwC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PXf5XiP9BtvnvotXfEjH1OuNgN4CN0ygBB/Tw== X-Received: by 2002:a05:6000:220d:b0:47e:96f2:52a8 with SMTP id ffacd0b85a97d-47fec4e31b9mr31500906f8f.1.1786380472224; Mon, 10 Aug 2026 09:47:52 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:692b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021e8cd0sm35460643f8f.17.2026.08.10.09.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 09:47:51 -0700 (PDT) From: Gustavo Luiz Duarte Date: Mon, 10 Aug 2026 17:47:29 +0100 Subject: [PATCH net-next v2 5/6] netconsole: show empty string for an unset 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: <20260810-netcons_ipv6-v2-5-3d4fc987a90f@gmail.com> References: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@gmail.com> In-Reply-To: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@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 An unset address (local_ip/remote_ip), now denoted by AF_UNSPEC, currently shows "0.0.0.0" in configfs. Print an empty string instead, which is more clear. In netconsole_print_banner() we can be even more explicit about it, as we don't have the risk of userspace trying to parse it. Signed-off-by: Gustavo Luiz Duarte Reviewed-by: Breno Leitao --- drivers/net/netconsole.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 054c39066043..0418031b6bc9 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -705,14 +705,18 @@ 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->local_ip.family =3D=3D AF_INET6) + if (nt->local_ip.family =3D=3D AF_UNSPEC) + np_info(np, "local IP unset\n"); + else 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->remote_ip.family =3D=3D AF_INET6) + if (nt->remote_ip.family =3D=3D AF_UNSPEC) + np_info(np, "remote IP unset\n"); + else 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); @@ -850,6 +854,8 @@ static ssize_t local_ip_show(struct config_item *item, = char *buf) { struct netconsole_target *nt =3D to_target(item); =20 + if (nt->local_ip.family =3D=3D AF_UNSPEC) + return sysfs_emit(buf, "\n"); if (nt->local_ip.family =3D=3D AF_INET6) return sysfs_emit(buf, "%pI6c\n", &nt->local_ip.in6); else @@ -860,6 +866,8 @@ static ssize_t remote_ip_show(struct config_item *item,= char *buf) { struct netconsole_target *nt =3D to_target(item); =20 + if (nt->remote_ip.family =3D=3D AF_UNSPEC) + return sysfs_emit(buf, "\n"); if (nt->remote_ip.family =3D=3D AF_INET6) return sysfs_emit(buf, "%pI6c\n", &nt->remote_ip.in6); else --=20 2.55.0 From nobody Tue Sep 29 08:22:55 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 9382942F704 for ; Mon, 10 Aug 2026 16:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380479; cv=none; b=RDUHMXDul5Ps1ZkPpw02mBrsuZZnn35IBkazlixiw/WAgpYOfsmBLqLUk8jZsa5ETYB6553PUkstKTMkd+5SO+A1y+xGFndSsXZkF3N0OXyjRhfErIhbBCoLEA4bGYSybYLxjHf+5RQRAm7Ng7kHcE6k8yPuReFPt7Ne6yimpD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786380479; c=relaxed/simple; bh=t/OvjGuVBrq4uGHwkR+woHevYj6ykvarkJcjPcBQJoU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EESVyxPl10mZueRvuGXc5Sbawwy3xlndXCSPZKacjqQqS5fs197qAlzUpAIssQJl/gZKgf7ldVxfgmvVcY0U53IKO8TZ2pBjBdhMNH+9YU3XXS2qS4Oxxbo6nZS+5oiACyOT4yIVE+gt/amj6m5HAMjWDnfzzDUzvJviGZy6r3I= 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=fJsw18VA; arc=none smtp.client-ip=209.85.128.48 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="fJsw18VA" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4994d41ceb9so3275215e9.2 for ; Mon, 10 Aug 2026 09:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786380476; x=1786985276; 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=niH2tRwcLSsfyl44V3yKY7PLg2udy6rA81mInPPAQuA=; b=fJsw18VAkq5WrvPSvvJapr2ndNSsyeswp76ss/UOR1O7CRC5DDS7e67Mn/VTH0eEj6 Esp6ZxDOcGL6up6OkUH89XjQE2PF42DlEfazVIeZ6Jmqdxa5YDL8NnUqI89xW9PZ/IrU rmFiq4f3LwWSOCPPY9jD8Ujridu0+2f3fSDvd+VyrF05y+G4xf+PcomzVn82TlWFZfVH 96Dp+WOaDwpS+DGuZhQNXGIuguj0l3CBINKXGU4G+g5+WPaJ+W6lMfcoRjZ8esQfJ2G0 OHcJSs1+SaaGMgeYVIFlklcrUQW7UdOgXvdSTOMNJEjUCnvB2xXJGsCwvR3tpoT5+ow9 poew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786380476; x=1786985276; 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=niH2tRwcLSsfyl44V3yKY7PLg2udy6rA81mInPPAQuA=; b=eY9i2RxFpBuw8Q3qt3OtCeZOOPUGgNmXuLrm168u+Bdt+OZMjSJ6haOT/sedP+95HE c6iMvilSMFIonzxjIr9Ej3R9T17iUSurV/PioXTjUl7ut0I2ASNFfpecnuoP+/0FD5EL XsAGZGYpP2QWFtMpKpb2jBFt0OhLj+cr5NIZAjOWnJnXTQakoXliRk4dFaArWbrmtYcn ikqzNgp/I5no6LxJZesrY2UIx3TG4xRcsZ0Lf1lNq3L2ngRFICNb2Oj+WkDla6XP69Dg Vpc8Nco/MTxm7zfK5E5QHx+FCh9iXrx2/0TdMGPUWd2GAMqicXGvHya82r4dEILK6yDP rOzw== X-Forwarded-Encrypted: i=1; AHgh+RpyUEaK3niZ6jpdRoof968OzxWN+jA+nhQxVt10J/2Rj8bmx6WUAbdFWlnrvmgSgLEdR+CNnPDuklov5o8=@vger.kernel.org X-Gm-Message-State: AOJu0Ywe/7E9H+OJQXF1N9yRpeuuLNDkX9Pa/74UQ5XDiGqlH0LI1/L+ NMVxdZs0qr6v5RqgVuKcF3AqCVX5QQuBrnRZlfjTOO+dPQSSpJ0Detkf X-Gm-Gg: AR+sD10ttUfiEy4vIzXXlUnwt0bzBMfgf/l+KQbmVtgwOCuGxCF2yzPaEPcpFxRNFM2 9qN4vdjjtWn5VjjODsJvlbndGdatS60XYLWH2bHTehVX3KiQddB+zIT/XD+99mD5jcek6gcR/gT 2IO+NK2FZuJTBmT2zuMiMahD5+e24Hzc2UO+bHeqTXkH0Uv9SRL6ntFkj3v849kLZq65NvJAXAC gLzCrNMoRIT9eLl1cVjv3Et03rsF2WrwAo0PA/19w9StH2lR3rS3snjtHlyXusY9C3E2xNUJ+9N yC7CB9kFMF9aR2HT1d2Jd8yJutFf18sr+s1xN2odIhF042Nm0dXWKmawCgiMaTWyn/PYd2ugEa8 ++oKhD03N3qYJdOVwGn5Ue1qy8TfPV10sWNdBlR/DKdSulSLZzoJL7hvO/uBhx7FqIk7GHd1eaE VI3GlSlqFbAlCB9dJrlKxcP9tUerK6BeIVQnSqesxZ4/k= X-Received: by 2002:a05:6000:40cb:b0:47f:946b:d3fc with SMTP id ffacd0b85a97d-47fec51b36emr34596331f8f.2.1786380475418; Mon, 10 Aug 2026 09:47:55 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::7:692b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-480021f9182sm37080453f8f.28.2026.08.10.09.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 09:47:53 -0700 (PDT) From: Gustavo Luiz Duarte Date: Mon, 10 Aug 2026 17:47:30 +0100 Subject: [PATCH net-next v2 6/6] netconsole: move struct inet_addr into netconsole.c 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: <20260810-netcons_ipv6-v2-6-3d4fc987a90f@gmail.com> References: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@gmail.com> In-Reply-To: <20260810-netcons_ipv6-v2-0-3d4fc987a90f@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 struct inet_addr lives in netpoll.h, but since commit a1116396476f ("netconsole: move local_ip/remote_ip/ipv6 to netconsole_target") the only user is netconsole. Move the definition into netconsole.c Signed-off-by: Gustavo Luiz Duarte Suggested-by: Breno Leitao Reviewed-by: Breno Leitao --- drivers/net/netconsole.c | 9 +++++++++ include/linux/netpoll.h | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 0418031b6bc9..810ded6e48f3 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -151,6 +151,15 @@ enum target_state { STATE_DEACTIVATED, }; =20 +struct inet_addr { + /* Address family: AF_UNSPEC when unset, else AF_INET or AF_INET6 */ + u8 family; + union { + __be32 ip; + struct in6_addr in6; + }; +}; + /** * struct netconsole_target - Represents a configured netconsole target. * @list: Links this target into the target_list. diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index de97f001a0f9..ec0821a5b02d 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -16,15 +16,6 @@ #include #include =20 -struct inet_addr { - /* Address family: AF_UNSPEC when unset, else AF_INET or AF_INET6 */ - u8 family; - union { - __be32 ip; - struct in6_addr in6; - }; -}; - struct netpoll { struct net_device *dev; netdevice_tracker dev_tracker; --=20 2.55.0