wifi: re-add code for tracking a peers groups

The code to track the property was accidentally removed in commit
21d4a26188 ('core: remove code for unused NM_WIFI_P2P_PEER_GROUPS property')
causing all P2P connections to fail after 5 seconds.

Fixes: 21d4a26188 ('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
(cherry picked from commit dc54a946ac)
This commit is contained in:
Benjamin Berg 2020-10-12 18:39:37 +02:00 committed by Thomas Haller
parent 817f2cb90e
commit 9cd4968b7b
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 23 additions and 3 deletions

View file

@ -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);
}

View file

@ -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_g_slice_free(peer_info);
@ -854,6 +855,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;
@ -878,6 +880,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);

View file

@ -185,6 +185,8 @@ typedef struct _NMSupplicantPeerInfo {
char *model_number;
char *serial;
const char **groups;
GBytes *ies;
gint64 last_seen_msec;