summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2020-10-12 18:39:37 +0200
committerThomas Haller <thaller@redhat.com>2020-10-12 21:39:48 +0200
commitdc54a946acb968c73f8d55e01c61efedb4ae6cc1 (patch)
tree15845068f5045caa7ae1a3d268df5582ade62391
parent3cf8620294e83960c97961d096be19ece5c57ea5 (diff)
downloadNetworkManager-dc54a946acb968c73f8d55e01c61efedb4ae6cc1.tar.gz
wifi: re-add code for tracking a peers groups
The code to track the property was accidentally removed in commit 21d4a2618868 ('core: remove code for unused NM_WIFI_P2P_PEER_GROUPS property') causing all P2P connections to fail after 5 seconds. Fixes: 21d4a2618868 ('core: remove code for unused NM_WIFI_P2P_PEER_GROUPS property') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/551 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/650
-rw-r--r--src/devices/wifi/nm-wifi-p2p-peer.c15
-rw-r--r--src/supplicant/nm-supplicant-interface.c9
-rw-r--r--src/supplicant/nm-supplicant-types.h2
3 files changed, 23 insertions, 3 deletions
diff --git a/src/devices/wifi/nm-wifi-p2p-peer.c b/src/devices/wifi/nm-wifi-p2p-peer.c
index fe6ad0a0ac..a194f168c0 100644
--- a/src/devices/wifi/nm-wifi-p2p-peer.c
+++ b/src/devices/wifi/nm-wifi-p2p-peer.c
@@ -47,7 +47,8 @@ struct _NMWifiP2PPeerPrivate {
char *address;
GBytes *wfd_ies;
- char ** groups;
+
+ const char **groups;
guint8 strength;
@@ -281,7 +282,7 @@ nm_wifi_p2p_peer_get_groups(const NMWifiP2PPeer *peer)
{
g_return_val_if_fail(NM_IS_WIFI_P2P_PEER(peer), NULL);
- return (const char *const *) NM_WIFI_P2P_PEER_GET_PRIVATE(peer)->groups;
+ return NM_WIFI_P2P_PEER_GET_PRIVATE(peer)->groups;
}
const char *
@@ -404,6 +405,14 @@ nm_wifi_p2p_peer_update_from_properties(NMWifiP2PPeer *peer, const NMSupplicantP
changed |= nm_wifi_p2p_peer_set_wfd_ies(peer, peer_info->ies);
changed |= nm_wifi_p2p_peer_set_last_seen(peer, peer_info->last_seen_msec / 1000u);
+ /* We currently only use the groups information internally to check if
+ * the peer is still joined. */
+ if (!_nm_utils_strv_equal((char **) priv->groups, (char **) peer_info->groups)) {
+ g_free(priv->groups);
+ priv->groups = nm_utils_strv_dup_packed(peer_info->groups, -1);
+ changed |= TRUE;
+ }
+
g_object_thaw_notify(G_OBJECT(peer));
return changed;
@@ -566,7 +575,7 @@ finalize(GObject *object)
g_free(priv->serial);
g_free(priv->address);
g_bytes_unref(priv->wfd_ies);
- g_strfreev(priv->groups);
+ g_free(priv->groups);
G_OBJECT_CLASS(nm_wifi_p2p_peer_parent_class)->finalize(object);
}
diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c
index e409f4900e..77254c7ebc 100644
--- a/src/supplicant/nm-supplicant-interface.c
+++ b/src/supplicant/nm-supplicant-interface.c
@@ -833,6 +833,7 @@ _peer_info_destroy(NMSupplicantPeerInfo *peer_info)
g_free(peer_info->model);
g_free(peer_info->model_number);
g_free(peer_info->serial);
+ g_free(peer_info->groups);
g_bytes_unref(peer_info->ies);
nm_ref_string_unref(peer_info->peer_path);
@@ -856,6 +857,7 @@ _peer_info_properties_changed(NMSupplicantInterface *self,
{
GVariant * v_v;
const char * v_s;
+ const char ** v_strv;
gint32 v_i32;
const guint8 *arr_data;
gsize arr_len;
@@ -880,6 +882,13 @@ _peer_info_properties_changed(NMSupplicantInterface *self,
if (nm_g_variant_lookup(properties, "Serial", "&s", &v_s))
nm_utils_strdup_reset(&peer_info->serial, v_s);
+ if (nm_g_variant_lookup(properties, "Groups", "^a&o", &v_strv)) {
+ g_free(peer_info->groups);
+ peer_info->groups = nm_utils_strv_dup_packed(v_strv, -1);
+
+ g_free(v_strv);
+ }
+
v_v = nm_g_variant_lookup_value(properties, "DeviceAddress", G_VARIANT_TYPE_BYTESTRING);
if (v_v) {
arr_data = g_variant_get_fixed_array(v_v, &arr_len, 1);
diff --git a/src/supplicant/nm-supplicant-types.h b/src/supplicant/nm-supplicant-types.h
index dc1e3c3537..e35059af45 100644
--- a/src/supplicant/nm-supplicant-types.h
+++ b/src/supplicant/nm-supplicant-types.h
@@ -185,6 +185,8 @@ typedef struct _NMSupplicantPeerInfo {
char *model_number;
char *serial;
+ const char **groups;
+
GBytes *ies;
gint64 last_seen_msec;