Skip to content

Commit 018f6fb

Browse files
denkenzjmberg-intel
authored andcommitted
mac80211: Send control port frames over nl80211
If userspace requested control port frames to go over 80211, then do so. The control packets are intercepted just prior to delivery of the packet to the underlying network device. Pre-authentication type frames (protocol: 0x88c7) are also forwarded over nl80211. Signed-off-by: Denis Kenzior <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 9118064 commit 018f6fb

File tree

7 files changed

+42
-5
lines changed

7 files changed

+42
-5
lines changed

net/mac80211/cfg.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,8 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
926926
*/
927927
sdata->control_port_protocol = params->crypto.control_port_ethertype;
928928
sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
929+
sdata->control_port_over_nl80211 =
930+
params->crypto.control_port_over_nl80211;
929931
sdata->encrypt_headroom = ieee80211_cs_headroom(sdata->local,
930932
&params->crypto,
931933
sdata->vif.type);
@@ -935,6 +937,8 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
935937
params->crypto.control_port_ethertype;
936938
vlan->control_port_no_encrypt =
937939
params->crypto.control_port_no_encrypt;
940+
vlan->control_port_over_nl80211 =
941+
params->crypto.control_port_over_nl80211;
938942
vlan->encrypt_headroom =
939943
ieee80211_cs_headroom(sdata->local,
940944
&params->crypto,
@@ -2020,6 +2024,8 @@ static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
20202024
if (err)
20212025
return err;
20222026

2027+
sdata->control_port_over_nl80211 = setup->control_port_over_nl80211;
2028+
20232029
/* can mesh use other SMPS modes? */
20242030
sdata->smps_mode = IEEE80211_SMPS_OFF;
20252031
sdata->needed_rx_chains = sdata->local->rx_chains;

net/mac80211/ibss.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
18441844

18451845
sdata->smps_mode = IEEE80211_SMPS_OFF;
18461846
sdata->needed_rx_chains = local->rx_chains;
1847+
sdata->control_port_over_nl80211 = params->control_port_over_nl80211;
18471848

18481849
ieee80211_queue_work(&local->hw, &sdata->work);
18491850

net/mac80211/ieee80211_i.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ struct ieee80211_sub_if_data {
900900
u16 sequence_number;
901901
__be16 control_port_protocol;
902902
bool control_port_no_encrypt;
903+
bool control_port_over_nl80211;
903904
int encrypt_headroom;
904905

905906
atomic_t num_tx_queued;

net/mac80211/iface.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
519519
master->control_port_protocol;
520520
sdata->control_port_no_encrypt =
521521
master->control_port_no_encrypt;
522+
sdata->control_port_over_nl80211 =
523+
master->control_port_over_nl80211;
522524
sdata->vif.cab_queue = master->vif.cab_queue;
523525
memcpy(sdata->vif.hw_queue, master->vif.hw_queue,
524526
sizeof(sdata->vif.hw_queue));

net/mac80211/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,8 @@ struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
554554
NL80211_FEATURE_USERSPACE_MPM |
555555
NL80211_FEATURE_FULL_AP_CLIENT_STATE;
556556
wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_FILS_STA);
557+
wiphy_ext_feature_set(wiphy,
558+
NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211);
557559

558560
if (!ops->hw_scan)
559561
wiphy->features |= NL80211_FEATURE_LOW_PRIORITY_SCAN |

net/mac80211/mlme.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4855,6 +4855,8 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
48554855

48564856
sdata->control_port_protocol = req->crypto.control_port_ethertype;
48574857
sdata->control_port_no_encrypt = req->crypto.control_port_no_encrypt;
4858+
sdata->control_port_over_nl80211 =
4859+
req->crypto.control_port_over_nl80211;
48584860
sdata->encrypt_headroom = ieee80211_cs_headroom(local, &req->crypto,
48594861
sdata->vif.type);
48604862

net/mac80211/rx.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,6 +2245,32 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
22452245
return true;
22462246
}
22472247

2248+
static void ieee80211_deliver_skb_to_local_stack(struct sk_buff *skb,
2249+
struct ieee80211_rx_data *rx)
2250+
{
2251+
struct ieee80211_sub_if_data *sdata = rx->sdata;
2252+
struct net_device *dev = sdata->dev;
2253+
2254+
if (unlikely((skb->protocol == sdata->control_port_protocol ||
2255+
skb->protocol == cpu_to_be16(ETH_P_PREAUTH)) &&
2256+
sdata->control_port_over_nl80211)) {
2257+
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2258+
bool noencrypt = status->flag & RX_FLAG_DECRYPTED;
2259+
struct ethhdr *ehdr = eth_hdr(skb);
2260+
2261+
cfg80211_rx_control_port(dev, skb->data, skb->len,
2262+
ehdr->h_source,
2263+
be16_to_cpu(skb->protocol), noencrypt);
2264+
dev_kfree_skb(skb);
2265+
} else {
2266+
/* deliver to local stack */
2267+
if (rx->napi)
2268+
napi_gro_receive(rx->napi, skb);
2269+
else
2270+
netif_receive_skb(skb);
2271+
}
2272+
}
2273+
22482274
/*
22492275
* requires that rx->skb is a frame with ethernet header
22502276
*/
@@ -2329,13 +2355,10 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
23292355
#endif
23302356

23312357
if (skb) {
2332-
/* deliver to local stack */
23332358
skb->protocol = eth_type_trans(skb, dev);
23342359
memset(skb->cb, 0, sizeof(skb->cb));
2335-
if (rx->napi)
2336-
napi_gro_receive(rx->napi, skb);
2337-
else
2338-
netif_receive_skb(skb);
2360+
2361+
ieee80211_deliver_skb_to_local_stack(skb, rx);
23392362
}
23402363

23412364
if (xmit_skb) {

0 commit comments

Comments
 (0)