Skip to content

Commit 286e696

Browse files
alexw65500jmberg-intel
authored andcommitted
wifi: mac80211: Drop cooked monitor support
Hostapd switched from cooked monitor interfaces to nl80211 Dec 2011. Drop support for the outdated cooked monitor interfaces and fix creating the virtual monitor interfaces in the following cases: 1) We have one non-monitor and one monitor interface with %MONITOR_FLAG_ACTIVE enabled and then delete the non-monitor interface. 2) We only have monitor interfaces enabled on resume while at least one has %MONITOR_FLAG_ACTIVE set. Signed-off-by: Alexander Wetzel <Alexander@wetzel-home.de> Link: https://patch.msgid.link/20250204111352.7004-2-Alexander@wetzel-home.de Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent be22179 commit 286e696

File tree

9 files changed

+94
-249
lines changed

9 files changed

+94
-249
lines changed

include/net/dropreason.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ enum skb_drop_reason_subsys {
1717
*/
1818
SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE,
1919

20-
/**
21-
* @SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR: mac80211 drop reasons
22-
* for frames still going to monitor, see net/mac80211/drop.h
23-
*/
24-
SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR,
25-
2620
/**
2721
* @SKB_DROP_REASON_SUBSYS_OPENVSWITCH: openvswitch drop reasons,
2822
* see net/openvswitch/drop.h

net/mac80211/cfg.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,14 @@ static int ieee80211_set_mon_options(struct ieee80211_sub_if_data *sdata,
8989

9090
/* check flags first */
9191
if (params->flags && ieee80211_sdata_running(sdata)) {
92-
u32 mask = MONITOR_FLAG_COOK_FRAMES | MONITOR_FLAG_ACTIVE;
92+
u32 mask = MONITOR_FLAG_ACTIVE;
9393

9494
/*
95-
* Prohibit MONITOR_FLAG_COOK_FRAMES and
96-
* MONITOR_FLAG_ACTIVE to be changed while the
97-
* interface is up.
95+
* Prohibit MONITOR_FLAG_ACTIVE to be changed
96+
* while the interface is up.
9897
* Else we would need to add a lot of cruft
9998
* to update everything:
100-
* cooked_mntrs, monitor and all fif_* counters
99+
* monitor and all fif_* counters
101100
* reconfigure hardware
102101
*/
103102
if ((params->flags & mask) != (sdata->u.mntr.flags & mask))

net/mac80211/drop.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111

1212
typedef unsigned int __bitwise ieee80211_rx_result;
1313

14-
#define MAC80211_DROP_REASONS_MONITOR(R) \
15-
R(RX_DROP_M_UNEXPECTED_4ADDR_FRAME) \
16-
R(RX_DROP_M_BAD_BCN_KEYIDX) \
17-
R(RX_DROP_M_BAD_MGMT_KEYIDX) \
18-
/* this line for the trailing \ - add before this */
19-
2014
#define MAC80211_DROP_REASONS_UNUSABLE(R) \
2115
/* 0x00 == ___RX_DROP_UNUSABLE */ \
2216
R(RX_DROP_U_MIC_FAIL) \
@@ -66,6 +60,10 @@ typedef unsigned int __bitwise ieee80211_rx_result;
6660
R(RX_DROP_U_UNEXPECTED_STA_4ADDR) \
6761
R(RX_DROP_U_UNEXPECTED_VLAN_MCAST) \
6862
R(RX_DROP_U_NOT_PORT_CONTROL) \
63+
R(RX_DROP_U_UNEXPECTED_4ADDR_FRAME) \
64+
R(RX_DROP_U_BAD_BCN_KEYIDX) \
65+
/* 0x30 */ \
66+
R(RX_DROP_U_BAD_MGMT_KEYIDX) \
6967
R(RX_DROP_U_UNKNOWN_ACTION_REJECTED) \
7068
/* this line for the trailing \ - add before this */
7169

@@ -78,22 +76,17 @@ enum ___mac80211_drop_reason {
7876
___RX_QUEUED = SKB_NOT_DROPPED_YET,
7977

8078
#define ENUM(x) ___ ## x,
81-
___RX_DROP_MONITOR = SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR <<
82-
SKB_DROP_REASON_SUBSYS_SHIFT,
83-
MAC80211_DROP_REASONS_MONITOR(ENUM)
84-
8579
___RX_DROP_UNUSABLE = SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE <<
8680
SKB_DROP_REASON_SUBSYS_SHIFT,
8781
MAC80211_DROP_REASONS_UNUSABLE(ENUM)
8882
#undef ENUM
8983
};
9084

9185
enum mac80211_drop_reason {
92-
RX_CONTINUE = (__force ieee80211_rx_result)___RX_CONTINUE,
93-
RX_QUEUED = (__force ieee80211_rx_result)___RX_QUEUED,
94-
RX_DROP_MONITOR = (__force ieee80211_rx_result)___RX_DROP_MONITOR,
86+
RX_CONTINUE = (__force ieee80211_rx_result)___RX_CONTINUE,
87+
RX_QUEUED = (__force ieee80211_rx_result)___RX_QUEUED,
88+
RX_DROP = (__force ieee80211_rx_result)___RX_DROP_UNUSABLE,
9589
#define DEF(x) x = (__force ieee80211_rx_result)___ ## x,
96-
MAC80211_DROP_REASONS_MONITOR(DEF)
9790
MAC80211_DROP_REASONS_UNUSABLE(DEF)
9891
#undef DEF
9992
};

net/mac80211/ieee80211_i.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,14 @@ enum ieee80211_packet_rx_flags {
200200
/**
201201
* enum ieee80211_rx_flags - RX data flags
202202
*
203-
* @IEEE80211_RX_CMNTR: received on cooked monitor already
204203
* @IEEE80211_RX_BEACON_REPORTED: This frame was already reported
205204
* to cfg80211_report_obss_beacon().
206205
*
207206
* These flags are used across handling multiple interfaces
208207
* for a single frame.
209208
*/
210209
enum ieee80211_rx_flags {
211-
IEEE80211_RX_CMNTR = BIT(0),
212-
IEEE80211_RX_BEACON_REPORTED = BIT(1),
210+
IEEE80211_RX_BEACON_REPORTED = BIT(0),
213211
};
214212

215213
struct ieee80211_rx_data {
@@ -1380,7 +1378,7 @@ struct ieee80211_local {
13801378
spinlock_t queue_stop_reason_lock;
13811379

13821380
int open_count;
1383-
int monitors, cooked_mntrs, tx_mntrs;
1381+
int monitors, tx_mntrs;
13841382
/* number of interfaces with corresponding FIF_ flags */
13851383
int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
13861384
fif_probe_req;
@@ -1492,7 +1490,7 @@ struct ieee80211_local {
14921490

14931491
/* see iface.c */
14941492
struct list_head interfaces;
1495-
struct list_head mon_list; /* only that are IFF_UP && !cooked */
1493+
struct list_head mon_list; /* only that are IFF_UP */
14961494
struct mutex iflist_mtx;
14971495

14981496
/* Scanning and BSS list */
@@ -2090,8 +2088,7 @@ struct sk_buff *
20902088
ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
20912089
struct sk_buff *skb, u32 info_flags);
20922090
void ieee80211_tx_monitor(struct ieee80211_local *local, struct sk_buff *skb,
2093-
int retry_count, bool send_to_cooked,
2094-
struct ieee80211_tx_status *status);
2091+
int retry_count, struct ieee80211_tx_status *status);
20952092

20962093
void ieee80211_check_fast_xmit(struct sta_info *sta);
20972094
void ieee80211_check_fast_xmit_all(struct ieee80211_local *local);

net/mac80211/iface.c

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,6 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
483483
ieee80211_ibss_stop(sdata);
484484
break;
485485
case NL80211_IFTYPE_MONITOR:
486-
if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES)
487-
break;
488486
list_del_rcu(&sdata->u.mntr.list);
489487
break;
490488
default:
@@ -584,18 +582,17 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do
584582
/* no need to tell driver */
585583
break;
586584
case NL80211_IFTYPE_MONITOR:
587-
if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) {
588-
local->cooked_mntrs--;
589-
break;
590-
}
585+
if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) &&
586+
!ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) {
591587

592-
local->monitors--;
593-
if (local->monitors == 0) {
594-
local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR;
595-
hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
596-
}
588+
local->monitors--;
589+
if (local->monitors == 0) {
590+
local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR;
591+
hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
592+
}
597593

598-
ieee80211_adjust_monitor_flags(sdata, -1);
594+
ieee80211_adjust_monitor_flags(sdata, -1);
595+
}
599596
break;
600597
case NL80211_IFTYPE_NAN:
601598
/* clean all the functions */
@@ -1326,27 +1323,24 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
13261323
}
13271324
break;
13281325
case NL80211_IFTYPE_MONITOR:
1329-
if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) {
1330-
local->cooked_mntrs++;
1331-
break;
1332-
}
1333-
13341326
if ((sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE) ||
13351327
ieee80211_hw_check(&local->hw, NO_VIRTUAL_MONITOR)) {
13361328
res = drv_add_interface(local, sdata);
13371329
if (res)
13381330
goto err_stop;
1339-
} else if (local->monitors == 0 && local->open_count == 0) {
1340-
res = ieee80211_add_virtual_monitor(local);
1341-
if (res)
1342-
goto err_stop;
1343-
}
1331+
} else {
1332+
if (local->monitors == 0 && local->open_count == 0) {
1333+
res = ieee80211_add_virtual_monitor(local);
1334+
if (res)
1335+
goto err_stop;
1336+
}
1337+
local->monitors++;
13441338

1345-
/* must be before the call to ieee80211_configure_filter */
1346-
local->monitors++;
1347-
if (local->monitors == 1) {
1348-
local->hw.conf.flags |= IEEE80211_CONF_MONITOR;
1349-
hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
1339+
/* must be before the call to ieee80211_configure_filter */
1340+
if (local->monitors == 1) {
1341+
local->hw.conf.flags |= IEEE80211_CONF_MONITOR;
1342+
hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
1343+
}
13501344
}
13511345

13521346
ieee80211_adjust_monitor_flags(sdata, 1);
@@ -1423,8 +1417,6 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
14231417
rcu_assign_pointer(local->p2p_sdata, sdata);
14241418
break;
14251419
case NL80211_IFTYPE_MONITOR:
1426-
if (sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES)
1427-
break;
14281420
list_add_tail_rcu(&sdata->u.mntr.list, &local->mon_list);
14291421
break;
14301422
default:

net/mac80211/main.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,18 +1744,7 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
17441744
wiphy_free(local->hw.wiphy);
17451745
}
17461746
EXPORT_SYMBOL(ieee80211_free_hw);
1747-
1748-
static const char * const drop_reasons_monitor[] = {
1749-
#define V(x) #x,
1750-
[0] = "RX_DROP_MONITOR",
1751-
MAC80211_DROP_REASONS_MONITOR(V)
1752-
};
1753-
1754-
static struct drop_reason_list drop_reason_list_monitor = {
1755-
.reasons = drop_reasons_monitor,
1756-
.n_reasons = ARRAY_SIZE(drop_reasons_monitor),
1757-
};
1758-
1747+
#define V(x) #x,
17591748
static const char * const drop_reasons_unusable[] = {
17601749
[0] = "RX_DROP_UNUSABLE",
17611750
MAC80211_DROP_REASONS_UNUSABLE(V)
@@ -1784,8 +1773,6 @@ static int __init ieee80211_init(void)
17841773
if (ret)
17851774
goto err_netdev;
17861775

1787-
drop_reasons_register_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR,
1788-
&drop_reason_list_monitor);
17891776
drop_reasons_register_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE,
17901777
&drop_reason_list_unusable);
17911778

@@ -1804,7 +1791,6 @@ static void __exit ieee80211_exit(void)
18041791

18051792
ieee80211_iface_exit();
18061793

1807-
drop_reasons_unregister_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_MONITOR);
18081794
drop_reasons_unregister_subsys(SKB_DROP_REASON_SUBSYS_MAC80211_UNUSABLE);
18091795

18101796
rcu_barrier();

0 commit comments

Comments
 (0)