D-Bus: Fix network block type change

It is possible for a network profile to change its type from P2P
persistent group to a normal network and back. The D-Bus interface uses
different types of objects for those, so the object needs to
re-registered in case of type change. This fixes issues in leaving
behind an incorrect type of object and leaking memory when freeing such
a network block that has had its disabled parameter changed.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-02-07 16:17:11 +02:00
parent c62bd5e44d
commit 1e529832a8
3 changed files with 28 additions and 1 deletions

View file

@ -2940,7 +2940,7 @@ static int wpa_supplicant_ctrl_iface_update_network(
static int wpa_supplicant_ctrl_iface_set_network( static int wpa_supplicant_ctrl_iface_set_network(
struct wpa_supplicant *wpa_s, char *cmd) struct wpa_supplicant *wpa_s, char *cmd)
{ {
int id, ret, prev_bssid_set; int id, ret, prev_bssid_set, prev_disabled;
struct wpa_ssid *ssid; struct wpa_ssid *ssid;
char *name, *value; char *name, *value;
u8 prev_bssid[ETH_ALEN]; u8 prev_bssid[ETH_ALEN];
@ -2970,6 +2970,7 @@ static int wpa_supplicant_ctrl_iface_set_network(
} }
prev_bssid_set = ssid->bssid_set; prev_bssid_set = ssid->bssid_set;
prev_disabled = ssid->disabled;
os_memcpy(prev_bssid, ssid->bssid, ETH_ALEN); os_memcpy(prev_bssid, ssid->bssid, ETH_ALEN);
ret = wpa_supplicant_ctrl_iface_update_network(wpa_s, ssid, name, ret = wpa_supplicant_ctrl_iface_update_network(wpa_s, ssid, name,
value); value);
@ -2977,6 +2978,11 @@ static int wpa_supplicant_ctrl_iface_set_network(
(ssid->bssid_set != prev_bssid_set || (ssid->bssid_set != prev_bssid_set ||
os_memcmp(ssid->bssid, prev_bssid, ETH_ALEN) != 0)) os_memcmp(ssid->bssid, prev_bssid, ETH_ALEN) != 0))
wpas_notify_network_bssid_set_changed(wpa_s, ssid); wpas_notify_network_bssid_set_changed(wpa_s, ssid);
if (prev_disabled != ssid->disabled &&
(prev_disabled == 2 || ssid->disabled == 2))
wpas_notify_network_type_changed(wpa_s, ssid);
return ret; return ret;
} }

View file

@ -764,3 +764,22 @@ void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
wpa_drv_roaming(wpa_s, !ssid->bssid_set, wpa_drv_roaming(wpa_s, !ssid->bssid_set,
ssid->bssid_set ? ssid->bssid : NULL); ssid->bssid_set ? ssid->bssid : NULL);
} }
void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid)
{
#ifdef CONFIG_P2P
if (ssid->disabled == 2) {
/* Changed from normal network profile to persistent group */
ssid->disabled = 0;
wpas_dbus_unregister_network(wpa_s, ssid->id);
ssid->disabled = 2;
wpas_dbus_register_persistent_group(wpa_s, ssid);
} else {
/* Changed from persistent group to normal network profile */
wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
wpas_dbus_register_network(wpa_s, ssid);
}
#endif /* CONFIG_P2P */
}

View file

@ -131,5 +131,7 @@ void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
const char *parameter); const char *parameter);
void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid); struct wpa_ssid *ssid);
void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
struct wpa_ssid *ssid);
#endif /* NOTIFY_H */ #endif /* NOTIFY_H */