Skip to content

Commit

Permalink
Merge tag 'mac80211-for-net-2021-11-16' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/linux/kernel/git/jberg/mac80211

Johannes Berg says:

====================
Couple of fixes:
 * bad dont-reorder check
 * throughput LED trigger for various new(ish) paths
 * radiotap header generation
 * locking assertions in mac80211 with monitor mode
 * radio statistics
 * don't try to access IV when not present
 * call stop_ap for P2P_GO as well as we should

* tag 'mac80211-for-net-2021-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211:
  mac80211: fix throughput LED trigger
  mac80211: fix monitor_sdata RCU/locking assertions
  mac80211: drop check for DONT_REORDER in __ieee80211_select_queue
  mac80211: fix radiotap header generation
  mac80211: do not access the IV when it was stripped
  nl80211: fix radio statistics in survey dump
  cfg80211: call cfg80211_stop_ap when switch from P2P_GO type
====================

Link: https://lore.kernel.org/r/20211116160845.157214-1-johannes@sipsolutions.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Nov 17, 2021
2 parents f083ec3 + 30f6cf9 commit f5c7416
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 58 deletions.
12 changes: 8 additions & 4 deletions net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata,
}

/* also validate MU-MIMO change */
monitor_sdata = rtnl_dereference(local->monitor_sdata);
monitor_sdata = wiphy_dereference(local->hw.wiphy,
local->monitor_sdata);

if (!monitor_sdata &&
(params->vht_mumimo_groups || params->vht_mumimo_follow_addr))
Expand Down Expand Up @@ -840,7 +841,8 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,

mutex_lock(&local->mtx);
if (local->use_chanctx) {
sdata = rtnl_dereference(local->monitor_sdata);
sdata = wiphy_dereference(local->hw.wiphy,
local->monitor_sdata);
if (sdata) {
ieee80211_vif_release_channel(sdata);
ret = ieee80211_vif_use_channel(sdata, chandef,
Expand Down Expand Up @@ -2707,7 +2709,8 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);

if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
sdata = rtnl_dereference(local->monitor_sdata);
sdata = wiphy_dereference(local->hw.wiphy,
local->monitor_sdata);
if (!sdata)
return -EOPNOTSUPP;
}
Expand Down Expand Up @@ -2767,7 +2770,8 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
mutex_unlock(&local->iflist_mtx);

if (has_monitor) {
sdata = rtnl_dereference(local->monitor_sdata);
sdata = wiphy_dereference(local->hw.wiphy,
local->monitor_sdata);
if (sdata) {
sdata->user_power_level = local->user_power_level;
if (txp_type != sdata->vif.bss_conf.txpower_type)
Expand Down
4 changes: 3 additions & 1 deletion net/mac80211/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
*/
if (local->suspended) {
WARN_ON(local->wowlan);
WARN_ON(rtnl_dereference(local->monitor_sdata));
WARN_ON(rcu_access_pointer(local->monitor_sdata));
return;
}

Expand Down Expand Up @@ -961,6 +961,7 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
return 0;

ASSERT_RTNL();
lockdep_assert_wiphy(local->hw.wiphy);

if (local->monitor_sdata)
return 0;
Expand Down Expand Up @@ -1028,6 +1029,7 @@ void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
return;

ASSERT_RTNL();
lockdep_assert_wiphy(local->hw.wiphy);

mutex_lock(&local->iflist_mtx);

Expand Down
8 changes: 4 additions & 4 deletions net/mac80211/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ static inline void ieee80211_mod_tpt_led_trig(struct ieee80211_local *local,
#endif

static inline void
ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, __le16 fc, int bytes)
ieee80211_tpt_led_trig_tx(struct ieee80211_local *local, int bytes)
{
#ifdef CONFIG_MAC80211_LEDS
if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
if (atomic_read(&local->tpt_led_active))
local->tpt_led_trigger->tx_bytes += bytes;
#endif
}

static inline void
ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, __le16 fc, int bytes)
ieee80211_tpt_led_trig_rx(struct ieee80211_local *local, int bytes)
{
#ifdef CONFIG_MAC80211_LEDS
if (ieee80211_is_data(fc) && atomic_read(&local->tpt_led_active))
if (atomic_read(&local->tpt_led_active))
local->tpt_led_trigger->rx_bytes += bytes;
#endif
}
12 changes: 7 additions & 5 deletions net/mac80211/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local,
* the compiler to think we have walked past the end of the
* struct member.
*/
pos = (void *)&rthdr->it_optional[it_present - rthdr->it_optional];
pos = (void *)&rthdr->it_optional[it_present + 1 - rthdr->it_optional];

/* the order of the following fields is important */

Expand Down Expand Up @@ -1952,7 +1952,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
int keyid = rx->sta->ptk_idx;
sta_ptk = rcu_dereference(rx->sta->ptk[keyid]);

if (ieee80211_has_protected(fc)) {
if (ieee80211_has_protected(fc) &&
!(status->flag & RX_FLAG_IV_STRIPPED)) {
cs = rx->sta->cipher_scheme;
keyid = ieee80211_get_keyid(rx->skb, cs);

Expand Down Expand Up @@ -4863,6 +4864,7 @@ void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta,
struct ieee80211_rate *rate = NULL;
struct ieee80211_supported_band *sband;
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;

WARN_ON_ONCE(softirq_count() == 0);

Expand Down Expand Up @@ -4959,9 +4961,9 @@ void ieee80211_rx_list(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta,
if (!(status->flag & RX_FLAG_8023))
skb = ieee80211_rx_monitor(local, skb, rate);
if (skb) {
ieee80211_tpt_led_trig_rx(local,
((struct ieee80211_hdr *)skb->data)->frame_control,
skb->len);
if ((status->flag & RX_FLAG_8023) ||
ieee80211_is_data_present(hdr->frame_control))
ieee80211_tpt_led_trig_rx(local, skb->len);

if (status->flag & RX_FLAG_8023)
__ieee80211_rx_handle_8023(hw, pubsta, skb, list);
Expand Down
34 changes: 15 additions & 19 deletions net/mac80211/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,21 +1721,19 @@ static bool ieee80211_tx_frags(struct ieee80211_local *local,
* Returns false if the frame couldn't be transmitted but was queued instead.
*/
static bool __ieee80211_tx(struct ieee80211_local *local,
struct sk_buff_head *skbs, int led_len,
struct sta_info *sta, bool txpending)
struct sk_buff_head *skbs, struct sta_info *sta,
bool txpending)
{
struct ieee80211_tx_info *info;
struct ieee80211_sub_if_data *sdata;
struct ieee80211_vif *vif;
struct sk_buff *skb;
bool result;
__le16 fc;

if (WARN_ON(skb_queue_empty(skbs)))
return true;

skb = skb_peek(skbs);
fc = ((struct ieee80211_hdr *)skb->data)->frame_control;
info = IEEE80211_SKB_CB(skb);
sdata = vif_to_sdata(info->control.vif);
if (sta && !sta->uploaded)
Expand Down Expand Up @@ -1769,8 +1767,6 @@ static bool __ieee80211_tx(struct ieee80211_local *local,

result = ieee80211_tx_frags(local, vif, sta, skbs, txpending);

ieee80211_tpt_led_trig_tx(local, fc, led_len);

WARN_ON_ONCE(!skb_queue_empty(skbs));

return result;
Expand Down Expand Up @@ -1920,15 +1916,13 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
ieee80211_tx_result res_prepare;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
bool result = true;
int led_len;

if (unlikely(skb->len < 10)) {
dev_kfree_skb(skb);
return true;
}

/* initialises tx */
led_len = skb->len;
res_prepare = ieee80211_tx_prepare(sdata, &tx, sta, skb);

if (unlikely(res_prepare == TX_DROP)) {
Expand All @@ -1951,8 +1945,7 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
return true;

if (!invoke_tx_handlers_late(&tx))
result = __ieee80211_tx(local, &tx.skbs, led_len,
tx.sta, txpending);
result = __ieee80211_tx(local, &tx.skbs, tx.sta, txpending);

return result;
}
Expand Down Expand Up @@ -4175,6 +4168,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
struct ieee80211_local *local = sdata->local;
struct sta_info *sta;
struct sk_buff *next;
int len = skb->len;

if (unlikely(skb->len < ETH_HLEN)) {
kfree_skb(skb);
Expand Down Expand Up @@ -4221,10 +4215,8 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
}
} else {
/* we cannot process non-linear frames on this path */
if (skb_linearize(skb)) {
kfree_skb(skb);
goto out;
}
if (skb_linearize(skb))
goto out_free;

/* the frame could be fragmented, software-encrypted, and other
* things so we cannot really handle checksum offload with it -
Expand Down Expand Up @@ -4258,7 +4250,10 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
goto out;
out_free:
kfree_skb(skb);
len = 0;
out:
if (len)
ieee80211_tpt_led_trig_tx(local, len);
rcu_read_unlock();
}

Expand Down Expand Up @@ -4396,8 +4391,7 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
}

static bool ieee80211_tx_8023(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb, int led_len,
struct sta_info *sta,
struct sk_buff *skb, struct sta_info *sta,
bool txpending)
{
struct ieee80211_local *local = sdata->local;
Expand All @@ -4410,6 +4404,8 @@ static bool ieee80211_tx_8023(struct ieee80211_sub_if_data *sdata,
if (sta)
sk_pacing_shift_update(skb->sk, local->hw.tx_sk_pacing_shift);

ieee80211_tpt_led_trig_tx(local, skb->len);

if (ieee80211_queue_skb(local, sdata, sta, skb))
return true;

Expand Down Expand Up @@ -4498,7 +4494,7 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
if (key)
info->control.hw_key = &key->conf;

ieee80211_tx_8023(sdata, skb, skb->len, sta, false);
ieee80211_tx_8023(sdata, skb, sta, false);

return;

Expand Down Expand Up @@ -4637,7 +4633,7 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
if (IS_ERR(sta) || (sta && !sta->uploaded))
sta = NULL;

result = ieee80211_tx_8023(sdata, skb, skb->len, sta, true);
result = ieee80211_tx_8023(sdata, skb, sta, true);
} else {
struct sk_buff_head skbs;

Expand All @@ -4647,7 +4643,7 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
hdr = (struct ieee80211_hdr *)skb->data;
sta = sta_info_get(sdata, hdr->addr1);

result = __ieee80211_tx(local, &skbs, skb->len, sta, true);
result = __ieee80211_tx(local, &skbs, sta, true);
}

return result;
Expand Down
7 changes: 4 additions & 3 deletions net/mac80211/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ static void __iterate_interfaces(struct ieee80211_local *local,

sdata = rcu_dereference_check(local->monitor_sdata,
lockdep_is_held(&local->iflist_mtx) ||
lockdep_rtnl_is_held());
lockdep_is_held(&local->hw.wiphy->mtx));
if (sdata &&
(iter_flags & IEEE80211_IFACE_ITER_RESUME_ALL || !active_only ||
sdata->flags & IEEE80211_SDATA_IN_DRIVER))
Expand Down Expand Up @@ -2381,7 +2381,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
IEEE80211_TPT_LEDTRIG_FL_RADIO, 0);

/* add interfaces */
sdata = rtnl_dereference(local->monitor_sdata);
sdata = wiphy_dereference(local->hw.wiphy, local->monitor_sdata);
if (sdata) {
/* in HW restart it exists already */
WARN_ON(local->resuming);
Expand Down Expand Up @@ -2426,7 +2426,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
WARN_ON(drv_add_chanctx(local, ctx));
mutex_unlock(&local->chanctx_mtx);

sdata = rtnl_dereference(local->monitor_sdata);
sdata = wiphy_dereference(local->hw.wiphy,
local->monitor_sdata);
if (sdata && ieee80211_sdata_running(sdata))
ieee80211_assign_chanctx(local, sdata);
}
Expand Down
3 changes: 1 addition & 2 deletions net/mac80211/wme.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ u16 ieee80211_select_queue_80211(struct ieee80211_sub_if_data *sdata,
u16 __ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta, struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct mac80211_qos_map *qos_map;
bool qos;

Expand All @@ -156,7 +155,7 @@ u16 __ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
else
qos = false;

if (!qos || (info->control.flags & IEEE80211_TX_CTRL_DONT_REORDER)) {
if (!qos) {
skb->priority = 0; /* required for correct WPA/11i MIC */
return IEEE80211_AC_BE;
}
Expand Down
Loading

0 comments on commit f5c7416

Please sign in to comment.