From 4428de2aad9a540e1375da0e8818534f0648e489 Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Wed, 23 Apr 2014 12:56:53 +0200 Subject: [PATCH 1/3] net/ifup.c: don't fail silently Since commit a162dfe50345d3461010759f8a0e79f7e388c140 the ifup command is implemented in C and runs up to two external scripts. If one of these scripts return with an error code, the command terminates silently. This can confuse a user because there is no hint about the reason why it fails. Add error messages to avoid this case. Signed-off-by: Juergen Borleis Signed-off-by: Sascha Hauer --- net/ifup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/ifup.c b/net/ifup.c index 7b6313629..b259a975d 100644 --- a/net/ifup.c +++ b/net/ifup.c @@ -70,14 +70,18 @@ int ifup(const char *name, unsigned flags) cmd_discover = asprintf("/env/network/%s-discover", name); ret = run_command(cmd); - if (ret) + if (ret) { + pr_err("Running '%s' failed with %d\n", cmd, ret); goto out; + } ret = stat(cmd_discover, &s); if (!ret) { ret = run_command(cmd_discover); - if (ret) + if (ret) { + pr_err("Running '%s' failed with %d\n", cmd, ret); goto out; + } } dev = get_device_by_name(name); From 3018f1367075dd5310fc5f5ceaf6706ae67b3013 Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Wed, 23 Apr 2014 11:19:25 +0200 Subject: [PATCH 2/3] net/ifup.c: avoid setting the MAC twice The command always sets the MAC address of the interface in the code path. For the static network configuration case it sets it again, due to the environment variable keyword ("ethaddr") is listed again in the table. Remove this keyword from the table, because the MAC is already set. Signed-off-by: Juergen Borleis Signed-off-by: Sascha Hauer --- net/ifup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ifup.c b/net/ifup.c index b259a975d..409b338ec 100644 --- a/net/ifup.c +++ b/net/ifup.c @@ -31,7 +31,6 @@ static char *vars[] = { "netmask", "gateway", "serverip", - "ethaddr", }; static int eth_set_param(struct device_d *dev, const char *param) From fb67ada79add357cf14c919504e27d54d91ca444 Mon Sep 17 00:00:00 2001 From: Juergen Borleis Date: Wed, 23 Apr 2014 11:19:26 +0200 Subject: [PATCH 3/3] default environment: force a specific return value Since commit a162dfe50345d3461010759f8a0e79f7e388c140 the ifup command runs this file as a script. Due to a hush misbehave it could happen it returns an error code by accident. For example if the last instructions in this file are: if [ false ]; then echo "friesel" fi the hush returns 1 after running this script instead of 0 and in this case the ifup command fails. I know, the correct fix would be to fix the hush, because it is a generic issue...but how? Signed-off-by: Juergen Borleis Signed-off-by: Sascha Hauer --- defaultenv/defaultenv-2-base/network/eth0 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/defaultenv/defaultenv-2-base/network/eth0 b/defaultenv/defaultenv-2-base/network/eth0 index 7e731cae0..33fe7c1b2 100644 --- a/defaultenv/defaultenv-2-base/network/eth0 +++ b/defaultenv/defaultenv-2-base/network/eth0 @@ -14,3 +14,5 @@ serverip= #ethaddr=xx:xx:xx:xx:xx:xx # put code to discover eth0 (i.e. 'usb') to /env/network/eth0-discover + +exit 0