1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-28 20:25:38 +03:00

network: reconfigure interface when wifi iftype is updated

Follow-up for a66a402da4.

Fixes #18059.
This commit is contained in:
Yu Watanabe 2021-01-12 23:35:01 +09:00
parent c33e405f20
commit 537ae584c8

View File

@ -16,6 +16,8 @@
#include "wifi-util.h"
int wifi_get_info(Link *link) {
_cleanup_free_ char *ssid = NULL;
enum nl80211_iftype iftype;
const char *type;
int r, s = 0;
@ -33,16 +35,18 @@ int wifi_get_info(Link *link) {
if (!streq(type, "wlan"))
return 0;
_cleanup_free_ char *ssid = NULL;
r = wifi_get_interface(link->manager->genl, link->ifindex, &link->wlan_iftype, &ssid);
r = wifi_get_interface(link->manager->genl, link->ifindex, &iftype, &ssid);
if (r < 0)
return r;
if (r > 0 && streq_ptr(link->ssid, ssid))
if (r > 0 && link->wlan_iftype == iftype && streq_ptr(link->ssid, ssid))
r = 0;
link->wlan_iftype = iftype;
free_and_replace(link->ssid, ssid);
if (link->wlan_iftype == NL80211_IFTYPE_STATION) {
struct ether_addr old_bssid = link->bssid;
s = wifi_get_station(link->manager->genl, link->ifindex, &link->bssid);
if (s < 0)
return s;
@ -56,7 +60,9 @@ int wifi_get_info(Link *link) {
if (link->wlan_iftype == NL80211_IFTYPE_STATION && link->ssid)
log_link_info(link, "Connected WiFi access point: %s (%s)",
link->ssid, ether_addr_to_string(&link->bssid, buf));
return 1;
return 1; /* Some information is updated. */
}
return 0;
return 0; /* No new information. */
}