From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 ED3B94EBAFA for ; Thu, 3 Sep 2026 16:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788452799; cv=none; b=pn7rYqZc2kDKfIgY1Mj63JyeIfICN6yvvxYGPpswJ4Dxu44lXc8Rw+h0iWfeGEVoZ7Pb5fo2uc4OwM2QQvcU70rN4mZ4UpxdZJj4nuJ5Pmd3ZpyBHbdBuu1JovoIMxE7cSYjoS8t3vj35sBxPjqONqz6I3ZdgXRPgM+X2VBtYLY= 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.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="D+Ep61cm" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-481595afa73so6899f8f.0 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=oL+zJ2rvCvrwHM9ItQPDI2P30LSL0oEjiuNclzoLsWGwHL/jD4dB5pI7WbRUzW43uE 80qR+/1tDCN3CWCKT0BLXuiINBdCKZKQfRmeLcDdCrbH/UAFHYdd/PxAnHnmKLEImATP H+TdrHS7190Xehf2CWKzfGgIzizhMLugViY3yaVoHPbKZ8LMiKm0IAHcQVa/pWKqlQT4 Qwe4JpDMTsv9dfdWBd6Icgi9LTAheKfpZbQM2vEZ9RWbF7F0toPBnjuGtg8QgsrmQwip iENTn5+rz/1+4LIWXpiF6GXNEP2VNaNY+PD4EqXIuJh4PFlg8lEl5bRm6/Zdph5iYwPX 02Uw== X-Forwarded-Encrypted: i=1; AKwUvBwBmAls2plmBPy575v5p8thf5E0ySp1Xb4H8djd69dbYZrZE9qPrg5x6SgcRgOyv4uGUloc2yH3VYwOkso=@vger.kernel.org X-Gm-Message-State: AFuF++lPgxb2ylAg7qmShJ+2391WCqxZidspGcNdzbv9w80GFkJwU8Et R4BrPqu0I8Z9e9B6ujiSbgaT8zcSlah07uhjW/NB4ZG6QAkCrYLSNzob X-Gm-Gg: AYBFou2FFQKir6JY9Pod5OizYMBSIEuNwzZ+4NRAY2KaA8lSgxW0RCd7ZSRwnrz+7ko KPp1MDUr72jnqG4TaNHsGIaelGDU6dWzG2nUsus4kDgVztnu9NDdOLVJuG50tKD+2o5HIl4Soo/ rj3dLbnX8ftX9zotvtVKUVKiQtUlNAwOhlIXKwRMBQesKXXsG74pj0kcPUWu66l4gLxeUvx3REm tn6+d0jGyA5s2gOeBMy9Hvs+yZLCCn878HStxQvjXdUXR1L4GxTEkxgVbEMbB28aDXykRea0EHb GPIadrV5voFunKbD5C4nR5EpcM1aPPRITbyQJ/G5TUlHq5Z5mA4iFZgJ09Ko07PfCEms7w2k1WS tzxKKR5ouOVESl2a+tc8rhp34iZcBWjUqwn/U66+I3iAaxF490U9eVgDO5qjAOlqLeoHtI6dpqe Sm5I3SCp8Q8I/BYlOoYPrYZajzFQpI3lzAbQy5Ix5FGyQ= 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-kernel@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