From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C251FC636CC for ; Thu, 16 Feb 2023 04:38:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D4B9C85A98; Thu, 16 Feb 2023 05:38:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="Xt54Woeh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24BA285A8E; Thu, 16 Feb 2023 05:38:52 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by phobos.denx.de (Postfix) with ESMTP id B056E85A98 for ; Thu, 16 Feb 2023 05:38:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanedmond@linux.microsoft.com Received: from ovlvm106.redmond.corp.microsoft.com (unknown [131.107.174.57]) by linux.microsoft.com (Postfix) with ESMTPSA id 8C5E4200DDF6; Wed, 15 Feb 2023 20:38:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8C5E4200DDF6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1676522323; bh=nWEL7vRpgt2UXlzd1CU+CWqdlDu39tnu8PiDnPjO1lE=; h=From:To:Cc:Subject:Date:From; b=Xt54Woehteg7j2P3gHxYFWQflVovKdZ3sx+aAJH+DoILmhRLYA952Ok4RRyihCx7v 2sMbpqr4UTzHTuY8Lwbv12ITsz6YdfjW8Rksj5FFaSKDA9pfuWj/NQBKjiAp30XXQ6 LKVxNeYUp/WKHKdi9X8RvnjIVtPdnQM1SSymlhOY= From: seanedmond@linux.microsoft.com To: u-boot@lists.denx.de Cc: joe.hershberger@ni.com, wd@denx.de, seanedmond@microsoft.com Subject: [PATCH] net: ipv6: IPv6 environment variable cleanup Date: Wed, 15 Feb 2023 20:38:36 -0800 Message-Id: <20230216043836.13886-1-seanedmond@linux.microsoft.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Sean Edmond Fix "setenv gatewayip6". Synchronize IPv6 local variables with environment variables in netboot_update_env() Signed-off-by: Sean Edmond --- cmd/net.c | 23 ++++++++++++++++++++++- include/env_flags.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index 88d53d14d5..0161c87529 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -208,7 +208,7 @@ U_BOOT_CMD( static void netboot_update_env(void) { - char tmp[22]; + char tmp[44]; if (net_gateway.s_addr) { ip_to_string(net_gateway, tmp); @@ -269,6 +269,27 @@ static void netboot_update_env(void) env_set("ntpserverip", tmp); } #endif + + if (IS_ENABLED(CONFIG_IPV6)) { + if (!ip6_is_unspecified_addr(&net_ip6) || + net_prefix_length != 0) { + sprintf(tmp, "%pI6c", &net_ip6); + if (net_prefix_length != 0) + sprintf(tmp, "%s/%d", tmp, net_prefix_length); + + env_set("ip6addr", tmp); + } + + if (!ip6_is_unspecified_addr(&net_server_ip6)) { + sprintf(tmp, "%pI6c", &net_server_ip6); + env_set("serverip6", tmp); + } + + if (!ip6_is_unspecified_addr(&net_gateway6)) { + sprintf(tmp, "%pI6c", &net_gateway6); + env_set("gatewayip6", tmp); + } + } } /** diff --git a/include/env_flags.h b/include/env_flags.h index 6bd574c2bd..7df40c59be 100644 --- a/include/env_flags.h +++ b/include/env_flags.h @@ -71,7 +71,7 @@ enum env_flags_varaccess { #define NET6_FLAGS \ "ip6addr:s," \ "serverip6:s," \ - "gatewayip6:s" + "gatewayip6:s," #else #define NET6_FLAGS #endif -- 2.39.0