|
|
ac3a84 |
From ff7e9a0e3bf9229b2ea55ac0e832358fe13b97b4 Mon Sep 17 00:00:00 2001
|
|
|
ac3a84 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
ac3a84 |
Date: Tue, 22 Nov 2022 14:24:32 +0900
|
|
|
ac3a84 |
Subject: [PATCH] network: wifi: try to reconfigure when connected
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Sometimes, RTM_NEWLINK message with carrier is received earlier than
|
|
|
ac3a84 |
NL80211_CMD_CONNECT. To make SSID= or other WiFi related settings in
|
|
|
ac3a84 |
[Match] section work, let's try to reconfigure the interface.
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Fixes a bug introduced by 96f5f9ef9a1ba5146d3357c1548fb675d3bd5b68.
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Fixes #25384.
|
|
|
ac3a84 |
|
|
|
ac3a84 |
(cherry picked from commit 8a4ad01a72481a6a7c0309064dd2dbd814818c94)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
Related: #2138081
|
|
|
ac3a84 |
---
|
|
|
ac3a84 |
src/network/networkd-link.c | 2 +-
|
|
|
ac3a84 |
src/network/networkd-link.h | 1 +
|
|
|
ac3a84 |
src/network/networkd-wifi.c | 12 ++++++++++++
|
|
|
ac3a84 |
3 files changed, 14 insertions(+), 1 deletion(-)
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
|
|
|
ac3a84 |
index 00e4e451ef..788c7957d3 100644
|
|
|
ac3a84 |
--- a/src/network/networkd-link.c
|
|
|
ac3a84 |
+++ b/src/network/networkd-link.c
|
|
|
ac3a84 |
@@ -1178,7 +1178,7 @@ static int link_get_network(Link *link, Network **ret) {
|
|
|
ac3a84 |
return -ENOENT;
|
|
|
ac3a84 |
}
|
|
|
ac3a84 |
|
|
|
ac3a84 |
-static int link_reconfigure_impl(Link *link, bool force) {
|
|
|
ac3a84 |
+int link_reconfigure_impl(Link *link, bool force) {
|
|
|
ac3a84 |
Network *network = NULL;
|
|
|
ac3a84 |
NetDev *netdev = NULL;
|
|
|
ac3a84 |
int r;
|
|
|
ac3a84 |
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
|
|
|
ac3a84 |
index 9f1cdca312..65b0164106 100644
|
|
|
ac3a84 |
--- a/src/network/networkd-link.h
|
|
|
ac3a84 |
+++ b/src/network/networkd-link.h
|
|
|
ac3a84 |
@@ -234,6 +234,7 @@ int link_stop_engines(Link *link, bool may_keep_dhcp);
|
|
|
ac3a84 |
const char* link_state_to_string(LinkState s) _const_;
|
|
|
ac3a84 |
LinkState link_state_from_string(const char *s) _pure_;
|
|
|
ac3a84 |
|
|
|
ac3a84 |
+int link_reconfigure_impl(Link *link, bool force);
|
|
|
ac3a84 |
int link_reconfigure(Link *link, bool force);
|
|
|
ac3a84 |
int link_reconfigure_after_sleep(Link *link);
|
|
|
ac3a84 |
|
|
|
ac3a84 |
diff --git a/src/network/networkd-wifi.c b/src/network/networkd-wifi.c
|
|
|
ac3a84 |
index 4bf798a9eb..62cbca0cf9 100644
|
|
|
ac3a84 |
--- a/src/network/networkd-wifi.c
|
|
|
ac3a84 |
+++ b/src/network/networkd-wifi.c
|
|
|
ac3a84 |
@@ -269,6 +269,18 @@ int manager_genl_process_nl80211_mlme(sd_netlink *genl, sd_netlink_message *mess
|
|
|
ac3a84 |
if (link->wlan_iftype == NL80211_IFTYPE_STATION && link->ssid)
|
|
|
ac3a84 |
log_link_info(link, "Connected WiFi access point: %s (%s)",
|
|
|
ac3a84 |
link->ssid, ETHER_ADDR_TO_STR(&link->bssid));
|
|
|
ac3a84 |
+
|
|
|
ac3a84 |
+ /* Sometimes, RTM_NEWLINK message with carrier is received earlier than NL80211_CMD_CONNECT.
|
|
|
ac3a84 |
+ * To make SSID= or other WiFi related settings in [Match] section work, let's try to
|
|
|
ac3a84 |
+ * reconfigure the interface. */
|
|
|
ac3a84 |
+ if (link->ssid && link_has_carrier(link)) {
|
|
|
ac3a84 |
+ r = link_reconfigure_impl(link, /* force = */ false);
|
|
|
ac3a84 |
+ if (r < 0) {
|
|
|
ac3a84 |
+ log_link_warning_errno(link, r, "Failed to reconfigure interface: %m");
|
|
|
ac3a84 |
+ link_enter_failed(link);
|
|
|
ac3a84 |
+ return 0;
|
|
|
ac3a84 |
+ }
|
|
|
ac3a84 |
+ }
|
|
|
ac3a84 |
break;
|
|
|
ac3a84 |
}
|
|
|
ac3a84 |
case NL80211_CMD_DISCONNECT:
|