From 53fff0890d11429e4186ce9467006015ee311bd0 Mon Sep 17 00:00:00 2001 From: Vulupala Shashank Reddy Date: Wed, 18 Mar 2020 14:53:07 +0530 Subject: [PATCH] qcacld-3.0: Don't add monitor mode if no interface is up Check if any interface is up and if no interface is up do not add monitor mode. Change-Id: I2e1218a14881f597885334c0a195758ed35c5e5b CRs-Fixed: 2644285 --- core/hdd/inc/wlan_hdd_main.h | 9 ++++----- core/hdd/src/wlan_hdd_main.c | 13 +++++-------- core/hdd/src/wlan_hdd_p2p.c | 19 ++++++++++++------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h index 57408510eec5..c2fedf865fdf 100644 --- a/core/hdd/inc/wlan_hdd_main.h +++ b/core/hdd/inc/wlan_hdd_main.h @@ -4154,7 +4154,6 @@ bool wlan_hdd_check_mon_concurrency(void); * wlan_hdd_add_monitor_check() - check for monitor intf and add if needed * @hdd_ctx: pointer to hdd context * @adapter: output pointer to hold created monitor adapter - * @type: type of the interface * @name: name of the interface * @rtnl_held: True if RTNL lock is held * @name_assign_type: the name of assign type of the netdev @@ -4164,8 +4163,8 @@ bool wlan_hdd_check_mon_concurrency(void); */ int wlan_hdd_add_monitor_check(struct hdd_context *hdd_ctx, struct hdd_adapter **adapter, - enum nl80211_iftype type, const char *name, - bool rtnl_held, unsigned char name_assign_type); + const char *name, bool rtnl_held, + unsigned char name_assign_type); /** * wlan_hdd_del_monitor() - delete monitor interface @@ -4195,8 +4194,8 @@ bool wlan_hdd_check_mon_concurrency(void) static inline int wlan_hdd_add_monitor_check(struct hdd_context *hdd_ctx, struct hdd_adapter **adapter, - enum nl80211_iftype type, const char *name, - bool rtnl_held, unsigned char name_assign_type) + const char *name, bool rtnl_held, + unsigned char name_assign_type) { return 0; } diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index c41cf3d2dcbb..b533965a2cd1 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -16652,7 +16652,6 @@ void wlan_hdd_del_monitor(struct hdd_context *hdd_ctx, * wlan_hdd_add_monitor_check() - check for monitor intf and add if needed * @hdd_ctx: pointer to hdd context * @adapter: output pointer to hold created monitor adapter - * @type: type of the interface * @name: name of the interface * @rtnl_held: True if RTNL lock is held * @name_assign_type: the name of assign type of the netdev @@ -16663,25 +16662,23 @@ void wlan_hdd_del_monitor(struct hdd_context *hdd_ctx, int wlan_hdd_add_monitor_check(struct hdd_context *hdd_ctx, struct hdd_adapter **adapter, - enum nl80211_iftype type, const char *name, - bool rtnl_held, unsigned char name_assign_type) + const char *name, bool rtnl_held, + unsigned char name_assign_type) { struct hdd_adapter *sta_adapter; struct hdd_adapter *mon_adapter; uint32_t mode; uint8_t num_open_session = 0; - if (!ucfg_pkt_capture_get_mode(hdd_ctx->psoc)) - return 0; + /* if no interface is up do not add monitor mode */ + if (!hdd_is_any_interface_open(hdd_ctx)) + return -EINVAL; /* * If add interface request is for monitor mode, then it can run in * parallel with only one station interface. * If there is no existing station interface return error */ - if (type != NL80211_IFTYPE_MONITOR) - return 0; - if (QDF_STATUS_SUCCESS != policy_mgr_mode_specific_num_open_sessions( hdd_ctx->psoc, QDF_MONITOR_MODE, diff --git a/core/hdd/src/wlan_hdd_p2p.c b/core/hdd/src/wlan_hdd_p2p.c index b97918e03c01..30a948a12983 100644 --- a/core/hdd/src/wlan_hdd_p2p.c +++ b/core/hdd/src/wlan_hdd_p2p.c @@ -51,6 +51,7 @@ #include "wlan_p2p_cfg_api.h" #include "wlan_policy_mgr_ucfg.h" #include "nan_ucfg_api.h" +#include "wlan_pkt_capture_ucfg_api.h" /* Ms to Time Unit Micro Sec */ #define MS_TO_TU_MUS(x) ((x) * 1024) @@ -722,13 +723,17 @@ struct wireless_dev *__wlan_hdd_add_virtual_intf(struct wiphy *wiphy, } adapter = NULL; - ret = wlan_hdd_add_monitor_check(hdd_ctx, &adapter, type, name, - true, name_assign_type); - if (ret) - return ERR_PTR(-EINVAL); - if (adapter) { - hdd_exit(); - return adapter->dev->ieee80211_ptr; + if ((ucfg_pkt_capture_get_mode(hdd_ctx->psoc)) && + (type == NL80211_IFTYPE_MONITOR)) { + ret = wlan_hdd_add_monitor_check(hdd_ctx, &adapter, name, + true, name_assign_type); + if (ret) + return ERR_PTR(-EINVAL); + + if (adapter) { + hdd_exit(); + return adapter->dev->ieee80211_ptr; + } } if (mode == QDF_SAP_MODE) {