Remove mesh station when it becomes inactive 09/148009/1
authorSaurav Babu <saurav.babu@samsung.com>
Wed, 6 Sep 2017 09:01:07 +0000 (14:31 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Wed, 6 Sep 2017 09:01:07 +0000 (14:31 +0530)
This patch removes current logic to send NL80211_CMD_DEL_STATION to
kernel from wifi-mesh-manager. Now wifi-mesh-manager will call connman's
method MeshRemovePeer to remove inactive peer

Change-Id: I2b2a6ffc1f19e45a4e255b9c7604b9f68a550d07
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
include/wmesh-gdbus.h
include/wmesh-netlink.h
src/wmesh-gdbus.c
src/wmesh-netlink.c
src/wmesh-peer-monitor.c

index caa00ec..cb882a4 100644 (file)
@@ -58,6 +58,7 @@ int wmesh_gdbus_disconnect_network(wmesh_service *service, wmesh_scan_result_s *
 int wmesh_gdbus_remove_network(wmesh_service *service, wmesh_scan_result_s *info);
 int wmesh_gdbus_enable_ethernet_interface(wmesh_service *service, bool state);
 int wmesh_gdbus_set_mesh_gate(wmesh_service *service);
+int wmesh_gdbus_mesh_remove_peer(wmesh_service *service, char *peer);
 
 #ifdef __cplusplus
 }
index 4207663..7b1edb6 100644 (file)
@@ -23,7 +23,6 @@ int wmesh_netlink_set_mesh_parameter(const char* mesh_if_name,
                const char* param_name, unsigned int value);
 
 int wmesh_netlink_get_station_info(const char* mesh_if_name, GList **station_list);
-int wmesh_netlink_del_station_info(const char* mesh_if_name, char *peer);
 int wmesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list);
 int wmesh_netlink_get_meshconf_info(wmesh_service *service);
 
index f1b8321..c8123b3 100644 (file)
@@ -1300,3 +1300,34 @@ int wmesh_gdbus_set_mesh_gate(wmesh_service *service)
        return ret;
 }
 
+int wmesh_gdbus_mesh_remove_peer(wmesh_service *service, char *peer)
+{
+       GVariant *variant = NULL;
+       GError *error = NULL;
+       int ret = WMESHD_ERROR_NONE;
+
+       wmeshd_check_null_ret_error("service", service,
+                                                               WMESHD_ERROR_INVALID_PARAMETER);
+       wmeshd_check_null_ret_error("connection", service->connection,
+                       WMESHD_ERROR_INVALID_PARAMETER);
+       wmeshd_check_null_ret_error("_gproxy_connman",
+                       _gproxy_connman, WMESHD_ERROR_IO_ERROR);
+
+       variant = g_dbus_proxy_call_sync(_gproxy_connman, "MeshRemovePeer",
+                               g_variant_new("(s)", peer), G_DBUS_CALL_FLAGS_NONE, 1, NULL,
+                               &error);
+       if (variant) {
+               WMESH_LOGD("Successfully requested. [MeshRemovePeer]");
+       } else if (error) {
+               ret = WMESHD_ERROR_IO_ERROR;
+               WMESH_LOGE("Failed DBus call [%s]", error->message);
+
+               /* Interface not exists */
+               if (g_strrstr(error->message, "No such device"))
+                       ret = WMESHD_ERROR_INVALID_PARAMETER;
+               g_error_free(error);
+       }
+
+       return ret;
+}
+
index 12a6fa9..a88c6c9 100644 (file)
@@ -1508,72 +1508,6 @@ nla_put_failure:
        return WMESHD_ERROR_OPERATION_FAILED;
 }
 
-static int _send_nl_del_station_info(const char* if_name, char* peer)
-{
-       mesh_nl_state state = {
-               .nl80211_id = -1,
-               .callback_state = MESH_NL_CALLBACK_FINISHED,
-               .event_source = 0,
-               .nl_socket = NULL,
-               .msg = NULL,
-               .cb = NULL,
-               .s_cb = NULL,
-               .station_list = NULL,
-       };
-       int err = WMESHD_ERROR_NONE;
-       int device_index = 0;
-       int ret;
-
-       ret = __initialize_nl80211(&state);
-       if (WMESHD_ERROR_NONE != ret) {
-               WMESH_LOGE("Failed to initialize nl80211");
-               return ret;
-       }
-
-       ret = __initialize_netlink_message(&state);
-       if (WMESHD_ERROR_NONE != ret) {
-               WMESH_LOGE("Failed to initialize netlink message");
-               goto DESTROY;
-       }
-
-       /* Set command into message */
-       genlmsg_put(state.msg, 0, 0, state.nl80211_id, 0,
-                   NLM_F_DUMP, NL80211_CMD_DEL_STATION, 0);
-
-       /* Add attributes into message */
-       WMESH_LOGD("Delete a station [%s] with interface [%s]", peer, if_name);
-       ret = __get_device_index_from_string(if_name, &device_index);
-       if (WMESHD_ERROR_NONE != ret) {
-               WMESH_LOGE("Failed to get mesh interface device index");
-               err = ret;
-               goto DESTROY;
-       }
-       NLA_PUT_U32(state.msg, NL80211_ATTR_IFINDEX, device_index);
-       NLA_PUT(state.msg, NL80211_ATTR_MAC, ETH_ALEN, peer);
-
-       /* Send message into kernel */
-       ret = nl_send_auto(state.nl_socket, state.msg);
-       if (ret < 0) {
-               WMESH_LOGE("Failed to nl_send_auto() [%s](%d)",
-                               nl_geterror(ret), ret);
-               err = WMESHD_ERROR_OPERATION_FAILED;
-               goto DESTROY;
-       }
-
-DESTROY:
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return err;
-
-nla_put_failure:
-       WMESH_LOGE("Failed to message build");
-       __clean_netlink_message(&state);
-       __clean_nl80211(&state);
-
-       return WMESHD_ERROR_OPERATION_FAILED;
-}
-
 static int _send_nl_get_mpath_info(const char* if_name, GList **mpath_list)
 {
        mesh_nl_state state = {
@@ -1838,25 +1772,6 @@ int wmesh_netlink_get_station_info(const char* mesh_if_name, GList **station_lis
        return ret;
 }
 
-int wmesh_netlink_del_station_info(const char* mesh_if_name, char *peer)
-{
-       int ret = WMESHD_ERROR_NONE;
-
-       if (NULL == mesh_if_name || strlen(mesh_if_name) > IFNAMSIZ) {
-               WMESH_LOGE("Invalid parameter [%p]", mesh_if_name);
-               return WMESHD_ERROR_INVALID_PARAMETER;
-       }
-       if (NULL == peer) {
-               WMESH_LOGE("Invalid parameter [%p]", peer);
-               return WMESHD_ERROR_INVALID_PARAMETER;
-       }
-
-       WMESH_LOGD("Del connected station : [%s]", peer);
-       ret = _send_nl_del_station_info(mesh_if_name, peer);
-
-       return ret;
-}
-
 int wmesh_netlink_get_mpath_info(const char* mesh_if_name, GList **mpath_list)
 {
        int ret = WMESHD_ERROR_NONE;
index bc60ff2..6949eb5 100644 (file)
@@ -85,7 +85,7 @@ static int _get_station_info(void *pdata)
                /* Found this in th existing station infomation list. */
                if (item->inactive_time > item->beacon_interval * MESH_MAXIMUM_BEACON_LOST_COUNT) {
                        /* Remove this node from station list in kernel */
-                       wmesh_netlink_del_station_info(info->mesh_interface, item->bssid);
+                       wmesh_gdbus_mesh_remove_peer(service, item->bssid);
                        /* Remove current linked list */
                        sta_list = g_list_remove(iter, item);
                        /* Send existing node disjoined */