[PATCH] iface match: unspecified matched interfaces should not log driver fails
Roy Marples
roy at marples.name
Tue Jul 21 09:25:26 EDT 2020
If there is no matching interface given, but interface matching is enabled
then all interfaces on the system will try to be initialized.
Non wireless interfaces will fail and the loopback device will be one
of these, so just log a diagnostic rather than an error.
Signed-off-by: Roy Marples <roy at marples.name>
---
wpa_supplicant/events.c | 2 --
wpa_supplicant/wpa_supplicant.c | 20 +++++++++++++++++---
wpa_supplicant/wpa_supplicant_i.h | 11 +++++++++++
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 0fcb1762e..978d0bfa7 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -5453,8 +5453,6 @@ void wpa_supplicant_event_global(void *ctx, enum
wpa_event_type event,
return;
wpa_s = wpa_supplicant_add_iface(ctx, wpa_i, NULL);
os_free(wpa_i);
- if (wpa_s)
- wpa_s->matched = 1;
}
#endif /* CONFIG_MATCH_IFACE */
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index e7989baef..fad4f3ad4 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -6044,6 +6044,8 @@ next_driver:
wpa_s->drv_priv = wpa_drv_init(wpa_s, wpa_s->ifname);
if (wpa_s->drv_priv == NULL) {
const char *pos;
+ int level;
+
pos = driver ? os_strchr(driver, ',') : NULL;
if (pos) {
wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize "
@@ -6051,7 +6053,14 @@ next_driver:
driver = pos + 1;
goto next_driver;
}
- wpa_msg(wpa_s, MSG_ERROR, "Failed to initialize driver "
+
+#ifdef CONFIG_MATCH_IFACE
+ if (wpa_s->matched == WPA_IFACE_MATCHEDNULL)
+ level = MSG_DEBUG;
+ else
+#endif
+ level = MSG_ERROR;
+ wpa_msg(wpa_s, level, "Failed to initialize driver "
"interface");
return -1;
}
@@ -6197,6 +6206,9 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant
*wpa_s,
return -1;
}
os_strlcpy(wpa_s->ifname, iface->ifname, sizeof(wpa_s->ifname));
+#ifdef CONFIG_MATCH_IFACE
+ wpa_s->matched = iface->matched;
+#endif
if (iface->bridge_ifname) {
if (os_strlen(iface->bridge_ifname) >=
@@ -6588,6 +6600,10 @@ struct wpa_interface * wpa_supplicant_match_iface(struct
wpa_global *global,
if (!iface)
return NULL;
*iface = *miface;
+ if (!miface->ifname)
+ iface->matched = WPA_IFACE_MATCHEDNULL;
+ else
+ iface->matched = WPA_IFACE_MATCHED;
iface->ifname = ifname;
return iface;
}
@@ -6622,8 +6638,6 @@ static int wpa_supplicant_match_existing(struct wpa_global
*global)
if (iface) {
wpa_s = wpa_supplicant_add_iface(global, iface, NULL);
os_free(iface);
- if (wpa_s)
- wpa_s->matched = 1;
}
}
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 341d84156..730ff290e 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -121,6 +121,17 @@ struct wpa_interface {
* interface that is not a network interface.
*/
int p2p_mgmt;
+
+#ifdef CONFIG_MATCH_IFACE
+ /**
+ * matched - Interface was matched rather than specified
+ *
+ */
+ int matched;
+#define WPA_IFACE_NOTMATCHED 0
+#define WPA_IFACE_MATCHEDNULL 1
+#define WPA_IFACE_MATCHED 2
+#endif /* CONFIG_MATCH_IFACE */
};
/**
--
2.27.0
More information about the Hostap
mailing list