From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 08B4B4EC64C for ; Thu, 3 Sep 2026 16:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788452799; cv=none; b=lMqnnZRo72dLRacu8EhQQOuQpTzEfaZJAhNNz78XaKG7m/CumPj3+hA0xgDprpewcKGwFLhGiP/GkuULEyj6ea+xFo23hmzbsJagwUcgHUGI9ucTlEuv2QILLx1BpsGohQMVTIdMGgF7r3hBbRwT2IEUO3D7sDZc+B60BcOt5XA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788452799; c=relaxed/simple; bh=rtw1I6+ZQwIhsJ1KAJ7coYMuQ5TqGSxTCkqUoPJfohw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WIMxlZoM6D2xyQpKGPGAhaF+m1EE1N/qg0Y+mpfZWrx+Q+94Ms6/B7A7YOgau2+4Ezv9V/T/tZ6IErFWE0vVXPOvRb5i3Q8KGw3dLvh8zIYIT3jiGI5tEJ79R8KwW2rwqKuLRHGkILaKCNI1rmKyHREq1JHq792rPjZkrIosVZg= 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=D+Ep61cm; arc=none smtp.client-ip=209.85.221.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="D+Ep61cm" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-48432729fb1so4388f8f.2 for ; Thu, 03 Sep 2026 09:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788452796; x=1789057596; 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=pPlwGzMzreFTOH2oIaycDj0Xnl8STIJ81ul4wFBoks0=; b=D+Ep61cmzJUumCFXw7Lcih6t/1RBe1Aa5mWBdc+m6MuOr4WcUgRF38Lnaa1dPqreKM bmrHFUeJXS+uAgU1GkeB/MsUwbd5xHPZ6st0XN6jsiw5bxAJqjS2Mmu6rORhodQlu4e2 q6RQQYL5wsBGM4fML3gE8Jzq3ahowJlT98cmJv/IwuJvxVYecPvJDxX+19ImxHWcMeEz tla9NkJgxlW6q1zqKwwi6XIuAI4myEzTde13e7Uui4cRNd+f6tdoIS79cLxIOboDuqgk ONvcgJzvpX8JVkDwmSBhLWY3TXYcuPlkhEUOWOkzoqT9egrRb1NXnhsYXRMAb5egi0jU YtOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788452796; x=1789057596; 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=pPlwGzMzreFTOH2oIaycDj0Xnl8STIJ81ul4wFBoks0=; b=BMdwmkBHmHNLV8xYNAF8BjD+VjwBA98bli+mfRs2wh7Yl0nRu7pGATxeEwEZ84BGvv mvCkhE50t/UcLSOC1b+/TxMeg6UaSZr/yQvMWYsivuGsQsOb+gVw0mjyvpJzzv2i+oF7 pfC+Ci+8l/hFk/OS9KR/AE9GvKFJchjGdm/ymSu8qk/q0iFdBl+on69YQlC8jioj2a80 4rGnkfb3DXEX3y4mKmgkWOOw+MSdt1l5uy7oGoGhVMUjhi1WtdJEDgosLDVbGBfdOEEx RiPTEpy7w2qjooJbEQKBP7YTK2sXmLILUMoGT61zN1jnHNsslCXfZTUkGtSd10PUuYPH EJ/g== X-Forwarded-Encrypted: i=1; AKwUvBxSgtCRyhiN6rKfAoErnXxX5DhYiTHCBaM3RRXTxEORueESAsN7OUYDvc9LLpbHWgmQzTjOaBGz8WY=@vger.kernel.org X-Gm-Message-State: AFuF++nGPSShCIovhhRb75+mIMhHAiWP98OU2lN6Kn8xVRp01HLHTKlg Y18+xC+796zRAZUZKK+ViR96KJIhOn6BLDgZtQ8Ae8yrMKDIVXJ4e6qr X-Gm-Gg: AYBFou06wq/aIpjjnFuV+ZQtyZ7O7VULLnNammApflloDMDj22KnZZvMKyg6WO2Vvgj TiVsRJ6QH6H/n0nYjzSz8PbL+uTEJPyEgIRdLnTMTsYZdlCb5XKguCXkZo+xnTtYQtaU1XneHIq RWylh+61RzFKl5NuP15ryJjqxzdzacM9VRgOC6bi/GgfmBAXW5v3eKA/f8AUfobeTezcsPIVZeZ kfe2JKRB7yIhaVsFJIPDLteMpl3lH3LqIFPtfrWdkqZxGBw/x0WQ7HOHwtJbEpR99XWwPRYE10q tuR5qt/+532kD0l2MQChuoOL2pw5KPsScc8JMDElntUfrTwOYrqFodbsmqtuk1uQT++OxXdhQJX wOg2XxB2FhWwbYj+07pXL4ddo1R2hZvO3Omkrck+Qm2Ew/JaZT78cC91CJytQ5LA94LEjsVeyKd KRF4/BsyiNKHqbxCjJJIRla2NtvM+TZP71RzZVEAp43sY= X-Received: by 2002:a05:6000:4a11:b0:484:3310:f393 with SMTP id ffacd0b85a97d-485872e4232mr88305f8f.5.1788452795980; Thu, 03 Sep 2026 09:26:35 -0700 (PDT) Received: from localhost ([2620:10d:c092:500::6:124b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448e72c28sm16058322f8f.6.2026.09.03.09.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 09:26:34 -0700 (PDT) From: Gustavo Luiz Duarte Date: Thu, 03 Sep 2026 17:26:00 +0100 Subject: [PATCH net-next v4 1/7] netconsole: add an address family to struct inet_addr Precedence: bulk X-Mailing-List: linux-doc@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: <20260903-netcons_ipv6-v4-1-bdd183c844d3@gmail.com> References: <20260903-netcons_ipv6-v4-0-bdd183c844d3@gmail.com> In-Reply-To: <20260903-netcons_ipv6-v4-0-bdd183c844d3@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan Cc: Gustavo Luiz Duarte , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org 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. Reviewed-by: Breno Leitao Signed-off-by: Gustavo Luiz Duarte --- 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 b358e5c36735..432b66cf111a 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -225,7 +225,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]; @@ -428,6 +428,7 @@ static int netcons_take_ipv6(struct netconsole_target *nt, continue; /* Got the IP, let's return */ nt->local_ip.in6 = ifp->addr; + nt->local_ip.family = AF_INET6; err = 0; break; } @@ -469,6 +470,7 @@ static int netcons_take_ipv4(struct netconsole_target *nt, } nt->local_ip.ip = ifa->ifa_local; + nt->local_ip.family = AF_INET; np_info(np, "local IP %pI4\n", &nt->local_ip.ip); return 0; @@ -741,10 +743,10 @@ static void netconsole_print_banner(struct netconsole_target *nt) np_info(np, "remote ethernet address %pM\n", nt->remote_mac); } -/* 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 = NULL; int len; @@ -756,14 +758,18 @@ static int netpoll_parse_ip_addr(const char *str, union inet_addr *addr) if (str[len - 1] == '\n') len -= 1; - if (in4_pton(str, len, (void *)addr, -1, &end) > 0 && - (!end || *end == 0 || *end == '\n')) + if (in4_pton(str, len, (void *)&addr->ip, -1, &end) > 0 && + (!end || *end == 0 || *end == '\n')) { + addr->family = AF_INET; return 0; + } if (IS_ENABLED(CONFIG_IPV6) && - in6_pton(str, len, (void *)addr, -1, &end) > 0 && - (!end || *end == 0 || *end == '\n')) + in6_pton(str, len, (void *)&addr->in6, -1, &end) > 0 && + (!end || *end == 0 || *end == '\n')) { + addr->family = AF_INET6; return 1; + } return -1; } @@ -871,7 +877,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); } static ssize_t remote_ip_show(struct config_item *item, char *buf) @@ -881,7 +887,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); } 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 -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; + }; }; struct netpoll { -- 2.55.0