net: ipv6: IPv6 environment variable cleanup
PATCH 1/1 net: ipv6: IPv6 environment variable cleanup
From: Sean Edmond <[email protected]>
Fix "setenv gatewayip6".
Synchronize IPv6 local variables with environment variables in netboot_update_env()
--- cmd/net.c | 23 ++++++++++++++++++++++- include/env_flags.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-)
cmd/net.c +22 -1
@@ -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); + } + } }/**
include/env_flags.h +1 -1
@@ -71,7 +71,7 @@ enum env_flags_varaccess {#define NET6_FLAGS \ "ip6addr:s," \ "serverip6:s," \ - "gatewayip6:s" + "gatewayip6:s,"#else #define NET6_FLAGS #endif
Signature · 1 line
2.39.0
Quoted 60 lines · On Thu, Feb 16, 2023 at 6:39 AM <[email protected]> wrote:
From: Sean Edmond <[email protected]>
Fix "setenv gatewayip6".
Synchronize IPv6 local variables with environment variables in
netboot_update_env()Signed-off-by Sean Edmond <[email protected]>--- cmd/net.c | 23 ++++++++++++++++++++++- include/env_flags.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-)cmd/net.c +22
-1@@ -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); + } + } }/** include/env_flags.h +0
-0
include/env_flags.h enum env_flags_varaccess { · line 74
Quoted 5 lines
include/env_flags.h +1
-1@@ -71,7 +71,7 @@ enum env_flags_varaccess {#define NET6_FLAGS \ "ip6addr:s," \ "serverip6:s," \ - "gatewayip6:s" + "gatewayip6:s,"
Why is this needed ?
Quoted 6 lines
include/env_flags.h +0
-1#else #define NET6_FLAGS #endif --2.39.0
Quoted 64 lines
-----Original Message-----
From: Ramon Fried <[email protected]>
Sent: Saturday, February 18, 2023 12:10 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Sean Edmond <[email protected]>
Subject: [EXTERNAL] Re: [PATCH] net: ipv6: IPv6 environment variable cleanupQuoted 55 lines · On Thu, Feb 16, 2023 at 6:39 AM <[email protected]> wrote:
From: Sean Edmond <[email protected]>
Fix "setenv gatewayip6".
Synchronize IPv6 local variables with environment variables in
netboot_update_env()Signed-off-by Sean Edmond <[email protected]>--- cmd/net.c | 23 ++++++++++++++++++++++- include/env_flags.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-)cmd/net.c +1
-1@@ -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
cmd/net.c +22
-0+ +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); + } + } }
Quoted 11 lines
include/env_flags.h enum env_flags_varaccess { #define NET6_FLAGS \ · line 73
Quoted 10 lines
/**
include/env_flags.h index renamed from include/env_flags.h +0
-0
6bd574c2bd..7df40c59be100644include/env_flags.h +1
-1@@ -71,7 +71,7 @@ enum env_flags_varaccess { #define NET6_FLAGS \"ip6addr:s," \"serverip6:s," \ -"gatewayip6:s" +"gatewayip6:s," Why is this needed ?
Without the comma, we see the following error when trying to set the gatewayip6 environment variable:
=> setenv gatewayip6 fe80::f0c7:7cff:fea9:c4ec
## Warning: Unknown environment variable access method 's' ## Error inserting "gatewayip6" variable, errno=3
Quoted 6 lines
Quoted 6 lines
include/env_flags.h +0
-1#else #define NET6_FLAGS #endif --2.39.0
Quoted 55 lines · Ramon Fried
Quoted 54 lines · On Thu, Feb 16, 2023 at 6:39 AM <[email protected]> wrote:
From: Sean Edmond <[email protected]>
Fix "setenv gatewayip6".
Synchronize IPv6 local variables with environment variables in
netboot_update_env()Signed-off-by Sean Edmond <[email protected]>--- cmd/net.c | 23 ++++++++++++++++++++++- include/env_flags.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-)cmd/net.c +22
-1@@ -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); + } + } }
Quoted 12 lines
include/env_flags.h enum env_flags_varaccess { · line 74
Quoted 11 lines
cmd/net.c +0
-0/** include/env_flags.h +1
-1@@ -71,7 +71,7 @@ enum env_flags_varaccess {#define NET6_FLAGS \ "ip6addr:s," \ "serverip6:s," \ - "gatewayip6:s" + "gatewayip6:s,"Why is this needed ?
Without the comma, we see the following error when trying to set the gatewayip6 environment variable:
=> setenv gatewayip6 fe80::f0c7:7cff:fea9:c4ec
## Warning: Unknown environment variable access method 's' ## Error inserting "gatewayip6" variable, errno=3
Quoted 6 lines
Quoted 6 lines
include/env_flags.h +0
-1#else #define NET6_FLAGS #endif --2.39.0
Quoted 8 lines · On Wed, Feb 15, 2023 at 08:38:36PM -0800, [email protected] wrote:
From: Sean Edmond <[email protected]>
Fix "setenv gatewayip6".
Synchronize IPv6 local variables with environment variables in
netboot_update_env()Signed-off-by Sean Edmond <[email protected]>
Applied to u-boot/master, thanks!
Signature · 1 line
Tom