diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkctl.c | 13 | ||||
-rw-r--r-- | src/network/networkd-link.c | 4 | ||||
-rw-r--r-- | src/network/networkd-link.h | 2 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 1 | ||||
-rw-r--r-- | src/network/networkd-network.c | 8 | ||||
-rw-r--r-- | src/network/networkd-network.h | 5 | ||||
-rw-r--r-- | src/network/networkd-wifi.c | 20 | ||||
-rw-r--r-- | src/network/test-network.c | 2 |
8 files changed, 34 insertions, 21 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c index d83dc611a5..5a8740883b 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -167,6 +167,7 @@ typedef struct LinkInfo { NetDevPort port; /* wlan info */ + enum nl80211_iftype wlan_iftype; char *ssid; struct ether_addr bssid; @@ -384,7 +385,7 @@ static void acquire_ether_link_info(int *fd, LinkInfo *link) { static void acquire_wlan_link_info(LinkInfo *link) { _cleanup_(sd_netlink_unrefp) sd_netlink *genl = NULL; const char *type = NULL; - int r, k; + int r, k = 0; if (link->sd_device) (void) sd_device_get_devtype(link->sd_device, &type); @@ -399,13 +400,15 @@ static void acquire_wlan_link_info(LinkInfo *link) { (void) sd_netlink_inc_rcvbuf(genl, RCVBUF_SIZE); - r = wifi_get_ssid(genl, link->ifindex, &link->ssid); + r = wifi_get_interface(genl, link->ifindex, &link->wlan_iftype, &link->ssid); if (r < 0) log_debug_errno(r, "%s: failed to query ssid: %m", link->name); - k = wifi_get_bssid(genl, link->ifindex, &link->bssid); - if (k < 0) - log_debug_errno(k, "%s: failed to query bssid: %m", link->name); + if (link->iftype == NL80211_IFTYPE_STATION) { + k = wifi_get_station(genl, link->ifindex, &link->bssid); + if (k < 0) + log_debug_errno(k, "%s: failed to query bssid: %m", link->name); + } link->has_wlan_link_info = r > 0 || k > 0; } diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 179408cbcc..906267764e 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -2865,7 +2865,7 @@ int link_reconfigure(Link *link, bool force) { return 0; r = network_get(link->manager, link->sd_device, link->ifname, - &link->mac, link->ssid, &link->bssid, &network); + &link->mac, link->wlan_iftype, link->ssid, &link->bssid, &network); if (r == -ENOENT) { link_enter_unmanaged(link); return 0; @@ -2959,7 +2959,7 @@ static int link_initialized_and_synced(Link *link) { return r; r = network_get(link->manager, link->sd_device, link->ifname, - &link->mac, link->ssid, &link->bssid, &network); + &link->mac, link->wlan_iftype, link->ssid, &link->bssid, &network); if (r == -ENOENT) { link_enter_unmanaged(link); return 0; diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index b47557181a..1e4510b277 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -2,6 +2,7 @@ #pragma once #include <endian.h> +#include <linux/nl80211.h> #include "sd-bus.h" #include "sd-device.h" @@ -56,6 +57,7 @@ typedef struct Link { sd_device *sd_device; /* wlan */ + enum nl80211_iftype wlan_iftype; char *ssid; struct ether_addr bssid; diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index d4d5743527..68199ac45f 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -29,6 +29,7 @@ Match.MACAddress, config_parse_hwaddrs, Match.Path, config_parse_match_strv, 0, offsetof(Network, match_path) Match.Driver, config_parse_match_strv, 0, offsetof(Network, match_driver) Match.Type, config_parse_match_strv, 0, offsetof(Network, match_type) +Match.WLANInterfaceType, config_parse_match_strv, 0, offsetof(Network, match_wlan_iftype) Match.SSID, config_parse_match_strv, 0, offsetof(Network, match_ssid) Match.BSSID, config_parse_hwaddrs, 0, offsetof(Network, match_bssid) Match.Name, config_parse_match_ifnames, 0, offsetof(Network, match_name) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 85d6150312..8cdcb57306 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -595,6 +595,7 @@ static Network *network_free(Network *network) { strv_free(network->match_type); strv_free(network->match_name); strv_free(network->match_property); + strv_free(network->match_wlan_iftype); strv_free(network->match_ssid); set_free_free(network->match_bssid); condition_free_list(network->conditions); @@ -701,7 +702,8 @@ int network_get_by_name(Manager *manager, const char *name, Network **ret) { int network_get(Manager *manager, sd_device *device, const char *ifname, const struct ether_addr *address, - const char *ssid, const struct ether_addr *bssid, Network **ret) { + enum nl80211_iftype wlan_iftype, const char *ssid, const struct ether_addr *bssid, + Network **ret) { Network *network; Iterator i; @@ -711,8 +713,8 @@ int network_get(Manager *manager, sd_device *device, ORDERED_HASHMAP_FOREACH(network, manager->networks, i) if (net_match_config(network->match_mac, network->match_path, network->match_driver, network->match_type, network->match_name, network->match_property, - network->match_ssid, network->match_bssid, - device, address, ifname, ssid, bssid)) { + network->match_wlan_iftype, network->match_ssid, network->match_bssid, + device, address, ifname, wlan_iftype, ssid, bssid)) { if (network->match_name && device) { const char *attr; uint8_t name_assign_type = NET_NAME_UNKNOWN; diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 1ae560e994..8b4b5d042d 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -1,6 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once +#include <linux/nl80211.h> + #include "sd-bus.h" #include "sd-device.h" @@ -64,6 +66,7 @@ struct Network { char **match_type; char **match_name; char **match_property; + char **match_wlan_iftype; char **match_ssid; Set *match_bssid; LIST_HEAD(Condition, conditions); @@ -291,7 +294,7 @@ int network_verify(Network *network); int network_get_by_name(Manager *manager, const char *name, Network **ret); int network_get(Manager *manager, sd_device *device, const char *ifname, const struct ether_addr *mac, - const char *ssid, const struct ether_addr *bssid, Network **ret); + enum nl80211_iftype wlan_iftype, const char *ssid, const struct ether_addr *bssid, Network **ret); int network_apply(Network *network, Link *link); void network_apply_anonymize_if_set(Network *network); diff --git a/src/network/networkd-wifi.c b/src/network/networkd-wifi.c index 877c742280..14a8687458 100644 --- a/src/network/networkd-wifi.c +++ b/src/network/networkd-wifi.c @@ -16,7 +16,7 @@ int wifi_get_info(Link *link) { const char *type; - int r, s; + int r, s = 0; assert(link); @@ -33,24 +33,26 @@ int wifi_get_info(Link *link) { return 0; _cleanup_free_ char *ssid = NULL; - r = wifi_get_ssid(link->manager->genl, link->ifindex, &ssid); + r = wifi_get_interface(link->manager->genl, link->ifindex, &link->wlan_iftype, &ssid); if (r < 0) return r; if (r > 0 && streq_ptr(link->ssid, ssid)) r = 0; free_and_replace(link->ssid, ssid); - struct ether_addr old_bssid = link->bssid; - s = wifi_get_bssid(link->manager->genl, link->ifindex, &link->bssid); - if (s < 0) - return s; - if (s > 0 && memcmp(&old_bssid, &link->bssid, sizeof old_bssid) == 0) - s = 0; + 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; + if (s > 0 && memcmp(&old_bssid, &link->bssid, sizeof old_bssid) == 0) + s = 0; + } if (r > 0 || s > 0) { char buf[ETHER_ADDR_TO_STRING_MAX]; - if (link->ssid) + 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; diff --git a/src/network/test-network.c b/src/network/test-network.c index 130adcbca8..873d996e4f 100644 --- a/src/network/test-network.c +++ b/src/network/test-network.c @@ -125,7 +125,7 @@ static void test_network_get(Manager *manager, sd_device *loopback) { /* let's assume that the test machine does not have a .network file that applies to the loopback device... */ - assert_se(network_get(manager, loopback, "lo", &mac, NULL, NULL, &network) == -ENOENT); + assert_se(network_get(manager, loopback, "lo", &mac, 0, NULL, NULL, &network) == -ENOENT); assert_se(!network); } |