From def61273ed29e944a48064bac18537652f9ef81a Mon Sep 17 00:00:00 2001 From: Danc2 Date: Fri, 14 Dec 2018 14:27:36 -0800 Subject: [PATCH] net_server: Add (more) missing devices even if one has already been found. Fixes #6423 and helps with #14626. In BringUpInterfaces, line 772 creates an error which only adds a missing interface if one does not already exist (i.e., !_testInterface()). This can lead to a missing WiFi interface if an Ethernet connection has been configured and set in the /boot/system/settings/network/interfaces before the WiFi has had a chance to be added to /dev/net. To properly configure a missing device, such as a WiFi connection, and allow the user to choose amongst configured interfaces (i.e., add it to the list of devices in /dev/net and e.g., see WiFi as an option), removing the 'if' statement on line 772 is necessary. Two edge cases may arise: 1. A user may disable an interface -- don't add device Solution: The code currently handles this. _ConfigureInterfacesFromSettings, called at line 746, checks for interfaces in fSettings to see if they are disabled (706-711). If so, they are disabled and not set as a missingDevice if the interface is disabled (709). The next interface is checked... etc. 2. Devices must not be added twice (i.e., Checking for An Existing configured Network) Solution: The code currently checks for this. On lines 716-720, a device that is found in fSettings (missingDevice), is set to the interface which is later added to the /dev/net within that (unnecessary?) if statement (772). The missingDevice will only be set and added to /dev/net if an entry does not exist in the settings already (716) (hence the identifier missingDevice). Change-Id: Ifc303371b88f18c30141a651a7d97a3c860e864f Reviewed-on: https://review.haiku-os.org/767 Reviewed-by: waddlesplash --- src/servers/net/NetServer.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index 192bd0b8d3..f70f567673 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -769,11 +769,9 @@ NetServer::_BringUpInterfaces() // TODO: also check if the networking driver is correctly initialized! // (and check for other devices to take over its configuration) - if (!_TestForInterface("/dev/net/")) { - // there is no driver configured - see if there is one and try to use it - _ConfigureDevices("/dev/net", - missingDevice.HasString("device") ? &missingDevice : NULL); - } + // if a missing device has been found, add it to /dev/net + _ConfigureDevices("/dev/net", + missingDevice.HasString("device") ? &missingDevice : NULL); }