Skip to content

Commit 27f852d

Browse files
committed
wifi: mac80211: tx: simplify chanctx_conf handling
In ieee80211_build_hdr() we do the same thing for all interface types except for AP_VLAN, but we can simplify the code by pulling the common thing in front of the switch and overriding it for AP_VLAN. This will also simplify the code for MLD here later. Signed-off-by: Johannes Berg <[email protected]>
1 parent e5c0ee0 commit 27f852d

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

net/mac80211/tx.c

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,8 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
25842584
ethertype = (skb->data[12] << 8) | skb->data[13];
25852585
fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
25862586

2587+
chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
2588+
25872589
switch (sdata->vif.type) {
25882590
case NL80211_IFTYPE_AP_VLAN:
25892591
if (sdata->wdev.use_4addr) {
@@ -2597,31 +2599,20 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
25972599
authorized = test_sta_flag(sta, WLAN_STA_AUTHORIZED);
25982600
wme_sta = sta->sta.wme;
25992601
}
2602+
/* override chanctx_conf from AP (we don't have one) */
26002603
ap_sdata = container_of(sdata->bss, struct ieee80211_sub_if_data,
26012604
u.ap);
26022605
chanctx_conf = rcu_dereference(ap_sdata->vif.bss_conf.chanctx_conf);
2603-
if (!chanctx_conf) {
2604-
ret = -ENOTCONN;
2605-
goto free;
2606-
}
2607-
band = chanctx_conf->def.chan->band;
26082606
if (sdata->wdev.use_4addr)
26092607
break;
26102608
fallthrough;
26112609
case NL80211_IFTYPE_AP:
2612-
if (sdata->vif.type == NL80211_IFTYPE_AP)
2613-
chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
2614-
if (!chanctx_conf) {
2615-
ret = -ENOTCONN;
2616-
goto free;
2617-
}
26182610
fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
26192611
/* DA BSSID SA */
26202612
memcpy(hdr.addr1, skb->data, ETH_ALEN);
26212613
memcpy(hdr.addr2, sdata->vif.addr, ETH_ALEN);
26222614
memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
26232615
hdrlen = 24;
2624-
band = chanctx_conf->def.chan->band;
26252616
break;
26262617
#ifdef CONFIG_MAC80211_MESH
26272618
case NL80211_IFTYPE_MESH_POINT:
@@ -2689,12 +2680,6 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
26892680
skb->data + ETH_ALEN);
26902681

26912682
}
2692-
chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
2693-
if (!chanctx_conf) {
2694-
ret = -ENOTCONN;
2695-
goto free;
2696-
}
2697-
band = chanctx_conf->def.chan->band;
26982683

26992684
/* For injected frames, fill RA right away as nexthop lookup
27002685
* will be skipped.
@@ -2732,44 +2717,32 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
27322717
memcpy(hdr.addr3, skb->data, ETH_ALEN);
27332718
hdrlen = 24;
27342719
}
2735-
chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
2736-
if (!chanctx_conf) {
2737-
ret = -ENOTCONN;
2738-
goto free;
2739-
}
2740-
band = chanctx_conf->def.chan->band;
27412720
break;
27422721
case NL80211_IFTYPE_OCB:
27432722
/* DA SA BSSID */
27442723
memcpy(hdr.addr1, skb->data, ETH_ALEN);
27452724
memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
27462725
eth_broadcast_addr(hdr.addr3);
27472726
hdrlen = 24;
2748-
chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
2749-
if (!chanctx_conf) {
2750-
ret = -ENOTCONN;
2751-
goto free;
2752-
}
2753-
band = chanctx_conf->def.chan->band;
27542727
break;
27552728
case NL80211_IFTYPE_ADHOC:
27562729
/* DA SA BSSID */
27572730
memcpy(hdr.addr1, skb->data, ETH_ALEN);
27582731
memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
27592732
memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN);
27602733
hdrlen = 24;
2761-
chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
2762-
if (!chanctx_conf) {
2763-
ret = -ENOTCONN;
2764-
goto free;
2765-
}
2766-
band = chanctx_conf->def.chan->band;
27672734
break;
27682735
default:
27692736
ret = -EINVAL;
27702737
goto free;
27712738
}
27722739

2740+
if (!chanctx_conf) {
2741+
ret = -ENOTCONN;
2742+
goto free;
2743+
}
2744+
band = chanctx_conf->def.chan->band;
2745+
27732746
multicast = is_multicast_ether_addr(hdr.addr1);
27742747

27752748
/* sta is always NULL for mesh */

0 commit comments

Comments
 (0)