qcacld-3.0: Update cfg80211_vendor_event_alloc for Kernel upgrade
Commit: 6c09e79 ("cfg80211: Allow NL80211_ATTR_IFINDEX to be added
to vendor events")
This commit add parameter wdev to cfg80211_vendor_event_alloc(), that would
be used to check at __cfg80211_alloc_vendor_skb() to assign ifindex to
the skb and is merged in Kernel 4.1, so add a kernel version macro to
support this
Also merge the hdd_vendor_put_ifindex into cfg80211_vendor_event_alloc
to assign the ifindex when wdev is given, that way we can unify the interface.
Change-Id: I321e12bfe3f9160a8a0fcfeb2408f6336d50e2c5
CRs-fixed: 964291
diff --git a/core/hdd/src/wlan_hdd_cfg80211.h b/core/hdd/src/wlan_hdd_cfg80211.h
index eaa82be..3b0cdbf 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.h
+++ b/core/hdd/src/wlan_hdd_cfg80211.h
@@ -2390,14 +2390,37 @@
int wlan_hdd_cfg80211_update_apies(hdd_adapter_t *adapter);
-#if !(defined (SUPPORT_WDEV_CFG80211_VENDOR_EVENT_ALLOC))
+#if !(defined (SUPPORT_WDEV_CFG80211_VENDOR_EVENT_ALLOC)) && \
+ (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && \
+ !(defined(WITH_BACKPORTS))
+
static inline struct sk_buff *
backported_cfg80211_vendor_event_alloc(struct wiphy *wiphy,
struct wireless_dev *wdev,
int approxlen,
int event_idx, gfp_t gfp)
{
- return cfg80211_vendor_event_alloc(wiphy, approxlen, event_idx, gfp);
+ struct sk_buff *skb;
+
+ skb = cfg80211_vendor_event_alloc(wiphy, approxlen, event_idx, gfp);
+
+ if (skb && wdev) {
+ struct nlattr *attr;
+ u32 ifindex = wdev->netdev->ifindex;
+
+ nla_nest_cancel(skb, ((void **)skb->cb)[2]);
+ if (nla_put_u32(skb, NL80211_ATTR_IFINDEX, ifindex))
+ goto nla_fail;
+
+ attr = nla_nest_start(skb, NL80211_ATTR_VENDOR_DATA);
+ ((void **)skb->cb)[2] = attr;
+ }
+
+ return skb;
+
+nla_fail:
+ kfree_skb(skb);
+ return NULL;
}
#define cfg80211_vendor_event_alloc backported_cfg80211_vendor_event_alloc
#endif