summaryrefslogtreecommitdiff
path: root/sys/net80211/ieee80211_input.c
AgeCommit message (Collapse)Author
2024-05-23increment CCMP decryption error counter if hw decrypt fails to get PNStefan Sperling
This case will only occur if the IV has been stripped by hardware and the driver has not cleared the protected bit in the frame header as it should. Incrementing this counter will make the problem more obvious when looking at netstat -W output. No functional change for people who do not work on wifi drivers.
2024-05-13remove prototypes with no matching functionJonathan Gray
ok mpi@
2024-04-13correct indentationJonathan Gray
no functional change, found by smatch warnings ok miod@ bluhm@
2024-03-15Ignore ADDBA requests if we are not ready to receive data frames.Stefan Sperling
This prevents potential firmware errors in Intel wifi drivers when APs send an ADDBA request before the driver's state machine has settled into RUN state. The driver's addba task would race the driver's newstate task, and the hardware would see an incorrect sequence of commands. Ignoring an early ADDBA request is harmless. The AP will retry later. Reported by zxystd from the OpenIntelWireless project, thanks! ok phessler@
2023-01-09restore NetBSD RCS IDDaniel Dickman
Looks like this was removed in rev 1.85 without comment (which may have been unintentional). ok stsp@
2023-01-07Make net80211 drop beacons received on secondary HT/VHT channels.Stefan Sperling
Prevents iwm firmware panics and makes association work with 11ac APs which transmit beacons on channels other than their primary channel. We would use the wrong channel in such cases, and iwm would request a bogus channel configuration, which made the firmware unhappy. Tested by myself on iwm 8265 and florian on iwm 9260. This issue did likely affect iwx devices, too. ok mpi@
2022-12-27Fix array bounds mismatch with clang 15Patrick Wildt
New warning -Warray-parameter is a bit overzealous. ok millert@ tb@
2022-03-20Introduce an alternative mechanism for wifi drivers to communicateStefan Sperling
the channel on which a frame was received. ieee80211_inputm() was expecting that ic->ic_bss->ni_chan would correspond to the channel which is currently being scanned. This dates back to older devices which are manually tuned to the next channel by the driver during SCAN->SCAN state transitions. However, this approach is very awkward for drivers which scan across a whole range of channels in firmware. Such drivers had an ugly workaround in place which tweaked ni_chan for each received frame. Introduce a channel number field in the Rx info struct which drivers can use to indicate the channel on which a frame was received. If this field is set, net80211 will use it instead of using the current channel of ic_bss. Use this new mechanism in all affected drivers. Tested by jmc@, sthen@, and myself on iwm(4) and iwx(4). Changes to iwn(4) and bwfm(4) are the same mechanical changes to get rid of the ni_chan tweak, and are therefore expected to work. ok sthen@ dlg@
2022-03-20Make background scans pick up APs on 2GHz channels while in 11ac mode.Stefan Sperling
found by landry@
2022-03-14Add initial 802.11ac (VHT) support to net80211.Stefan Sperling
Add VHT capability and operation IE definitions to ieee80211.h. Introduce channel flags to identify 80MHz and 160MHz capable channels. Parse VHT IEs in beacons, announce the driver's VHT capabilities in probe requests and assoc requests, and hop into 11ac mode after association to the AP if possible. Enable VHT by default if the driver announces support for it. ok claudio@
2022-01-28When it's the possessive of 'it', it's spelled "its", without thePhilip Guenther
apostrophe.
2022-01-21Fix and re-enable active scans on iwm(4) and iwx(4).Stefan Sperling
Ensure that we supply the access point's DTIM period to firmware after an active scan, as soon as the next beacon arrives. This prevents the problems which prompted us to keep active scans disabled in our drivers. Problem debugged and patch by zxystd from the OpenIntelWireless project. I made some tweaks regarding TIM parsing, which were reviewed by zxystd. Johannes Berg from Intel has confirmed to me via IRC that firmware will misbehave if running with a zero DTIM period. Tested: 8265: jca, stsp 9260: kettenis (possible fallout observed here; will keep an eye on it) 9650: stsp ax200: zxystd, kevlo, stsp ax201: stsp ok kevlo@ kettenis@
2022-01-12Remove ieee80211_find_node_for_beacon().Stefan Sperling
The original purpose of ieee80211_find_node_for_beacon() was to avoid storing duplicate nodes with the same source MAC address in a hash table. Later on, our node table data structure was changed from a hash table to an RB tree. The RB tree can only store a single node per MAC address. However, find_node_for_beacon() was kept regardless, now documented to serve a different purpose. Its new purpose is to tell apart different nodes which happen to use the same MAC address and hence cannot both be stored in the RB tree. The idea is to filter such duplicate nodes out during a scan. But colliding nodes are told apart by RSSI and channel, and either may change over time. So this does not really prevent duplicate MAC addresses from causing issues. The code which decides which node is "better" can erroneously match an AP against itself, in case the AP uses a hidden SSID. This caused workarounds for hidden SSID to pile up over time. Just a bit further down, the code looks up the same node again and performs all of the intended node state updates. Simply skipping the ieee80211_find_node_for_beacon() check makes such state updates work. ok tobhe@
2022-01-05rename ETHERTYPE_PAE to ETHERTYPE_EAPOL.David Gwynne
everyone else seems to use ETHERTYPE_EAPOL, and as a bonus it also appears to be more correct. ok deraadt@ stsp@
2021-12-03Ignore ADDBA requests from our AP while we are roaming away from it.Stefan Sperling
Noticed while testing iwm/iwx roaming patches, where my AP would request a new Rx BA session when we had already decided to roam away. There is no need to set up a new Rx BA session with our old AP which we would have to immediately tear down again anyway.
2021-10-11Monitor 20/40 MHz channel width changes in beacons sent by our access pointStefan Sperling
and notify drivers when the channel width has changed.
2021-09-03Reset a net80211 node's QoS Tx sequence counter to the start of theStefan Sperling
block ack window when a new Tx block ack agreement is established. In the future this change will allow the iwx(4) driver to initialize this sequence number such that it corresponds to what the firmware expects. Note that ba->ba_winstart is set to ni->ni_qos_txseqs[tid] when a new Tx agg agreement is initiated in ieee80211_node_addba_request(). Unless the driver resets ba->ba_winstart before ieee80211_addba_resp_accept() runs, which is what iwx(4) will do, the assignment added with this patch is a no-op.
2021-05-18Drop fragmented 802.11 frames.Stefan Sperling
Fragmented frames were never of any practical use to us anyway, given that our net80211 stack does not (yet?) re-assemble them. Counter-measure against attacks where an arbitrary packet is injected in a fragment with attacker-controlled content (via an AP which supports fragments). See https://papers.mathyvanhoef.com/usenix2021.pdf Section 6.8 "Treating fragments as full frames" ok mpi@
2021-05-17put unused 802.11 fragmentation support code under #ifdef notyetStefan Sperling
2021-05-17Prevent frame injection via forged 802.11n A-MSDUs.Stefan Sperling
This mitigates an attack where a single 802.11 frame is interpreted as an A-MSDU because of a forged AMSDU-present bit in the 802.11 QoS frame header. See https://papers.mathyvanhoef.com/usenix2021.pdf section 3.2. MAC address validation is added as an additional measure to prevent hostap clients from sending A-MSDU subframes with a spoofed source address. An earlier version of this patch was reviewed by Mathy Vanhoef, who spotted a bug in my original attempt at preventing spoofed addresses. ok mpi@
2021-04-29Make iwn, iwm, and iwx keep track of beacon parameters at run-time.Stefan Sperling
- HT protection settings (this was already implemented) - ERP (11g) protection setting - short slottime setting - short preamble setting - EDCA (QoS) parameters All of these parameters are communicated in beacons and hardware is now kept up-to-date with them. Prompted by a problem report from Christian Ehrhardt regarding ERP. Tested: iwn 6205: stsp, Josh Grosse iwm 7265: trondd iwm 8265: stsp, Matthias Schmidt iwm 9260: phessler iwx ax200: stsp, jmc, gnezdo
2021-04-25Implement support for Rx aggregation offload in iwm(9) and iwx(4), andStefan Sperling
re-enable de-aggregation of A-MSDUs in net80211 for all drivers capable of 11n mode. This can provide improved Rx performance if the access point supports transmission of A-MSDUs nested in A-MDPUs. iwm(9) 9k and iwx(4) devices de-aggregate A-MSDUs in hardware. Neither our drivers nor the net80211 stack were prepared to handle this. Add two Rx-info flags which drivers can use to avoid having subframes which arrived in the same A-MSDU rejected as duplicates in the net80211 input layer: IEEE80211_RXI_HWDEC_SAME_PN allows the same CCMP packet number for a series of subsequent frames. IEEE80211_RXI_SAME_SEQ allows the same 802.11 frame header sequence number for a series of subsequent of frames. Handle A-MPDU reordering on iwm 9k and iwx devices, based on code from iwlwifi. Rx block ack window information is provided by firmware. So far this info was ignored by drivers and reordering of A-MPDU subframes happened twice: Once in firmware, and again in net80211. Tested: iwm 7260: bcallah, dv iwm 7265: mpi, trondd, Matthias Schmidt iwm 8260: bket, Marcus MERIGHI iwm 8265: stsp, tracey, Uwe Werler iwm 9260: phessler, matthieu iwm 9560: stsp, Uwe Werler iwx ax200: jmc, stsp iwx ax201: stsp
2021-03-26Fix wrong sequence number wrap in ieee80211_recv_auth().Stefan Sperling
IEEE 802.11 sequence numbers wrap around at 0xfff, not 0xffff. ok phessler@ kevlo@
2021-03-23Fix a corner case bug in Rx block ack window gap-wait timeout handling.Stefan Sperling
If ieee80211_input_ba_flush() was called when there was nothing to flush, the (already pending) gap wait timeout was re-armed. This is only correct if we flush at least one packet. Otherwise packets that arrive at a constant rate of about 4-5 packets per second would extend the gap-wait timeout until the block ack window fills up. In extreme cases this can result in packets being queued for almost 20s. Fix this by returning immediately from ieee80211_input_ba_flush() if the first packet in the reordering buffer is missing. This prevents the timeout from being re-armed. Patch by Christian Ehrhardt. Tested by me on iwm(4) 7265.
2021-03-23When moving the Rx block ack window forward do not implicitly rely onStefan Sperling
ieee80211_input_ba_flush() for updating ba->ba_winend. Required for an upcoming ieee80211_input_ba_flush() fix. Patch by Christian Ehrhardt who found one instance of this problem in ieee80211_input_ba_seq(). I spotted another in ieee80211_ba_move_window().
2021-03-10spellingJonathan Gray
ok gnezdo@ semarie@ mpi@
2020-12-10Fix double-free on error in ieee80211_amsdu_decap().Stefan Sperling
Bug was introduced by my previous commit to this file. ok tobhe@
2020-12-09Ignore trailing data in A-MSDU frame buffers if it is smaller than theStefan Sperling
Ethernet header size. Avoids spurious "input packet decapsulations failed" errors in 'netstat -W' with A-MSDU enabled (currently disabled in-tree). Problem observed and fix verified on iwm(4) 8260 by me and 7260 by tobhe. ok phessler@ tobhe@
2020-12-09Disable A-MSDU support again.Stefan Sperling
iwm(4) 9k and iwx(4) need more work before AMSDU can be enabled. These devices decapsulate A-MSDU in hardware and required changes to make this work with our drivers and stack seem to be non-trivial. Problems reported by phessler@ ok phessler@
2020-12-09Flush reorder buffer after gap timeout, otherwise the frames remaintobhe
in the buffer until the next frame is received. Found by and fix from Christian Ehrhardt ok stsp@
2020-12-08Enable 802.11 A-MSDU support again. It was disabled some time ago butStefan Sperling
the underlying problems have since been fixed. Using A-MSDUs results in improved download speeds with APs that support them. tested by robert@
2020-12-08Fix gapwait accounting. Count all the packets in the reordertobhe
buffer. Restart the gap timeout if the buffer is not empty after we flush out some of the packets. Found by and fix from Christian Ehrhardt ok stsp@ phessler@
2020-12-08Use BA agreement immediately after it is requested by the AP.tobhe
Some APs continue to send QOS packet for the same tid (with normal ack policy). Make those packets go through BA reordering to advance the sequence number counter in the BA agreement and prevent performance loss due to a gap wait later on. Found by and fix from Christian Erhardt ok stsp@ phessler@
2020-08-28Add missing #if's to fix build without bpf(4).mvs
ok deraadt@
2020-07-21Improve processing of lost frames during 802.11 Rx aggregation.Stefan Sperling
Make ieee80211_input_ba() skip one missing frame at the head of the Rx block ack (BA) window once the rest of the window has filled up with pending frames. This avoids having to wait for the BA window gap timeout handler to run in order to make progress in such situations. Simplify the BA gap timeout handler by deferring the actual flushing of the BA window buffer to the regular input path. The timeout handler now simply advances the BA window across any missing frames at the head of the window, and if_input() is no longer called from the context of this timeout handler. The window will be flushed once another frame arrives. Packet loss under streamy traffic conditions and during Rx bursts is reduced. Much less stuttering, more stable tcpbench, and easier flight in Minecraft. tested by phessler@, Martin Vahlensieck, jmc@, Uwe Werler, and myself
2020-07-20The IEEE80211_F_HIDENWID flag is now part of ic_userflags, not ic_flags.Stefan Sperling
Fix code which was still looking for this flag at the old location. The 'hidenwid' feature was slightly broken as a result: The SSID was leaked in probe responses to wildcard probe requests. There are other trivial ways of snooping a "hidden" SSID however so this is not a big deal. Problem reported by Mogens Jensen.
2020-06-01Revert "Ignore new Rxblock ack agreements until the WPA handshake is done."Stefan Sperling
There are access points out there which insist on establishing a block ack agreement with the client before the WPA handshake can complete. This is sad, but we cannot operate against such APs if we require the handshake to complete first. This reverts CVS commit 4wXCjWU3qNtIX7gW. Problem reported and fix tested by Brandon Sahlin on bugs@
2020-05-26Let unencrypted 802.11 frames pass during hardware decryption post-processing.Stefan Sperling
Some drivers, such as ral(4), cannot provide the IV required for a replay check because hardware strips the IV before passing the frame to the driver. Which means frames with the RXI_HWDEC flag but without the 'protected' bit set in the frame header must be passed without any further verification and without updating the last-seen packet number. All we can do is hope that these devices perform replay checking correctly. Fixes a regression where some ral(4) devices would fail to receive packets on encrypted networks. Reported and fix confirmed by Hendrik Meyburgh. ok mpi@
2020-05-15Fix CCMP replay check with 11n Rx aggregation and CCMP hardware offloading.Stefan Sperling
So far, drivers using hardware CCMP decryption were expected to keep the most recently seen CCMP packet number (PN) up-to-date, and to discard frames with lower PNs as replays. A-MPDU subframes may legitimately arrive out of order, and the drivers skipped CCMP replay checking for such frames. Re-ordering happens in ieee80211_inputm(), after the driver is done with a frame. Drivers cannot tell replayed frames apart from legitimate out-of-order retransmissions. To fix this, update the PN value in ieee80211_inputm() after subframes have been reordered into their proper sequence. Drivers still perform replay checks but they no longer have to worry about updating the last seen PN value. The 802.11 spec confirms that replay checking is supposed to happen after A-MPDU re-ordering. Tested by jmc@, benno@, solene@, and myself with the following drivers: athn(4), iwn(4), iwm(4), wpi(4), urtwn(4) ok solene@
2020-03-11Make sure hdrlen is initialized.tobhe
ok stsp@
2019-12-20Ignore new Rx block ack agreements until the WPA handshake is done.Stefan Sperling
Some peers will eagerly try to negotiate block ack (asking us to reserve buffer space) before they are done authenticating themselves. No thanks. Just let them try again later. ok mpi@
2019-12-20Have net80211 actually update the Rx block ack sequence number window,Stefan Sperling
as well as pulling frames off the Rx block ack reordering queue, when an incoming frame above the current seqnum window forces us to slide the window forward, potentially losing frames within the old window. Leaving the seqnum window out of sync with the queue would cause needlessly long stalls in traffic until the window moved again for some other reason. Problem observed on lossy wifi whenever netstat -W indicated an increasing "input block ack window slides" counter. With this fix, stalled frames can be observed only for a relatively short amount of time whenever one or more frames in the current window are lost. ok mpi@
2019-10-11Probe responses are generally only seen after probe requests,Patrick Wildt
which we only send if an SSID is already configured. Thus a scan only creates beacons. Especially on bwfm(4) only beacons frames are faked, there are no probe responses. When a node first is created, ni_rssi is 0, which is always smaller than rxi_rssi, and it wil never be set for nodes on 5 GHz. Thus we should always set ni_rssi if it is 0. Tested by jan@ tobhe@ ok stsp@ deraadt@
2019-10-06Fix net80211's accounting of discarded input control frames.Stefan Sperling
PS-poll and BA-req frames are in fact being processed. Do not count such frames as discarded control frames. OK phessler kn mpi
2019-09-25Update acces point channel in node list when receiving packets from sametobhe
AP on a new channel. Not doing so leads to a disconnect because AP messages on the new channel are ignored.
2019-09-12Make wireless drivers call if_input() only once per interrupt.Stefan Sperling
This reduces drops caused by the ifq pressure drop mechanism and hence increases throughput. Such drops are visible with e.g. 'netstat -dnI iwm0'. Not all affected drivers have been tested yet but these changes are largely mechanical and should be safe. As usual, please report any regressions. With help from dlg@ and mpi@ Problem found by robert@ Tested by robert, jmc, Tracey Emer, Matthias Schmidt, florian, Björn Ketelaars ok mpi@
2019-08-29Always parse RSN/WPA IEs if the driver announces support for RSN.Stefan Sperling
Prevents WPA APs from appearing as non-WPA APs to the AP selection logic. The decision whether or not to parse the IE was made as a side-effect of a check for the highest mutually supported version of WPA. We can safely assume that all our drivers support WPA versions <= 2 and parse the IE regardless of whether WPA is currently active or not. ok mpi@
2019-07-29Add support for 802.11n Tx aggregation to net80211 and the iwn(4) driver.Stefan Sperling
In particular, add Tx block ack session management to net80211, with enough funcionality to support Tx aggregation on devices which perform A-MPDU subframe scheduling in firmware. Make use of the iwn(4) firmware Tx scheduler to build A-MPDUs. net80211's QoS support code is now enabled and used by Tx aggregation. A-MSDU frames inside A-MPDUs have been tested and work in principle. For now, this feature is disabled because unfair TCP connection sharing was observed during testing, where bursts of TCP Ack frames for a single tcpbench(1) connection arriving in A-MSDUs made other TCP connections stall. Switch off support for A-MSDUs inside A-MPDUs on the Rx side as well. Tested on iwn chipsets 1000, 4965, 5100, 5300, 2200, 6200, 6205, 6300 (committed version of tested diff has all debug printfs removed) tests/ok benno kmos mlarkin kevlo
2019-05-12Fix 'ifconfig nwflags; These flags ended up overlapping with other flagsStefan Sperling
in ieee80211com's ic_flags because we haven't been paying attention to them (they're not in the same place in the code and hence easy to miss). Move them to a dedicated variable to avoid this problem in the future. Add a new 'stayauth' nwflag which can be set to let net80211 ignore deauth frames. This can be useful when deauth frames are being persistently spoofed by an attacker. Idea from beck@ ok beck@ phessler@
2019-03-29Use stricter validation checks for A-MPDUs in the net80211 input path.Stefan Sperling
Don't accept A-MPDUs if not in RUN state, and don't accept them from unassociated clients in hostap mode. ok jmatthew@ kevlo@