From ddbaec0f4b7b5bf71eb585c17bdf80a72f153229 Mon Sep 17 00:00:00 2001 From: Ravi Joshi Date: Tue, 10 Apr 2018 15:21:13 -0700 Subject: [PATCH] qcacmn: Accept nan responder request without iface name The service layer need not provide the iface name in the responder request to the driver if the request is being rejected. The service layer maps the ndp_instance_id only after accepting the request, if the ndp indication is rejected, the user space has no knowledge of the iface name on which the NDP would have gotten mapped if it were successful CRs-Fixed: 2222041 Change-Id: I94a7de0c98c14dbe2389dd8364b6dd78858a9d0a --- src/os_if_nan.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/os_if_nan.c b/src/os_if_nan.c index c1fa9b8d0c..1f1d3630cd 100644 --- a/src/os_if_nan.c +++ b/src/os_if_nan.c @@ -406,22 +406,36 @@ static int os_if_nan_process_ndp_responder_req(struct wlan_objmgr_psoc *psoc, struct wlan_objmgr_vdev *nan_vdev; struct nan_datapath_responder_req req = {0}; - if (!tb[QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR]) { - cfg80211_err("Interface name string is unavailable"); - return -EINVAL; - } + if (tb[QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR]) { + iface_name = nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR]); - iface_name = nla_data(tb[QCA_WLAN_VENDOR_ATTR_NDP_IFACE_STR]); - /* Check if there is already an existing NAN interface */ - nan_vdev = wlan_util_get_vdev_by_ifname(psoc, iface_name, WLAN_NAN_ID); - if (!nan_vdev) { - cfg80211_err("NAN data interface %s not available", iface_name); - return -EINVAL; - } + /* Check if there is already an existing NAN interface */ + nan_vdev = wlan_util_get_vdev_by_ifname(psoc, iface_name, + WLAN_NAN_ID); + if (!nan_vdev) { + cfg80211_err("NAN data interface %s not available", + iface_name); + return -ENODEV; + } - if (nan_vdev->vdev_mlme.vdev_opmode != QDF_NDI_MODE) { - cfg80211_err("Interface found is not NDI"); - return -EINVAL; + if (nan_vdev->vdev_mlme.vdev_opmode != QDF_NDI_MODE) { + cfg80211_err("Interface found is not NDI"); + return -ENODEV; + } + } else { + /* + * If the data indication is rejected, the userspace + * may not send the iface name. Use the first available NDI + * in that case + */ + cfg80211_debug("ndp rsp rejected, using first available NDI"); + + nan_vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(psoc, + QDF_NDI_MODE, WLAN_NAN_ID); + if (!nan_vdev) { + cfg80211_err("NAN data interface is not available"); + return -ENODEV; + } } state = ucfg_nan_get_ndi_state(nan_vdev);