Skip to content

Commit d69fd44

Browse files
alexw65500Sasha Levin
authored andcommitted
wifi: mac80211: Add counter for all monitor interfaces
[ Upstream commit 1298600 ] Count open monitor interfaces regardless of the monitor interface type. The new counter virt_monitors takes over counting interfaces depending on the virtual monitor interface while monitors is used for all active monitor interfaces. This fixes monitor packet mirroring when using MONITOR_FLAG_ACTIVE or NO_VIRTUAL_MONITOR interfaces. Fixes: 286e696 ("wifi: mac80211: Drop cooked monitor support") Reported-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com> Closes: https://lore.kernel.org/r/cc715114-4e3b-619a-49dc-a4878075e1dc@quicinc.com Signed-off-by: Alexander Wetzel <Alexander@wetzel-home.de> Tested-by: Karthikeyan Periyasamy <quic_periyasa@quicinc.com> Link: https://patch.msgid.link/20250220094139.61459-1-Alexander@wetzel-home.de Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b2c1fde commit d69fd44

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

net/mac80211/cfg.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4370,9 +4370,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
43704370
if (chanctx_conf) {
43714371
*chandef = link->conf->chanreq.oper;
43724372
ret = 0;
4373-
} else if (!ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR) &&
4374-
local->open_count > 0 &&
4375-
local->open_count == local->monitors &&
4373+
} else if (local->open_count > 0 &&
4374+
local->open_count == local->virt_monitors &&
43764375
sdata->vif.type == NL80211_IFTYPE_MONITOR) {
43774376
*chandef = local->monitor_chanreq.oper;
43784377
ret = 0;

net/mac80211/ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static void ieee80211_get_stats(struct net_device *dev,
158158
if (chanctx_conf)
159159
channel = chanctx_conf->def.chan;
160160
else if (local->open_count > 0 &&
161-
local->open_count == local->monitors &&
161+
local->open_count == local->virt_monitors &&
162162
sdata->vif.type == NL80211_IFTYPE_MONITOR)
163163
channel = local->monitor_chanreq.oper.chan;
164164
else

net/mac80211/ieee80211_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ struct ieee80211_local {
13781378
spinlock_t queue_stop_reason_lock;
13791379

13801380
int open_count;
1381-
int monitors, tx_mntrs;
1381+
int monitors, virt_monitors, tx_mntrs;
13821382
/* number of interfaces with corresponding FIF_ flags */
13831383
int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
13841384
fif_probe_req;

net/mac80211/iface.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,13 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
582582
/* no need to tell driver */
583583
break;
584584
case NL80211_IFTYPE_MONITOR:
585+
local->monitors--;
586+
585587
if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) &&
586588
!ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) {
587589

588-
local->monitors--;
589-
if (local->monitors == 0) {
590+
local->virt_monitors--;
591+
if (local->virt_monitors == 0) {
590592
local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR;
591593
hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
592594
}
@@ -686,7 +688,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
686688
case NL80211_IFTYPE_AP_VLAN:
687689
break;
688690
case NL80211_IFTYPE_MONITOR:
689-
if (local->monitors == 0)
691+
if (local->virt_monitors == 0)
690692
ieee80211_del_virtual_monitor(local);
691693

692694
ieee80211_recalc_idle(local);
@@ -723,7 +725,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
723725
ieee80211_configure_filter(local);
724726
ieee80211_hw_config(local, hw_reconf_flags);
725727

726-
if (local->monitors == local->open_count)
728+
if (local->virt_monitors == local->open_count)
727729
ieee80211_add_virtual_monitor(local);
728730
}
729731

@@ -982,7 +984,7 @@ static bool ieee80211_set_sdata_offload_flags(struct ieee80211_sub_if_data *sdat
982984
local->hw.wiphy->frag_threshold != (u32)-1)
983985
flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED;
984986

985-
if (local->monitors)
987+
if (local->virt_monitors)
986988
flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED;
987989
} else {
988990
flags &= ~IEEE80211_OFFLOAD_ENCAP_ENABLED;
@@ -992,7 +994,7 @@ static bool ieee80211_set_sdata_offload_flags(struct ieee80211_sub_if_data *sdat
992994
ieee80211_iftype_supports_hdr_offload(sdata->vif.type)) {
993995
flags |= IEEE80211_OFFLOAD_DECAP_ENABLED;
994996

995-
if (local->monitors &&
997+
if (local->virt_monitors &&
996998
!ieee80211_hw_check(&local->hw, SUPPORTS_CONC_MON_RX_DECAP))
997999
flags &= ~IEEE80211_OFFLOAD_DECAP_ENABLED;
9981000
} else {
@@ -1336,20 +1338,22 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
13361338
if (res)
13371339
goto err_stop;
13381340
} else {
1339-
if (local->monitors == 0 && local->open_count == 0) {
1341+
if (local->virt_monitors == 0 && local->open_count == 0) {
13401342
res = ieee80211_add_virtual_monitor(local);
13411343
if (res)
13421344
goto err_stop;
13431345
}
1344-
local->monitors++;
1346+
local->virt_monitors++;
13451347

13461348
/* must be before the call to ieee80211_configure_filter */
1347-
if (local->monitors == 1) {
1349+
if (local->virt_monitors == 1) {
13481350
local->hw.conf.flags |= IEEE80211_CONF_MONITOR;
13491351
hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
13501352
}
13511353
}
13521354

1355+
local->monitors++;
1356+
13531357
ieee80211_adjust_monitor_flags(sdata, 1);
13541358
ieee80211_configure_filter(local);
13551359
ieee80211_recalc_offload(local);

net/mac80211/util.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
21562156

21572157
wake_up:
21582158

2159-
if (local->monitors == local->open_count && local->monitors > 0)
2159+
if (local->virt_monitors > 0 &&
2160+
local->virt_monitors == local->open_count)
21602161
ieee80211_add_virtual_monitor(local);
21612162

21622163
/*

0 commit comments

Comments
 (0)