
The patch fd3056337e6fcc introduces env callbacks to several of the net related env variables. These callbacks are responsible for updating the corresponding global variables internal to the net source code. However this behavior will be skipped if the source of the callbacks originated from setenv. This is based on the assumption that all current instances of setenv are invoked using the same global variables that the callback will eventually write to; therefore there is no need set them to the same value.
As setenv is a public interface this assumption may not always hold. In our usage case we implement a user facing menu system for configuration of networking parameters. This ultimately lead to calling setenv rather than through the traditional interactive command line parser do_env_set. Therefore, in our usage case, setenv can be called for an "interactive" case. Consequently, the early return for non-interactive invocation are now removed and any call to setenv will update the corresponding states internal to the net source code as expected.
Signed-off-by: Matthew Bright matthew.bright@alliedtelesis.co.nz Reviewed-by: Hamish Martin hamish.martin@alliedtelesis.co.nz Reviewed-by: Chris Packham chris.packham@alliedtelesis.co.nz --- net/net.c | 24 ------------------------ 1 file changed, 24 deletions(-)
diff --git a/net/net.c b/net/net.c index 1e1d23d..726b0f0 100644 --- a/net/net.c +++ b/net/net.c @@ -209,9 +209,6 @@ int __maybe_unused net_busy_flag; static int on_bootfile(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - switch (op) { case env_op_create: case env_op_overwrite: @@ -229,9 +226,6 @@ U_BOOT_ENV_CALLBACK(bootfile, on_bootfile); static int on_ipaddr(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - net_ip = string_to_ip(value);
return 0; @@ -241,9 +235,6 @@ U_BOOT_ENV_CALLBACK(ipaddr, on_ipaddr); static int on_gatewayip(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - net_gateway = string_to_ip(value);
return 0; @@ -253,9 +244,6 @@ U_BOOT_ENV_CALLBACK(gatewayip, on_gatewayip); static int on_netmask(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - net_netmask = string_to_ip(value);
return 0; @@ -265,9 +253,6 @@ U_BOOT_ENV_CALLBACK(netmask, on_netmask); static int on_serverip(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - net_server_ip = string_to_ip(value);
return 0; @@ -277,9 +262,6 @@ U_BOOT_ENV_CALLBACK(serverip, on_serverip); static int on_nvlan(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - net_native_vlan = string_to_vlan(value);
return 0; @@ -289,9 +271,6 @@ U_BOOT_ENV_CALLBACK(nvlan, on_nvlan); static int on_vlan(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - net_our_vlan = string_to_vlan(value);
return 0; @@ -302,9 +281,6 @@ U_BOOT_ENV_CALLBACK(vlan, on_vlan); static int on_dnsip(const char *name, const char *value, enum env_op op, int flags) { - if (flags & H_PROGRAMMATIC) - return 0; - net_dns_server = string_to_ip(value);
return 0;