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 [thread overview]
Message-ID: <20230216043836.13886-1-seanedmond@linux.microsoft.com> (raw)
From: Sean Edmond <seanedmond@microsoft.com>
Fix "setenv gatewayip6".
Synchronize IPv6 local variables with environment variables
in netboot_update_env()
Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
---
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
next reply other threads:[~2023-02-16 4:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 4:38 seanedmond [this message]
2023-02-18 20:09 ` [PATCH] net: ipv6: IPv6 environment variable cleanup Ramon Fried
2023-02-20 17:50 ` [EXTERNAL] " Sean Edmond
2023-02-20 19:56 ` Sean Edmond
2023-05-06 14:53 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230216043836.13886-1-seanedmond@linux.microsoft.com \
--to=seanedmond@linux.microsoft.com \
--cc=joe.hershberger@ni.com \
--cc=seanedmond@microsoft.com \
--cc=u-boot@lists.denx.de \
--cc=wd@denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox