From c3e160880f32f8e7ce7e3aa10b7a8dd9bf6bbe34 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 3 Feb 2021 11:07:04 -0800 Subject: [PATCH] station: only add diagnostic interface when connected The diagnostic interface returns an error anyways if station is not connected so it makes more sense to only bring the interface up when its actually usable. This also removes the interface when station disconnects, which was never done before (the interface stayed up indefinitely due to a forgotten remove call). --- src/station.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/station.c b/src/station.c index 4bc1bf5b..20f2fe2f 100644 --- a/src/station.c +++ b/src/station.c @@ -1255,11 +1255,21 @@ static void station_enter_state(struct station *station, l_dbus_property_changed(dbus, network_get_path(station->connected_network), IWD_NETWORK_INTERFACE, "Connected"); - /* fall through */ - case STATION_STATE_DISCONNECTED: - case STATION_STATE_CONNECTED: - periodic_scan_stop(station); + periodic_scan_stop(station); + break; + case STATION_STATE_DISCONNECTED: + l_dbus_object_remove_interface(dbus_get_bus(), + netdev_get_path(station->netdev), + IWD_STATION_DIAGNOSTIC_INTERFACE); + periodic_scan_stop(station); + break; + case STATION_STATE_CONNECTED: + l_dbus_object_add_interface(dbus, + netdev_get_path(station->netdev), + IWD_STATION_DIAGNOSTIC_INTERFACE, + station); + periodic_scan_stop(station); break; case STATION_STATE_DISCONNECTING: case STATION_STATE_ROAMING: @@ -3451,9 +3461,6 @@ static struct station *station_create(struct netdev *netdev) l_dbus_object_add_interface(dbus, netdev_get_path(netdev), IWD_STATION_INTERFACE, station); - l_dbus_object_add_interface(dbus, netdev_get_path(netdev), - IWD_STATION_DIAGNOSTIC_INTERFACE, - station); if (netconfig_enabled) station->netconfig = netconfig_new(netdev_get_ifindex(netdev)); @@ -3628,12 +3635,6 @@ static struct l_dbus_message *station_get_diagnostics(struct l_dbus *dbus, struct station *station = user_data; int ret; - /* - * At this time all values depend on a connected state. - */ - if (station->state != STATION_STATE_CONNECTED) - return dbus_error_not_connected(message); - ret = netdev_get_current_station(station->netdev, station_get_diagnostic_cb, station, station_get_diagnostic_destroy);