diff mbox series

wpa_supplicant: Try all drivers by default

Message ID 20211012182831.524437-1-kees@ubuntu.com
State Accepted
Headers show
Series wpa_supplicant: Try all drivers by default | expand

Commit Message

Kees Cook Oct. 12, 2021, 6:28 p.m. UTC
Some distros carry patches to specify driver fallback, but only in
specific conditions (e.g. the systemd service definition[1]). This leaves
other wpa_supplicant instances needing to define fallback themselves,
which leads to places where wpa_supplicant thinks it can't find a
driver[2]. Instead, when -D is not specified, have wpa_supplicant try
all the drivers it was built with in an attempt to find a working one
instead of just giving up if the first doesn't work.

[1] https://salsa.debian.org/debian/wpa/-/blob/debian/unstable/debian/patches/networkd-driver-fallback.patch
[2] https://bugs.launchpad.net/netplan/+bug/1814012

Signed-off-by: Kees Cook <kees@ubuntu.com>
---
 wpa_supplicant/wpa_supplicant.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Andrej Shadura Oct. 13, 2021, 4:45 p.m. UTC | #1
Hi,

On Tue, 12 Oct 2021, at 20:28, Kees Cook wrote:
> Some distros carry patches to specify driver fallback, but only in
> specific conditions (e.g. the systemd service definition[1]). This leaves
> other wpa_supplicant instances needing to define fallback themselves,
> which leads to places where wpa_supplicant thinks it can't find a
> driver[2]. Instead, when -D is not specified, have wpa_supplicant try
> all the drivers it was built with in an attempt to find a working one
> instead of just giving up if the first doesn't work.

Thanks! This looks like a great idea — I’ll be able to finally drop that patch :)

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
Jouni Malinen Oct. 18, 2021, 8:08 p.m. UTC | #2
On Tue, Oct 12, 2021 at 11:28:31AM -0700, Kees Cook wrote:
> Some distros carry patches to specify driver fallback, but only in
> specific conditions (e.g. the systemd service definition[1]). This leaves
> other wpa_supplicant instances needing to define fallback themselves,
> which leads to places where wpa_supplicant thinks it can't find a
> driver[2]. Instead, when -D is not specified, have wpa_supplicant try
> all the drivers it was built with in an attempt to find a working one
> instead of just giving up if the first doesn't work.

Thanks, applied.
diff mbox series

Patch

diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 0f9db267fe9d..8edf87c46342 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -4812,8 +4812,13 @@  static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
 	}
 
 	if (name == NULL) {
-		/* default to first driver in the list */
-		return select_driver(wpa_s, 0);
+		/* Default to first successful driver in the list */
+		for (i = 0; wpa_drivers[i]; i++) {
+			if (select_driver(wpa_s, i) == 0)
+				return 0;
+		}
+		/* Drivers have each reported failure, so no wpa_msg() here. */
+		return -1;
 	}
 
 	do {