1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 30 Sep 2024 17:05:18 +0200
3 Subject: [PATCH] wifi: mac80211: add support for the monitor SKIP_TX flag
5 Do not pass locally sent packets to monitor interfaces with this flag set.
6 Skip processing tx packets on the status call entirely if no monitor
7 interfaces without this flag are present.
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 --- a/net/mac80211/ieee80211_i.h
13 +++ b/net/mac80211/ieee80211_i.h
14 @@ -1374,7 +1374,7 @@ struct ieee80211_local {
15 spinlock_t queue_stop_reason_lock;
18 - int monitors, cooked_mntrs;
19 + int monitors, cooked_mntrs, tx_mntrs;
20 /* number of interfaces with corresponding FIF_ flags */
21 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
23 --- a/net/mac80211/iface.c
24 +++ b/net/mac80211/iface.c
25 @@ -1094,6 +1094,8 @@ void ieee80211_adjust_monitor_flags(stru
26 ADJUST(CONTROL, control);
27 ADJUST(CONTROL, pspoll);
28 ADJUST(OTHER_BSS, other_bss);
29 + if (!(flags & MONITOR_FLAG_SKIP_TX))
30 + local->tx_mntrs += offset;
34 --- a/net/mac80211/status.c
35 +++ b/net/mac80211/status.c
36 @@ -927,6 +927,9 @@ void ieee80211_tx_monitor(struct ieee802
37 if (!ieee80211_sdata_running(sdata))
40 + if (sdata->u.mntr.flags & MONITOR_FLAG_SKIP_TX)
43 if ((sdata->u.mntr.flags & MONITOR_FLAG_COOK_FRAMES) &&
46 @@ -1099,7 +1102,7 @@ static void __ieee80211_tx_status(struct
47 * This is a bit racy but we can avoid a lot of work
50 - if (!local->monitors && (!send_to_cooked || !local->cooked_mntrs)) {
51 + if (!local->tx_mntrs && (!send_to_cooked || !local->cooked_mntrs)) {
52 if (status->free_list)
53 list_add_tail(&skb->list, status->free_list);