summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-04-06 15:10:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-04-09 08:49:30 +0200
commitb0f7425f922d371737804a5a9a213232c6fe0265 (patch)
tree5ada7bae61900e0b95895438f169942a5485ce18 /net
parentbd9ad3a602295fb9aa8882fbf27c54288b150d5f (diff)
downloadbarebox-b0f7425f922d371737804a5a9a213232c6fe0265.tar.gz
barebox-b0f7425f922d371737804a5a9a213232c6fe0265.tar.xz
net: on ifup -a only detect devices when necessary
For network boot we once used to hardcode eth0, but in latest changes this was changed to work with different network devices and the 'ifup eth0' was replaced with 'ifup -a' which lead to the result that we now detect all devices in order to eventually also bring up USB network adapters. In most of the cases this is not desired. When a board has internal network support this is likely to be used. With this patch we only detect all devices when we do not have a network device already. For the unusual case in which a USB network adapter shall be used even when an internal network interface is present we introduce the global variable "global.net.ifup_force_detect" which can be used to force detection of devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r--net/ifup.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/net/ifup.c b/net/ifup.c
index 827c5c03d1..d550f82530 100644
--- a/net/ifup.c
+++ b/net/ifup.c
@@ -28,6 +28,9 @@
#include <globalvar.h>
#include <string.h>
#include <driver.h>
+#include <init.h>
+#include <globalvar.h>
+#include <magicvar.h>
#include <linux/stat.h>
static int eth_discover(char *file)
@@ -245,6 +248,8 @@ int ifup(const char *ethname, unsigned flags)
return ifup_edev(edev, flags);
}
+static int net_ifup_force_detect;
+
int ifup_all(unsigned flags)
{
struct eth_device *edev;
@@ -266,7 +271,9 @@ int ifup_all(unsigned flags)
closedir(dir);
- device_detect_all();
+ if ((flags & IFUP_FLAG_FORCE) || net_ifup_force_detect ||
+ list_empty(&netdev_list))
+ device_detect_all();
for_each_netdev(edev)
ifup_edev(edev, flags);
@@ -274,6 +281,18 @@ int ifup_all(unsigned flags)
return 0;
}
+static int ifup_all_init(void)
+{
+ globalvar_add_simple_bool("net.ifup_force_detect", &net_ifup_force_detect);
+
+ return 0;
+}
+late_initcall(ifup_all_init);
+
+BAREBOX_MAGICVAR_NAMED(global_net_ifup_force_detect,
+ global.net.ifup_force_detect,
+ "net: force detection of devices on ifup -a");
+
#if IS_ENABLED(CONFIG_NET_CMD_IFUP)
static int do_ifup(int argc, char *argv[])