diff --git a/Documentation/user/networking.rst b/Documentation/user/networking.rst index 5822165..6bb99b0 100644 --- a/Documentation/user/networking.rst +++ b/Documentation/user/networking.rst @@ -51,6 +51,10 @@ | global.net.nameserver | ipv4 address | The DNS server used for resolving host names. | | | | May be set by DHCP | +------------------------------+--------------+------------------------------------------------+ +| global.net.ifup_force_detect | boolean | Set to true if your network device is not | +| | | detected automatically during start (i.e. for | +| | | USB network adapters) | ++------------------------------+--------------+------------------------------------------------+ The first step for networking is configuring the network device. The network device is usually ``eth0``. The current configuration can be viewed with the diff --git a/net/ifup.c b/net/ifup.c index 827c5c0..d550f82 100644 --- a/net/ifup.c +++ b/net/ifup.c @@ -28,6 +28,9 @@ #include #include #include +#include +#include +#include #include static int eth_discover(char *file) @@ -245,6 +248,8 @@ return ifup_edev(edev, flags); } +static int net_ifup_force_detect; + int ifup_all(unsigned flags) { struct eth_device *edev; @@ -266,7 +271,9 @@ 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 @@ 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[])