Skip to content

Commit aea6a3f

Browse files
nbd168jmberg-intel
authored andcommitted
mac80211: skip encap offload for tx multicast/control packets
This simplifies the checks in the encap offload tx handler and allows using it in cases where software crypto is used for multicast packets, e.g. when using an AP_VLAN. Signed-off-by: Felix Fietkau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 96ae9cd commit aea6a3f

File tree

1 file changed

+19
-55
lines changed

1 file changed

+19
-55
lines changed

net/mac80211/tx.c

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4193,88 +4193,47 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
41934193
struct sk_buff *skb)
41944194
{
41954195
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
4196-
struct ethhdr *ehdr = (struct ethhdr *)skb->data;
41974196
struct ieee80211_local *local = sdata->local;
4198-
bool authorized = false;
4199-
bool multicast;
4200-
unsigned char *ra = ehdr->h_dest;
42014197
struct tid_ampdu_tx *tid_tx;
42024198
u8 tid;
42034199

4204-
if (IS_ERR(sta) || (sta && !sta->uploaded))
4205-
sta = NULL;
4206-
4207-
if (sdata->vif.type == NL80211_IFTYPE_STATION &&
4208-
(!sta || !test_sta_flag(sta, WLAN_STA_TDLS_PEER)))
4209-
ra = sdata->u.mgd.bssid;
4210-
4211-
if (is_zero_ether_addr(ra))
4212-
goto out_free;
4213-
42144200
if (local->ops->wake_tx_queue) {
42154201
u16 queue = __ieee80211_select_queue(sdata, sta, skb);
42164202
skb_set_queue_mapping(skb, queue);
42174203
skb_get_hash(skb);
42184204
}
42194205

4220-
multicast = is_multicast_ether_addr(ra);
4221-
4222-
if (sta)
4223-
authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
4224-
4225-
if (!multicast && !authorized &&
4226-
(ehdr->h_proto != sdata->control_port_protocol ||
4227-
!ether_addr_equal(sdata->vif.addr, ehdr->h_source)))
4228-
goto out_free;
4229-
4230-
if (multicast && sdata->vif.type == NL80211_IFTYPE_AP &&
4231-
!atomic_read(&sdata->u.ap.num_mcast_sta))
4232-
goto out_free;
4233-
42344206
if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) &&
42354207
test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
42364208
goto out_free;
42374209

42384210
memset(info, 0, sizeof(*info));
42394211

4240-
if (sta) {
4241-
tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
4242-
tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
4243-
if (tid_tx) {
4244-
if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
4245-
/* fall back to non-offload slow path */
4246-
__ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
4247-
return;
4248-
}
4249-
4250-
info->flags |= IEEE80211_TX_CTL_AMPDU;
4251-
if (tid_tx->timeout)
4252-
tid_tx->last_tx = jiffies;
4212+
tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
4213+
tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[tid]);
4214+
if (tid_tx) {
4215+
if (!test_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state)) {
4216+
/* fall back to non-offload slow path */
4217+
__ieee80211_subif_start_xmit(skb, dev, 0, 0, NULL);
4218+
return;
42534219
}
4220+
4221+
info->flags |= IEEE80211_TX_CTL_AMPDU;
4222+
if (tid_tx->timeout)
4223+
tid_tx->last_tx = jiffies;
42544224
}
42554225

4256-
if (unlikely(!multicast && skb->sk &&
4226+
if (unlikely(skb->sk &&
42574227
skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS))
42584228
info->ack_frame_id = ieee80211_store_ack_skb(local, skb,
42594229
&info->flags, NULL);
42604230

4261-
if (unlikely(sdata->control_port_protocol == ehdr->h_proto)) {
4262-
if (sdata->control_port_no_encrypt)
4263-
info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
4264-
info->control.flags |= IEEE80211_TX_CTRL_PORT_CTRL_PROTO;
4265-
}
4266-
4267-
if (multicast)
4268-
info->flags |= IEEE80211_TX_CTL_NO_ACK;
4269-
42704231
info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
42714232

42724233
ieee80211_tx_stats(dev, skb->len);
42734234

4274-
if (sta) {
4275-
sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
4276-
sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
4277-
}
4235+
sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
4236+
sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
42784237

42794238
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
42804239
sdata = container_of(sdata->bss,
@@ -4295,6 +4254,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
42954254
struct net_device *dev)
42964255
{
42974256
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
4257+
struct ethhdr *ehdr = (struct ethhdr *)skb->data;
42984258
struct sta_info *sta;
42994259

43004260
if (WARN_ON(!sdata->hw_80211_encap)) {
@@ -4311,6 +4271,10 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
43114271

43124272
if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
43134273
kfree_skb(skb);
4274+
else if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
4275+
!test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
4276+
sdata->control_port_protocol == ehdr->h_proto))
4277+
ieee80211_subif_start_xmit(skb, dev);
43144278
else
43154279
ieee80211_8023_xmit(sdata, dev, sta, skb);
43164280

0 commit comments

Comments
 (0)