cfg80211: allow sending vendor events unicast

Sometimes, we may want to transport higher bandwidth data
through vendor events, and in that case sending it multicast
is a bad idea. Allow vendor events to be unicast.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg
2019-02-06 13:17:19 +02:00
parent 7976b1e9e3
commit 55c1fdf0d6
2 changed files with 71 additions and 8 deletions

View File

@@ -5854,6 +5854,7 @@ struct sk_buff *__cfg80211_alloc_event_skb(struct wiphy *wiphy,
struct wireless_dev *wdev,
enum nl80211_commands cmd,
enum nl80211_attrs attr,
unsigned int portid,
int vendor_event_idx,
int approxlen, gfp_t gfp);
@@ -5903,6 +5904,15 @@ cfg80211_vendor_cmd_alloc_reply_skb(struct wiphy *wiphy, int approxlen)
*/
int cfg80211_vendor_cmd_reply(struct sk_buff *skb);
/**
* cfg80211_vendor_cmd_get_sender
* @wiphy: the wiphy
*
* Return the current netlink port ID in a vendor command handler.
* Valid to call only there.
*/
unsigned int cfg80211_vendor_cmd_get_sender(struct wiphy *wiphy);
/**
* cfg80211_vendor_event_alloc - allocate vendor-specific event skb
* @wiphy: the wiphy
@@ -5930,7 +5940,42 @@ cfg80211_vendor_event_alloc(struct wiphy *wiphy, struct wireless_dev *wdev,
{
return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
NL80211_ATTR_VENDOR_DATA,
event_idx, approxlen, gfp);
0, event_idx, approxlen, gfp);
}
/**
* cfg80211_vendor_event_alloc_ucast - alloc unicast vendor-specific event skb
* @wiphy: the wiphy
* @wdev: the wireless device
* @event_idx: index of the vendor event in the wiphy's vendor_events
* @portid: port ID of the receiver
* @approxlen: an upper bound of the length of the data that will
* be put into the skb
* @gfp: allocation flags
*
* This function allocates and pre-fills an skb for an event to send to
* a specific (userland) socket. This socket would previously have been
* obtained by cfg80211_vendor_cmd_get_sender(), and the caller MUST take
* care to register a netlink notifier to see when the socket closes.
*
* 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_ucast(struct wiphy *wiphy,
struct wireless_dev *wdev,
unsigned int portid, int approxlen,
int event_idx, gfp_t gfp)
{
return __cfg80211_alloc_event_skb(wiphy, wdev, NL80211_CMD_VENDOR,
NL80211_ATTR_VENDOR_DATA,
portid, event_idx, approxlen, gfp);
}
/**
@@ -6030,7 +6075,7 @@ static inline struct sk_buff *
cfg80211_testmode_alloc_event_skb(struct wiphy *wiphy, int approxlen, gfp_t gfp)
{
return __cfg80211_alloc_event_skb(wiphy, NULL, NL80211_CMD_TESTMODE,
NL80211_ATTR_TESTDATA, -1,
NL80211_ATTR_TESTDATA, 0, -1,
approxlen, gfp);
}