All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ipv6: IPv6 environment variable cleanup
@ 2023-02-16  4:38 seanedmond
  2023-02-18 20:09 ` Ramon Fried
  2023-05-06 14:53 ` Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: seanedmond @ 2023-02-16  4:38 UTC (permalink / raw)
  To: u-boot; +Cc: joe.hershberger, wd, seanedmond

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: ipv6: IPv6 environment variable cleanup
  2023-02-16  4:38 [PATCH] net: ipv6: IPv6 environment variable cleanup seanedmond
@ 2023-02-18 20:09 ` Ramon Fried
  2023-02-20 17:50   ` [EXTERNAL] " Sean Edmond
  2023-02-20 19:56   ` Sean Edmond
  2023-05-06 14:53 ` Tom Rini
  1 sibling, 2 replies; 5+ messages in thread
From: Ramon Fried @ 2023-02-18 20:09 UTC (permalink / raw)
  To: seanedmond; +Cc: u-boot, joe.hershberger, wd, seanedmond

On Thu, Feb 16, 2023 at 6:39 AM <seanedmond@linux.microsoft.com> wrote:
>
> 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,"
Why is this needed ?
>  #else
>  #define NET6_FLAGS
>  #endif
> --
> 2.39.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [EXTERNAL] Re: [PATCH] net: ipv6: IPv6 environment variable cleanup
  2023-02-18 20:09 ` Ramon Fried
@ 2023-02-20 17:50   ` Sean Edmond
  2023-02-20 19:56   ` Sean Edmond
  1 sibling, 0 replies; 5+ messages in thread
From: Sean Edmond @ 2023-02-20 17:50 UTC (permalink / raw)
  To: Ramon Fried, seanedmond; +Cc: u-boot, joe.hershberger, wd

>-----Original Message-----
>From: Ramon Fried <rfried.dev@gmail.com>
>Sent: Saturday, February 18, 2023 12:10 PM
>To: seanedmond@linux.microsoft.com
>Cc: u-boot@lists.denx.de; joe.hershberger@ni.com; wd@denx.de; Sean
>Edmond <seanedmond@microsoft.com>
>Subject: [EXTERNAL] Re: [PATCH] net: ipv6: IPv6 environment variable cleanup
>
>On Thu, Feb 16, 2023 at 6:39 AM <seanedmond@linux.microsoft.com> wrote:
>>
>> 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,"
>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


>>  #else
>>  #define NET6_FLAGS
>>  #endif
>> --
>> 2.39.0
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: ipv6: IPv6 environment variable cleanup
  2023-02-18 20:09 ` Ramon Fried
  2023-02-20 17:50   ` [EXTERNAL] " Sean Edmond
@ 2023-02-20 19:56   ` Sean Edmond
  1 sibling, 0 replies; 5+ messages in thread
From: Sean Edmond @ 2023-02-20 19:56 UTC (permalink / raw)
  To: Ramon Fried; +Cc: u-boot, joe.hershberger, wd, seanedmond

Sat, Feb 18, 2023 at 10:09:56PM +0200, Ramon Fried wrote:
> On Thu, Feb 16, 2023 at 6:39 AM <seanedmond@linux.microsoft.com> wrote:
> >
> > 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,"
> 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

> >  #else
> >  #define NET6_FLAGS
> >  #endif
> > --
> > 2.39.0
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: ipv6: IPv6 environment variable cleanup
  2023-02-16  4:38 [PATCH] net: ipv6: IPv6 environment variable cleanup seanedmond
  2023-02-18 20:09 ` Ramon Fried
@ 2023-05-06 14:53 ` Tom Rini
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2023-05-06 14:53 UTC (permalink / raw)
  To: seanedmond; +Cc: u-boot, joe.hershberger, wd, seanedmond

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

On Wed, Feb 15, 2023 at 08:38:36PM -0800, seanedmond@linux.microsoft.com wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-06 14:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16  4:38 [PATCH] net: ipv6: IPv6 environment variable cleanup seanedmond
2023-02-18 20:09 ` Ramon Fried
2023-02-20 17:50   ` [EXTERNAL] " Sean Edmond
2023-02-20 19:56   ` Sean Edmond
2023-05-06 14:53 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.