Skip to content

Commit

Permalink
cfg80211: add event for unexpected 4addr frames
Browse files Browse the repository at this point in the history
The frames are used by AP/STA WDS mode, and hostapd
needs to know when such a frame was received to set
up the VLAN appropriately to allow using it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
jmberg-intel authored and linvjw committed Nov 9, 2011
1 parent ee97192 commit b92ab5d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
10 changes: 9 additions & 1 deletion include/linux/nl80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,13 @@
* For the event, the %NL80211_ATTR_MAC attribute carries the TA and
* other attributes like the interface index are present.
* If used as the command it must have an interface index and you can
* only unsubscribe from the event by closing the socket.
* only unsubscribe from the event by closing the socket. Subscription
* is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events.
*
* @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the
* associated station identified by %NL80211_ATTR_MAC sent a 4addr frame
* and wasn't already in a 4-addr VLAN. The event will be sent similarly
* to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener.
*
* @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface
* by sending a null data frame to it and reporting when the frame is
Expand Down Expand Up @@ -667,6 +673,8 @@ enum nl80211_commands {

NL80211_CMD_REGISTER_BEACONS,

NL80211_CMD_UNEXPECTED_4ADDR_FRAME,

/* add new commands above here */

/* used to define NL80211_CMD_MAX below */
Expand Down
16 changes: 16 additions & 0 deletions include/net/cfg80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -3226,6 +3226,22 @@ void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index,
bool cfg80211_rx_spurious_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp);

/**
* cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame
* @dev: The device the frame matched to
* @addr: the transmitter address
* @gfp: context flags
*
* This function is used in AP mode (only!) to inform userspace that
* an associated station sent a 4addr frame but that wasn't expected.
* It is allowed and desirable to send this event only once for each
* station to avoid event flooding.
* Returns %true if the frame was passed to userspace (or this failed
* for a reason other than not having a subscription.)
*/
bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp);

/**
* cfg80211_probe_status - notify userspace about probe status
* @dev: the device the probe was sent on
Expand Down
14 changes: 14 additions & 0 deletions net/wireless/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,3 +1123,17 @@ bool cfg80211_rx_spurious_frame(struct net_device *dev,
return nl80211_unexpected_frame(dev, addr, gfp);
}
EXPORT_SYMBOL(cfg80211_rx_spurious_frame);

bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp)
{
struct wireless_dev *wdev = dev->ieee80211_ptr;

if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP &&
wdev->iftype != NL80211_IFTYPE_P2P_GO &&
wdev->iftype != NL80211_IFTYPE_AP_VLAN))
return false;

return nl80211_unexpected_4addr_frame(dev, addr, gfp);
}
EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame);
19 changes: 17 additions & 2 deletions net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -7289,7 +7289,8 @@ void nl80211_send_sta_del_event(struct cfg80211_registered_device *rdev,
nlmsg_free(msg);
}

bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp)
static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd,
const u8 *addr, gfp_t gfp)
{
struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
Expand All @@ -7305,7 +7306,7 @@ bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp)
if (!msg)
return true;

hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_UNEXPECTED_FRAME);
hdr = nl80211hdr_put(msg, 0, 0, 0, cmd);
if (!hdr) {
nlmsg_free(msg);
return true;
Expand All @@ -7330,6 +7331,20 @@ bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp)
return true;
}

bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp)
{
return __nl80211_unexpected_frame(dev, NL80211_CMD_UNEXPECTED_FRAME,
addr, gfp);
}

bool nl80211_unexpected_4addr_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp)
{
return __nl80211_unexpected_frame(dev,
NL80211_CMD_UNEXPECTED_4ADDR_FRAME,
addr, gfp);
}

int nl80211_send_mgmt(struct cfg80211_registered_device *rdev,
struct net_device *netdev, u32 nlpid,
int freq, const u8 *buf, size_t len, gfp_t gfp)
Expand Down
2 changes: 2 additions & 0 deletions net/wireless/nl80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,7 @@ void nl80211_pmksa_candidate_notify(struct cfg80211_registered_device *rdev,

bool nl80211_unexpected_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp);
bool nl80211_unexpected_4addr_frame(struct net_device *dev,
const u8 *addr, gfp_t gfp);

#endif /* __NET_WIRELESS_NL80211_H */

0 comments on commit b92ab5d

Please sign in to comment.