diff mbox

[U-Boot,RFC] env: Add a setenv that allows passing flags

Message ID 71de867f37ad49299b08c6389d03dca2@svr-chch-ex1.atlnz.lc
State RFC
Headers show

Commit Message

Chris Packham June 15, 2016, 5:43 a.m. UTC
On 06/15/2016 08:47 AM, Chris Packham wrote:
> Hi Joe,
>
> On 06/15/2016 07:01 AM, Joe Hershberger wrote:
>> In some cases an interactive feature will be implemented using the
>> programmatic APIs, so the developer will want "interactive" behavior as
>> a result, so provide an API that will allow that to be specified.
>>
>> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
>
> Thanks looks great
>
> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>
> I'll also give it a test on some of our setups here and report back.

Matt did the testing for me so:

Tested-by: Matthew Bright <matthew.bright@alliedtelesis.co.nz>

One other corner case I think I spotted was that if you use the dns 
command to set one of these net variables it won't stick

e.g.
   setenv serverip 127.0.0.1
   setenv dnsip 192.168.1.1
   dns bootserver.example.com serverip
   tftpboot

So maybe we want this as well (warning totally untested and my mailer is 
probably going to eat the whitespace)

--- 8< ---
[PATCH] net: use setenv_w_flags when updating environment variable

The serverip environment variable is special in that it is not updated
unless set from the CLI. The other places it is set (e.g. bootp/dhcp)
this is handled correctly but as the dns command can take an arbitrary
environment variable we need to use the H_INTERACTIVE flag to make the
setting stick.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
  net/dns.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

                 }
diff mbox

Patch

diff --git a/net/dns.c b/net/dns.c
index 7017bac..f0c8744 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -184,7 +184,8 @@  static void dns_handler(uchar *pkt, unsigned dest, 
struct in_addr sip,
                         ip_to_string(ip_addr, ip_str);
                         printf("%s\n", ip_str);
                         if (net_dns_env_var)
-                               setenv(net_dns_env_var, ip_str);
+                               setenv_w_flags(net_dns_env_var, ip_str,
+                                              H_INTERACTIVE);
                 } else {
                         puts("server responded with invalid IP number\n");