Commit 6c09e791 authored by Ahmad Kholaif's avatar Ahmad Kholaif Committed by Johannes Berg
Browse files

cfg80211: Allow NL80211_ATTR_IFINDEX to be added to vendor events

This modifies cfg80211_vendor_event_alloc() with an additional argument
struct wireless_dev *wdev. __cfg80211_alloc_event_skb() is modified to
take in *wdev argument, if wdev != NULL, both the NL80211_ATTR_IFINDEX
and wdev identifier are added to the vendor event.

These changes make it easier for drivers to add ifindex indication in
vendor events cleanly.

This also updates all existing users of cfg80211_vendor_event_alloc()
and __cfg80211_alloc_event_skb() in the kernel tree.
Signed-off-by: default avatarAhmad Kholaif <>
Signed-off-by: default avatarJouni Malinen <>
Signed-off-by: default avatarJohannes Berg <>
parent ffc11991
......@@ -77,7 +77,7 @@ static int wlcore_smart_config_sync_event(struct wl1271 *wl, u8 sync_channel,
"SMART_CONFIG_SYNC_EVENT_ID, freq: %d (chan: %d band %d)",
freq, sync_channel, sync_band);
skb = cfg80211_vendor_event_alloc(wl->hw->wiphy, 20,
skb = cfg80211_vendor_event_alloc(wl->hw->wiphy, NULL, 20,
......@@ -98,7 +98,7 @@ static int wlcore_smart_config_decode_event(struct wl1271 *wl,
wl1271_dump_ascii(DEBUG_EVENT, "SSID:", ssid, ssid_len);
skb = cfg80211_vendor_event_alloc(wl->hw->wiphy,
skb = cfg80211_vendor_event_alloc(wl->hw->wiphy, NULL,
ssid_len + pwd_len + 20,
......@@ -4295,6 +4295,7 @@ struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
int approxlen);
struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
struct wireless_dev *wdev,
enum nl80211_commands cmd,
enum nl80211_attrs attr,
int vendor_event_idx,
......@@ -4349,6 +4350,7 @@ int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
* cfg80211_vendor_event_alloc - allocate vendor-specific event skb
* @wiphy: the wiphy
* @wdev: the wireless device
* @event_idx: index of the vendor event in the wiphy's vendor_events
* @approxlen: an upper bound of the length of the data that will
* be put into the skb
......@@ -4357,16 +4359,20 @@ int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
* This function allocates and pre-fills an skb for an event on the
* vendor-specific multicast group.
* If wdev != NULL, both the ifindex and identifier of the specified
* wireless device are added to the event message before the vendor data
* attribute.
* When done filling the skb, call cfg80211_vendor_event() with the
* skb to send the event.
* Return: An allocated and pre-filled skb. %NULL if any errors happen.
static inline struct sk_buff *
cfg80211_vendor_event_alloc(struct wiphy *wiphy, int approxlen,
int event_idx, gfp_t gfp)
cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
int approxlen, int event_idx, gfp_t gfp)
return __cfg80211_alloc_event_skb(wiphy, NL80211_CMD_VENDOR,
return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
event_idx, approxlen, gfp);
......@@ -4467,7 +4473,7 @@ static inline int cfg80211_testmode_reply(struct sk_buff *skb)
static inline struct sk_buff *
cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
return __cfg80211_alloc_event_skb(wiphy, NL80211_CMD_TESTMODE,
return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
approxlen, gfp);
......@@ -7389,8 +7389,8 @@ static int nl80211_set_mcast_rate(struct sk_buff *skb, struct genl_info *info)
static struct sk_buff *
__cfg80211_alloc_vendor_skb(struct cfg80211_registered_device *rdev,
int approxlen, u32 portid, u32 seq,
enum nl80211_commands cmd,
struct wireless_dev *wdev, int approxlen,
u32 portid, u32 seq, enum nl80211_commands cmd,
enum nl80211_attrs attr,
const struct nl80211_vendor_cmd_info *info,
gfp_t gfp)
......@@ -7421,6 +7421,16 @@ __cfg80211_alloc_vendor_skb(struct cfg80211_registered_device *rdev,
goto nla_put_failure;
if (wdev) {
if (nla_put_u64(skb, NL80211_ATTR_WDEV,
goto nla_put_failure;
if (wdev->netdev &&
nla_put_u32(skb, NL80211_ATTR_IFINDEX,
goto nla_put_failure;
data = nla_nest_start(skb, attr);
((void **)skb->cb)[0] = rdev;
......@@ -7435,6 +7445,7 @@ __cfg80211_alloc_vendor_skb(struct cfg80211_registered_device *rdev,
struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
struct wireless_dev *wdev,
enum nl80211_commands cmd,
enum nl80211_attrs attr,
int vendor_event_idx,
......@@ -7460,7 +7471,7 @@ struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
return NULL;
return __cfg80211_alloc_vendor_skb(rdev, approxlen, 0, 0,
return __cfg80211_alloc_vendor_skb(rdev, wdev, approxlen, 0, 0,
cmd, attr, info, gfp);
......@@ -9906,7 +9917,7 @@ struct sk_buff *__cfg80211_alloc_reply_skb(struct wiphy *wiphy,
if (WARN_ON(!rdev->cur_cmd_info))
return NULL;
return __cfg80211_alloc_vendor_skb(rdev, approxlen,
return __cfg80211_alloc_vendor_skb(rdev, NULL, approxlen,
cmd, attr, NULL, GFP_KERNEL);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment