Commit Graph

1427 Commits

Author SHA1 Message Date
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
71625ec9ad sys: Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:24 -06:00
Warner Losh
2ff63af9b8 sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:18 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Bjoern A. Zeeb
d73de45743 net80211: Radiotap: add two more EHT defines
An updated iwlwifi needs further radiotap updates for EHT.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-08-07 01:22:53 +00:00
Bjoern A. Zeeb
63231f4d5b net80211: Radiotap: update for defines
ath1xk drivers require further HE defines.  Some of those we had
already predicted as comments in the past.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-20 00:56:21 +00:00
Bjoern A. Zeeb
7232e6dcc8 net80211: Radiotap: update for newer standards (add EHT, U-SIG)
iwlwifi already uses suggested EHT and U-SIG bits as well as some
more TLV bits.  Update radiotap to know of those even if they might
get updated again in the future in order to get newer versions of
the driver to compile.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-16 16:05:55 +00:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Gordon Bergling
93e4914816 net80211: Remove double words in source code comments
- s/we we/we/

MFC after:	5 days
2023-04-18 07:14:50 +02:00
Mikhail Pchelin
2f53b5991c net80211: fix a typo in Rx MCS set for unequal modulation case
RX MCS set defines which MCSs are supported for RX, bits 0-31 are for equal
modulation of the streams, bits 33-76 are for unequal case. Current code checks
txstreams variable instead of rxstreams to set bits from 53 to 76 for 4 spatial
streams case.

The modulations are defined in tables 19-38 and 19-41 of the IEEE Std
802.11-2020.

Spotted by bz in https://reviews.freebsd.org/D39476

Reviewed by:		bz
Approved by:		bz
Sponsored by:		Serenity Cybersecurity, LLC
Differential Revision:	https://reviews.freebsd.org/D39568
2023-04-14 18:20:09 +03:00
Mikhail Pchelin
ea26545cc5 net80211: wrong transmit MCS set in HT cap IE
Current code checks whether or not txstreams are equal to rxstreams and if it
isn't - sets needed bits in "Transmit MCS Set". But if they are equal it sets
whole set to zero, which contradicts the standard, if tx and rx streams are
equal 'Tx MCS Set Defined' (table 9-186, IEEE Std 802.11-2020) must be set to
one.

Reviewed by:		bz
Approved by:		bz
Sponsored by:		Serenity Cybersecurity, LLC
Differential Revision:	https://reviews.freebsd.org/D39476
2023-04-14 18:16:29 +03:00
domienschepers
61605e0ae5 net80211: fail for unicast traffic without unicast key
Falling back to the multicast key may cause unicast traffic to leak.
Instead fail when no key is found.

For more information see the 'Framing Frames: Bypassing Wi-Fi Encryption
by Manipulating Transmit Queues' paper.

[ I updated the commit message to reference the paper and the code
comment to record historic behaviour as discussed in private email. ]

Security:	CVE-2022-47522
2023-04-10 23:38:57 +00:00
Bjoern A. Zeeb
d7fb679dc9 net80211: make ieee80211_scan_dump_channels private
ieee80211_scan_dump_channels() is only used locally and only when
IEEE80211_DEBUG is compiled.  Stop exporting it, make it file local
and hide under the #ifdef to reduce the footprint for production
kernels a tiny bit.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D38833
2023-03-14 22:17:03 +00:00
Bjoern A. Zeeb
3346164ce8 net80211: define mask for ss_flags rather than using hardcoded 0xfff
scan state ss_flags in two places cut off the "internal" GOTPICK
options.  Replace the hardcoded 0xfff with a defined mask.
Note that "internal" flags is confusing as we also supplement the
the 16bit by another 16bit of "internal flags" passed around but
comaparing to GOTPICK never stored to my understanding.

No functional change.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D38832
2023-03-14 22:16:41 +00:00
Bjoern A. Zeeb
c9ba91435a net80211: ieee80211_swscan_bg_scan() track return variable under lock
As the comment says it probably does not matter but use a local
variable to track state under lock so we can return the last known
good state of what we thought we were operating under after unlocking.

Likely no functional changes.

Sponsored by:	The FreeBSD Foundation
MFC atfer:	3 days
Reviewed by:	enweiwu, adrian
Differential Revision: https://reviews.freebsd.org/D38660
2023-02-23 21:12:23 +00:00
Justin Hibbits
3d0d5b21c9 IfAPI: Explicitly include <net/if_private.h> in netstack
Summary:
In preparation of making if_t completely opaque outside of the netstack,
explicitly include the header.  <net/if_var.h> will stop including the
header in the future.

Sponsored by:	Juniper Networks, Inc.
Reviewed by:	glebius, melifaro
Differential Revision: https://reviews.freebsd.org/D38200
2023-01-31 15:02:16 -05:00
John Baldwin
95d146592f iee80211_hwmp: Don't dereference NULL ni in debug printf.
In this call to IEEE80211_NOTE, ni is always NULL due to the assignment
a few lines earlier at the start of the function.  If debug traces are
enabled, then this will pass an invalid pointer as the 'mac' pointer to
ieee80211_note_mac.  Use IEEE80211_DPRINTF which doesn't take a 'ni'
argument instead.

Reported by:	GCC -Wstringop-overread
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D37626
2022-12-21 10:45:45 -08:00
Alexander V. Chernikov
1bcd230f95 netlink: add interface notification on link status / flags change.
* Add link-state change notifications by subscribing to ifnet_link_event.
 In the Linux netlink model, link state is reported in 2 places: first is
 the IFLA_OPERSTATE, which stores state per RFC2863.
 The second is an IFF_LOWER_UP interface flag. As many applications rely
 on the latter, reserve 1 bit from if_flags, named as IFF_NETLINK_1.
 This flag is mapped to IFF_LOWER_UP in the netlink headers. This is done
 to avoid making applications think this flag is actually
 supported / presented in non-netlink outputs.
* Add flag change notifications, by hooking into rt_ifmsg().
 In the netlink model, notification should include the bitmask for the
 change flags. Update rt_ifmsg() to include such bitmask.

Differential Revision: https://reviews.freebsd.org/D37597
2022-12-09 11:20:07 +00:00
John Baldwin
1f07812095 net80211: Fix mismatches in array bounds.
Reported by:	GCC -Warray-parameter
Reviewed by:	imp, emaste (earlier version)
Differential Revision:	https://reviews.freebsd.org/D37546
2022-12-07 12:31:53 -08:00
Bjoern A. Zeeb
4a8e4d1546 net80211: fix IEEE80211_DEBUG_REFCNT builds
Remove the KPI/KBI changes from ieee80211_node.h and always use the
macros to pass in __func__ and __LINE__ to the functions.
The actual implementations are prefixed by "_" rather than suffixed
by "_debug" as they no longer are "debug"-specific.

Some of the select functions were not actually using the passed in
func, line options; however they are calling other functions which
use them.  Directly call the internal implementation in those cases
passing the arguments on.

Use a file-local __debrefcnt_used define to mark the arguments __unused
in cases when we compile without IEEE80211_DEBUG_REFCNT and hope the
toolchain is intelligent enough to not pass them at all in those cases.

Also _ieee80211_free_node() now has a conflict so make the previous
_ieee80211_free_node() the new __ieee80211_free_node().

Add IEEE80211_DEBUG_REFCNT to the NOTES file on amd64 to keep exercising
the option.

Sponsored by:	The FreeBSD Foundation
X-MFC:		never
Discussed on:	freebsd-wireless
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D37529
2022-11-29 21:20:37 +00:00
Gordon Bergling
156ce1e51c net8021: Fix a typo in a kernel error message
- s/missmatch/mismatch/

MFC after:	1 week
2022-10-25 04:31:51 +02:00
Bjoern A. Zeeb
f82316f678 net80211: move IEEE80211_F_WME check to vap for consistency
The IEEE80211_F_WME checks done on the ic were changed to be per-vap
back in the time when multi-bss was introduced or earlier in 2008.
This one was left out but given it is a (re-)accos-req case I see
no reason not to use the vap value here for consistency too.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D36733
2022-09-29 12:54:23 +00:00
Alexander V. Chernikov
91ebcbe02a if_clone: migrate some consumers to the new KPI.
Convert most of the cloner customers who require custom params
 to the new if_clone KPI.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D36636
MFC after:	2 weeks
2022-09-22 12:30:09 +00:00
Bjoern A. Zeeb
800aa9cd3d LinuxKPI: 80211 (+net80211): update and cleanup headers
Fix types for various struct fields (initially added as int).

Move structs and inline functions logically together, e.g., for wowlan.
Add more skeleton functions and #defines needed for iwlwifi d3.c
in the future.

Add struct ieee80211_vht_cap (without "_ie") to net80211 and remove
duplicate definitions in LinuxKPI headers now using net80211 structs.
For now leave ieee80211_ie_vhtcap in net80211.  I am not sure yet if we
actually need it as such.  That'll be cleaned up with more VHT updates
in net80211 in the future.

No functional changes in currently compiled code intended.

Try to implement ieee80211_action_contains_tpc() as I ran into it with
an older iwlwifi chipset.  This depends on c994352a88.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2022-09-09 18:40:23 +00:00
Bjoern A. Zeeb
c994352a88 net80211: update (parts of) Action field categories
Update to the full list of action field category values based on
802.11-2020 with 11ax extensions and remove one value Reserved nowadays.
While here annotate them with descriptions.

Also add Spectrum Management and Radio Measurement action field values
needed in LinuxKPI.

No functional changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-09-07 23:28:13 +00:00
Gordon Bergling
d78a907665 net80211(4): Correct a grammar mistake in a source code comment
- s/the/be the/
- s/Mhz/MHz/
- s/it'll/it will/

Reported by:	bz, danfe
MFC after:	3 days
2022-09-07 13:13:54 +02:00
Gordon Bergling
8f538e2766 net80211(4): Remove a double word in a source code comment
- s/the the/the/

MFC after:	3 days
2022-09-04 13:53:17 +02:00
Bjoern A. Zeeb
fb47649ebc net80211: update (parts of) frame types and subtypes and annotate
Update to the full list of frame type and subtype values based on
802.11-2020 with 11ax and 11ay extensions. This includes the 4th type
"Extension" (IEEE80211_FC0_TYPE_EXT).
While here annotate them with descriptions which should help matching
names (as at times things get confusing with LinuxKPI).
Also remove some 802.11-1997 values Reserved nowadays.

No functional changes.

Sponsored by:	The FreeBSD Foundation
MFC after:	5 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D36410
2022-09-03 21:18:40 +00:00
Bjoern A. Zeeb
c9b7e9df18 net80211 / drivers: rename to IEEE80211_FC0_SUBTYPE_QOS_DATA
Going through the Frame (Sub)types the "QOS Data" being called "QOS"
scheme leads to a naming conflict for QOS_CFPOLL and QOS_CFACKPOLL
(if added).   Rename QOS* to QOS_DATA* to avoid the conflict and
to also better match the standards name.

No functional changes intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	5 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D36409
2022-09-03 21:04:13 +00:00
Bjoern A. Zeeb
8def06d5af net80211: simplify an #ifdef INET/INET6 block
I got lost in the #ifdef #endif here so I changed the code to a
switch block with two non-overlapping #ifdef parts and a default
which makes it a lot easier to read.

No functional changes.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	(zlei.huang gmail.com)
MFC after:	5 days
Differential Revision: https://reviews.freebsd.org/D36411
2022-09-03 20:59:30 +00:00
Gleb Smirnoff
c414347bc5 mbufs: isolate max_linkhdr and max_protohdr handling in the mbuf code
o Statically initialize max_linkhdr to default value without relying
  on domain(9) code doing that.
o Statically initialize max_protohdr to a sane value, without relying
  on TCP being always compiled in.
o Retire max_datalen. Set, but not used.
o Don't make the domain(9) system responsible in validating these
  values and updating max_hdr.  Instead provide KPI max_linkhdr_grow()
  and max_protohdr_grow().
o Call max_linkhdr_grow() from IEEE802.11 and max_protohdr_grow() from
  TCP.  Those are the only protocols today that may want to grow.

Reviewed by:		tuexen
Differential revision:	https://reviews.freebsd.org/D36376
2022-08-29 19:14:25 -07:00
Bjoern A. Zeeb
8d37116489 net80211: LinuxKPI 802.11: harmonize IEEE80211_VHT_MCS_*
Rather than defining the same values in two places and having to do
conflict resulution on the name in LKPI, change the defines to an
enum in net80211.  In addition to de-duplication this also gives us
value checks in certain cases.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D36250
2022-08-18 20:34:30 +00:00
Bjoern A. Zeeb
bd29f81763 net80211: consistently use the IEEE80211_M_ memory related options
Replace a malloc() by IEEE80211_MALLOC().
For malloc flags even in the local ieee80211_freebsd.c there was a mix
of both versions M_ and IEEE80211_M_.
Consistently use the IEEE80211_M_ malloc options everywhere.
If the field is changed for malloc, it'll also be changed for the
other accessor functions taking a "how" field to avoid any confusion.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D36249
2022-08-18 20:32:24 +00:00
Bjoern A. Zeeb
9d2ba51806 net80211: ieee80211_ies_expand() add extra length check
Make sure the given IE length fits into the total length left when
parsing through the information elements.  In theory I would say
discard everything if there is an error but that proves hard with
the current code.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D36245
2022-08-18 20:29:25 +00:00
Adrian Chadd
2889cbe29e net80211: add an IEEE80211_IS_PROTECTED() macro
Summary: This returns whether the given 802.11 frame has the protected bit set.

Test Plan:
* tested in AP/STA mode
* STA mode - local athp/ath10k driver
* AP mode - in tree ath driver

Subscribers: imp, melifaro, glebius
Reviewed by: bz
Approved by: bz

Differential Revision: https://reviews.freebsd.org/D36183
2022-08-14 09:48:06 -07:00
Gordon Bergling
044169efe0 net80211(4): Fix a typo in a source code comment
- s/paramaters/parameters/

MFC after:	3 days
2022-08-07 16:01:13 +02:00
Cy Schubert
4f158a444e net80211: Remove tautological state display
When printing the current state name and the old state numeric value,
both are always the same. Remove the redundant ostate. It is always
the same as iv_state.

Reviewed by:		bz
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D35849
2022-08-05 18:53:38 -07:00
Bjoern A. Zeeb
195733401f net80211: change order in ieee80211_vhtchanflags()
While 80P80 is less likely to be used, VHT160 (a single contiguous
width) is harder to acquire but also preferable so return that first.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:    adrian
Differential Revision: https://reviews.freebsd.org/D35977
2022-07-29 15:10:52 +00:00
Bjoern A. Zeeb
dc32c71339 net80211: VHT correct check/option in ieee80211_vht_adjust_channel()
In ieee80211_vht_adjust_channel() we have to check for all possible
IEEE80211_FVHT_VHT* options using the mask rather than just checking
for IEEE80211_FVHT_VHT;  ieee80211_vhtchanflags() (contrary to its
HT counterpart) only returns the "highest" flag nor or-ing them together
with the base flag.  For the moment this seems to make sense as with
more width options we'd add a pyramid.

Later on, in the same function when we get VHT160 actually go and look
for VHT160 and not VHT80.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D35977
2022-07-29 15:10:45 +00:00
Bjoern A. Zeeb
656d0e8fa9 net80211: add VHT5G and VHT2G checks/return to media_status
Add the fields for VHT (2Ghz and 5Ghz) to report back by media_status
so we actually have a chance to get the right information.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D35977
2022-07-29 15:10:38 +00:00
Bjoern A. Zeeb
5c9f992919 net80211: improve DDB output.
Start adding more fields to DDB output related to VHT (11ac) and
mark COM, VAP, and STA more explicitly to make show all vaps /..
more readable.

Sponsored by:	The FreeBSD Foundaton
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D35977
2022-07-29 15:10:31 +00:00
Bjoern A. Zeeb
463d6125e7 net80211: correct IEEE80211_FEXT_BITS
Correct IEEE80211_FEXT_BITS adding the missed one and move the later
one further.  This will actually make VHT to show.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D35977
2022-07-29 15:10:24 +00:00
Bjoern A. Zeeb
a78be09e4d net80211: add more 802.11ac Element IDs
Add more Element IDs for VHT (11ac) to complete the current list
and we can use them if/as needed.

Sposnored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D35977
2022-07-29 15:10:15 +00:00
Bjoern A. Zeeb
c7a8db6a85 net80211: radiotap: add one more define for HE
Add one more define for HE radiotap used by a driver.

MFC after:	1 week
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D35977
2022-07-29 15:09:55 +00:00
Dimitry Andric
9319211f96 Fix unused variable warning in ieee80211_proto.c
With clang 15, the following -Werror warning is produced:

    sys/net80211/ieee80211_proto.c:1070:34: error: variable 'num_mixed' set but not used [-Werror,-Wunused-but-set-variable]
            int num_vaps = 0, num_pure = 0, num_mixed = 0;
                                            ^

The 'num_mixed' variable was in ieee80211_proto.c when the function
vap_update_ht_protmode() was added, but it was never used for anything,
so remove it.

MFC after:	3 days
2022-07-26 21:25:09 +02:00
Bjoern A. Zeeb
4c3684ef5c net80211 / LinuxKPI: 802.11: add Control Trigger Subframe information
Add definitions related to 802.11ax Control Trigger frame format
needed for rtw89.

MFC after:	3 days
2022-06-17 22:55:13 +00:00
Bjoern A. Zeeb
892b1874ac net80211: remove (optional) RSN from preobereq
802.11i-2004 did not specify that RSN can be added to the probereq,
only to the proberesp (and others) yet it was added in what seems was
b032f27c36 (multi-BSS support).
802.11-2020 does not list the IE either for probereq so remove it.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Okayed by:	adrian
Differential Revision: https://reviews.freebsd.org/D34893
2022-05-17 22:33:10 +00:00
Bjoern A. Zeeb
464907ce1c net80211: simplify code after STA/AP VAPs traffic hang fix
Combine the comment and double-unsetting of OACTIVE into a single case
after e8de31cace.
This saves the question of why we do it twice--once right before and
one more time right after the state change check.
Also move the XXX comment about kicking the queue up to where it seems
better suited now.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D35135
2022-05-06 09:34:16 +00:00
Adrian Chadd
e8de31cace net80211: Fix traffic hang on STA/AP VAPs on a multi-VAP interface
This took an embarrasingly long time to find.

The state changes for a radio with a STA /and/ AP VAP gets a bit messy.
The AP maps are marked as waiting, waiting for the STA AP to find a
channel to use before the AP VAPs become active.

However, the code path that clears the OACTIVE flag on a VAP only runs
during a successful run of ieee80211_newstate_cb().

So here is how it goes:

* the STA VAP goes down and needs to scan;
* the AP vap goes RUN->INIT; but it doesn't YET call ieee80211_newstate_cb();
* meanwhile - a send on the AP VAP causes the VAP to set the OACTIVE flag here;
* then the STA VAP finishes scan and goes to RUN;
* which will call wakeupwaiting() as part of the STA VAP transition to RUN;
* .. then the AP VAP goes INIT->RUN directly via a call to hostap_newstate
  in wakeupwaiting rather than it being through the deferred path;
* /then/ the ieee80211_newstate_cb() is called, but it sees the state go
  RUN->RUN;
* .. which results in the OACTIVE flag never being cleared.

This clears the OACTIVE flag when a VAP transitions RUN->RUN; the
driver layer or net80211 layer can set it if required in a subsequent
transmit.

Differential Revision: https://reviews.freebsd.org/D34920

Reviewed by: bz
2022-04-21 22:49:01 -07:00
Gordon Bergling
fb5a502692 net80211(4): Fix a typo in a source code comment
- s/is is/is/

MFC after:	3 days
2022-04-09 09:13:53 +02:00