]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: ipv6: IPv6 environment variable cleanup
authorSean Edmond <seanedmond@microsoft.com>
Thu, 16 Feb 2023 04:38:36 +0000 (20:38 -0800)
committerTom Rini <trini@konsulko.com>
Fri, 5 May 2023 17:41:55 +0000 (13:41 -0400)
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
include/env_flags.h

index d5e20843ddafa4d46b57a55f50855b1018b87c3c..036b7720a7cc4997fbd9a6ef4d7f731d43625e12 100644 (file)
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -186,7 +186,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);
@@ -247,6 +247,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);
+               }
+       }
 }
 
 /**
index 7de58cc57c34127ec7f459255040610ada24186c..d785f87cdcbe11f342a24206b6dc2c0bc74a2d16 100644 (file)
@@ -71,7 +71,7 @@ enum env_flags_varaccess {
 #define NET6_FLAGS \
        "ip6addr:s," \
        "serverip6:s," \
-       "gatewayip6:s"
+       "gatewayip6:s,"
 #else
 #define NET6_FLAGS
 #endif