History log of /freebsd-current/sys/net80211/ieee80211_hwmp.c
Revision Date Author Comments
# c1ada397 22-Jan-2024 Gordon Bergling <gbe@FreeBSD.org>

net80211: Fix a typo in a source code comment

- s/recevied/received/

MFC after: 3 days


# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

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


# 95d14659 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

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


# bd29f817 17-Aug-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

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


# a9beea05 03-Dec-2021 Gordon Bergling <gbe@FreeBSD.org>

net80211(4): Fix a typo in a sysctl description

- s/travelse/traversal/

MFC after: 3 days


# 2ec4c3c7 25-Sep-2021 Gordon Bergling <gbe@FreeBSD.org>

net80211(4): Fix a few common typos in source code comments

- s/annoucement/announcement/
- s/setings/settings/

MFC after: 1 week


# 9feff969 08-Aug-2021 Ed Maste <emaste@FreeBSD.org>

Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights

These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).

Sponsored by: The FreeBSD Foundation


# d197bf2b 13-Mar-2021 Gordon Bergling <gbe@FreeBSD.org>

net80211: Fix a typo in a comment

- destionation -> destination
- while here, fix some whitespace issues

MFC after: 1 week


# 662c1305 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

net: clean up empty lines in .c and .h files


# 08f5e6bb 21-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (7 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all low hanging fruits as MPSAFE.

Reviewed by: markj
Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23626


# fb3bc596 24-May-2019 John Baldwin <jhb@FreeBSD.org>

Restructure mbuf send tags to provide stronger guarantees.

- Perform ifp mismatch checks (to determine if a send tag is allocated
for a different ifp than the one the packet is being output on), in
ip_output() and ip6_output(). This avoids sending packets with send
tags to ifnet drivers that don't support send tags.

Since we are now checking for ifp mismatches before invoking
if_output, we can now try to allocate a new tag before invoking
if_output sending the original packet on the new tag if allocation
succeeds.

To avoid code duplication for the fragment and unfragmented cases,
add ip_output_send() and ip6_output_send() as wrappers around
if_output and nd6_output_ifp, respectively. All of the logic for
setting send tags and dealing with send tag-related errors is done
in these wrapper functions.

For pseudo interfaces that wrap other network interfaces (vlan and
lagg), wrapper send tags are now allocated so that ip*_output see
the wrapper ifp as the ifp in the send tag. The if_transmit
routines rewrite the send tags after performing an ifp mismatch
check. If an ifp mismatch is detected, the transmit routines fail
with EAGAIN.

- To provide clearer life cycle management of send tags, especially
in the presence of vlan and lagg wrapper tags, add a reference count
to send tags managed via m_snd_tag_ref() and m_snd_tag_rele().
Provide a helper function (m_snd_tag_init()) for use by drivers
supporting send tags. m_snd_tag_init() takes care of the if_ref
on the ifp meaning that code alloating send tags via if_snd_tag_alloc
no longer has to manage that manually. Similarly, m_snd_tag_rele
drops the refcount on the ifp after invoking if_snd_tag_free when
the last reference to a send tag is dropped.

This also closes use after free races if there are pending packets in
driver tx rings after the socket is closed (e.g. from tcpdrop).

In order for m_free to work reliably, add a new CSUM_SND_TAG flag in
csum_flags to indicate 'snd_tag' is set (rather than 'rcvif').
Drivers now also check this flag instead of checking snd_tag against
NULL. This avoids false positive matches when a forwarded packet
has a non-NULL rcvif that was treated as a send tag.

- cxgbe was relying on snd_tag_free being called when the inp was
detached so that it could kick the firmware to flush any pending
work on the flow. This is because the driver doesn't require ACK
messages from the firmware for every request, but instead does a
kind of manual interrupt coalescing by only setting a flag to
request a completion on a subset of requests. If all of the
in-flight requests don't have the flag when the tag is detached from
the inp, the flow might never return the credits. The current
snd_tag_free command issues a flush command to force the credits to
return. However, the credit return is what also frees the mbufs,
and since those mbufs now hold references on the tag, this meant
that snd_tag_free would never be called.

To fix, explicitly drop the mbuf's reference on the snd tag when the
mbuf is queued in the firmware work queue. This means that once the
inp's reference on the tag goes away and all in-flight mbufs have
been queued to the firmware, tag's refcount will drop to zero and
snd_tag_free will kick in and send the flush request. Note that we
need to avoid doing this in the middle of ethofld_tx(), so the
driver grabs a temporary reference on the tag around that loop to
defer the free to the end of the function in case it sends the last
mbuf to the queue after the inp has dropped its reference on the
tag.

- mlx5 preallocates send tags and was using the ifp pointer even when
the send tag wasn't in use. Explicitly use the ifp from other data
structures instead.

- Sprinkle some assertions in various places to assert that received
packets don't have a send tag, and that other places that overwrite
rcvif (e.g. 802.11 transmit) don't clobber a send tag pointer.

Reviewed by: gallatin, hselasky, rgrimes, ae
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20117


# ab9ed8a1 10-Aug-2018 Devin Teske <dteske@FreeBSD.org>

Fix misspellings of transmitter/transmitted

Reviewed by: emaste, bcr
Sponsored by: Smule, Inc.
Differential Revision: https://reviews.freebsd.org/D16025


# fe267a55 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 6dbbec93 19-May-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: fix more compiler warnings.

ieee80211.c:
add_chanlist(): 'error' variable will be uninitialized if
no channels were passed; return '0' instead.
ieee80211_action.c:
ieee80211_send_action_register(): drop 'break' after 'return'.
ieee80211_crypto_none.c:
none_encap(): 'keyid' is not used in non-debug builds; hide it
behind IEEE80211_DEBUG ifdef.
ieee80211_freebsd.c:
Staticize global 'ieee80211_debug' variable (used only in this
file).
ieee80211_hostap.c:
Fix a comment (associatio -> association).
ieee80211_ht.c:
ieee80211_setup_htrates(): initialize 'maxunequalmcs' to 0 to mute
compiler warning.
ieee80211_hwmp.c:
hwmp_recv_preq(): copy 'prep' between conditional blocks to fix
-Wshadow warning.
ieee80211_mesh.c:
mesh_newstate(): remove duplicate 'ni' definition.
mesh_recv_group_data(): fix -Wempty-body warning in non-debug
builds.
ieee80211_phy.c:
ieee80211_compute_duration(): remove 'break' after panic() call.
ieee80211_scan_sta.c:
Hide some TDMA-specific macros under IEEE80211_SUPPORT_TDMA ifdef
adhoc_pick_bss(): remove 'ic' pointer redefinition.
ieee80211_sta.c:
sta_beacon_miss(): remove 'ic' pointer redefinition.
ieee80211_superg.c:
superg_ioctl_set80211(): drop unreachable return.

Tested with clang 3.8.0, gcc 4.6.4 and gcc 5.3.0.


# 601a2543 12-May-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: drop some unused variables / local macros

Most of them left after some commits (r178354, r191544, r287197 etc.);
some were never used.

Found by: Clang Static Analyzer


# 31021a2b 20-Apr-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: replace internal LE_READ_*/LE_WRITE_* macro with system
le*dec / le*enc functions.

Replace net80211 specific macros with system-wide bytestream
encoding/decoding functions:
- LE_READ_2 -> le16dec
- LE_READ_4 -> le32dec
- LE_WRITE_2 -> le16enc
- LE_WRITE_4 -> le32enc

+ drop ieee80211_input.h include, where it was included for these
operations only.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D6030


# 0d667017 22-Mar-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] add missing static declarations.

Submitted by: Sascha Wildner <saw@online.de>
Obtained from: dragonflybsd (https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/822aeeabc8c4c074deea46383f36e6d1cdcd19f5)


# 6fe391f4 27-May-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Move counter.h include into ieee80211_freebsd.h. Should fix build.

Submitted by: Zilvinas Valinskas <zilvinas.valinskas gmail.com>


# 81c04d11 25-May-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Add two counters to ieee80211com, that will be used to count transmission
or receive errors that can't be associated with any vap.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# b9b53389 25-May-2015 Adrian Chadd <adrian@FreeBSD.org>

Convert malloc/free back to #define's, as part of OS portability work.

DragonflyBSD uses the FreeBSD wireless stack and drivers. Their malloc()
API is named differently, so they don't have userland/kernel symbol
clashes like we do (think libuinet.)

So, to make it easier for them and to port to other BSDs/other operating
systems, start hiding the malloc specific bits behind defines in
ieee80211_freebsd.h.

DragonflyBSD can now put these portability defines in their local
ieee80211_dragonflybsd.h.

This should be a great big no-op for everyone running wifi.

TODO:

* kill M_WAITOK - some platforms just don't want you to use it
* .. and/or handle it returning NULL rather than waiting forever.
* MALLOC_DEFINE() ?
* Migrate the well-known malloc names (eg M_TEMP) to net80211
namespace defines.


# fd90e2ed 22-May-2015 Jung-uk Kim <jkim@FreeBSD.org>

CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head. However, it is continuously misused as the mpsafe argument
for callout_init(9). Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision: https://reviews.freebsd.org/D2613
Reviewed by: jhb
MFC after: 2 weeks


# f0188618 21-Oct-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix multiple incorrect SYSCTL arguments in the kernel:

- Wrong integer type was specified.

- Wrong or missing "access" specifier. The "access" specifier
sometimes included the SYSCTL type, which it should not, except for
procedural SYSCTL nodes.

- Logical OR where binary OR was expected.

- Properly assert the "access" argument passed to all SYSCTL macros,
using the CTASSERT macro. This applies to both static- and dynamically
created SYSCTLs.

- Properly assert the the data type for both static and dynamic
SYSCTLs. In the case of static SYSCTLs we only assert that the data
pointed to by the SYSCTL data pointer has the correct size, hence
there is no easy way to assert types in the C language outside a
C-function.

- Rewrote some code which doesn't pass a constant "access" specifier
when creating dynamic SYSCTL nodes, which is now a requirement.

- Updated "EXAMPLES" section in SYSCTL manual page.

MFC after: 3 days
Sponsored by: Mellanox Technologies


# e7495198 07-Aug-2013 Adrian Chadd <adrian@FreeBSD.org>

Convert net80211 over to using if_transmit for the dispatch from the
upper layer(s).

This eliminates the if_snd queue from net80211. Yay!

This unfortunately has a few side effects:

* It breaks ALTQ to net80211 for now - sorry everyone, but fixing
parallelism and eliminating the if_snd queue is more important
than supporting this broken traffic scheduling model. :-)

* There's no VAP and IC flush methods just yet - I think I'll add
some NULL methods for now just as placeholders.

* It reduces throughput a little because now net80211 will drop packets
rather than buffer them if the driver doesn't do its own buffering.
This will be addressed in the future as I implement per-node software
queues.

Tested:

* ath(4) and iwn(4) in STA operation


# 5cda6006 08-Mar-2013 Adrian Chadd <adrian@FreeBSD.org>

Bring over my initial work from the net80211 TX locking branch.

This patchset implements a new TX lock, covering both the per-VAP (and
thus per-node) TX locking and the serialisation through to the underlying
physical device.

This implements the hard requirement that frames to the underlying physical
device are scheduled to the underlying device in the same order that they
are processed at the VAP layer. This includes adding extra encapsulation
state (such as sequence numbers and CCMP IV numbers.) Any order mismatch
here will result in dropped packets at the receiver.

There are multiple transmit contexts from the upper protocol layers as well
as the "raw" interface via the management and BPF transmit paths.
All of these need to be correctly serialised or bad behaviour will result
under load.

The specifics:

* add a new TX IC lock - it will eventually just be used for serialisation
to the underlying physical device but for now it's used for both the
VAP encapsulation/serialisation and the physical device dispatch.

This lock is specifically non-recursive.

* Methodize the parent transmit, vap transmit and ic_raw_xmit function
pointers; use lock assertions in the parent/vap transmit routines.

* Add a lock assertion in ieee80211_encap() - the TX lock must be held
here to guarantee sensible behaviour.

* Refactor out the packet sending code from ieee80211_start() - now
ieee80211_start() is just a loop over the ifnet queue and it dispatches
each VAP packet send through ieee80211_start_pkt().

Yes, I will likely rename ieee80211_start_pkt() to something that
better reflects its status as a VAP packet transmit path. More on
that later.

* Add locking around the management and BAR TX sending - to ensure that
encapsulation and TX are done hand-in-hand.

* Add locking in the mesh code - again, to ensure that encapsulation
and mesh transmit are done hand-in-hand.

* Add locking around the power save queue and ageq handling, when
dispatching to the parent interface.

* Add locking around the WDS handoff.

* Add a note in the mesh dispatch code that the TX path needs to be
re-thought-out - right now it's doing a direct parent device transmit
rather than going via the vap layer. It may "work", but it's likely
incorrect (as it bypasses any possible per-node power save and
aggregation handling.)

Why not a per-VAP or per-node lock?

Because in order to ensure per-VAP ordering, we'd have to hold the
VAP lock across parent->if_transmit(). There are a few problems
with this:

* There's some state being setup during each driver transmit - specifically,
the encryption encap / CCMP IV setup. That should eventually be dragged
back into the encapsulation phase but for now it lives in the driver TX path.
This should be locked.

* Two drivers (ath, iwn) re-use the node->ni_txseqs array in order to
allocate sequence numbers when doing transmit aggregation. This should
also be locked.

* Drivers may have multiple frames queued already - so when one calls
if_transmit(), it may end up dispatching multiple frames for different
VAPs/nodes, each needing a different lock when handling that particular
end destination.

So to be "correct" locking-wise, we'd end up needing to grab a VAP or
node lock inside the driver TX path when setting up crypto / AMPDU sequence
numbers, and we may already _have_ a TX lock held - mostly for the same
destination vap/node, but sometimes it'll be for others. That could lead
to LORs and thus deadlocks.

So for now, I'm sticking with an IC TX lock. It has the advantage of
papering over the above and it also has the added advantage that I can
assert that it's being held when doing a parent device transmit.
I'll look at splitting the locks out a bit more later on.

General outstanding net80211 TX path issues / TODO:

* Look into separating out the VAP serialisation and the IC handoff.
It's going to be tricky as parent->if_transmit() doesn't give me the
opportunity to split queuing from driver dispatch. See above.

* Work with monthadar to fix up the mesh transmit path so it doesn't go via
the parent interface when retransmitting frames.

* Push the encryption handling back into the driver, if it's at all
architectually sane to do so. I know it's possible - it's what mac80211
in Linux does.

* Make ieee80211_raw_xmit() queue a frame into VAP or parent queue rather
than doing a short-cut direct into the driver. There are QoS issues
here - you do want your management frames to be encapsulated and pushed
onto the stack sooner than the (large, bursty) amount of data frames
that are queued. But there has to be a saner way to do this.

* Fragments are still broken - drivers need to be upgraded to an if_transmit()
implementation and then fragmentation handling needs to be properly fixed.

Tested:

* STA - AR5416, AR9280, Intel 5300 abgn wifi
* Hostap - AR5416, AR9160, AR9280
* Mesh - some testing by monthadar@, more to come.


# d68e1a37 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh HWMP forwarding information: updating FI for transmitter.

* Added hwmp_update_transmitter function that checks if the metric
to the transmitter have improved. If old FI is invalid or metric
is larger the FI to the transmitter is updated occurdingly.
This is a recommendation from the 802.11 2012 standard, table 13-9;

Approved by: adrian (mentor)


# 80e25642 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh HWMP PERR bug fixes.

* When calling ieee80211_mesh_rt_flush_peer, the rt->rt_dest argument
should not be passed because it can get freed before invalidating
the other routes that depends on it to compare with next_hop.
Use PERR_DADDR(i) instead;

Approved by: adrian (mentor)


# 026e280f 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh HWMP PREQ: fixed conditions for discarding elements.

Approved by: adrian (mentor)


# 230394c0 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh HWMP: don't send an intermediate PREP for proxy entries.

* The standard is unclear about what should happen in case a mesh STA (not
marked as a mesh gate) recevies a PREQ for a destination that is marked
as proxy. Solution for now is not to do intermediate reply at all, and
let the PREQ reach the mesh gate;

Approved by: adrian (mentor)


# 6e839020 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh HWMP PREQ update: proxy reply only if mesh STA is a meshgate.

* Original PREP frame is transmitted only by the target mesh STA or the
mesh STA that is the proxy target;
* Fixed so that metric value is not over written incorrectly in
hwmp_recv_preq for when replying back with a PREP;

Approved by: adrian (mentor)


# 4c4f4aa0 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

HWMP: ic->raw_xmit didn't always point to correct ni.

This is a code re-write. ic->raw_xmit need a pointer to ieee80211_node
for the destination node (da). I have reorganized the code so that
a pointer to the da node is searched for in the end & in one place.

* Make mesh_find_txnode public to be used by HWMP, renamed to
ieee80211_mesh_finx_txnode;
* changed the argument from ieee80211_node to ieee80211vap for all
hwmp_send_* functions;
* removed the 'sa' argument from hwmp_send_* functions as all HWMP frames
have the source address equal to vap->iv_myaddr;
* Modified hwmp_send_action so that if da is MULTCAST ni=vap->iv_bss
otherwise we called ieee80211_mesh_find_txnode. Also no need to hold
a reference in this functions if da is not MULTICAST as by finding the
node it became referenced in ieee80211_find_txnode;

Approved by: adrian (mentor)


# b79858da 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Send frames to mesh gate if 11s discovery fails.

* Send frames that have no path to a known valid Mesh Gate;
* Added the function ieee80211_mesh_forward_to_gates that sends the frame
to the first found Mesh Gate in the forwarding information;
* If we try to discover again while we are discovering queue frame,
the discovery callout will send the frames either to mesh gates
or discards them silently;
* Queue frame also if we try to discover to frequently;

Approved by: adrian (mentor)


# a21c6123 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mark root mesh as gate when mesh gate flag set.

* Add function ieee80211_mesh_mark_gate in ieee80211_mesh.h;
* When received a proactive PREQ or RANN with corresponding mesh gate
flag set, create a new entry in the known mesh gate list;

Approved by: adrian (mentor)


# ed0b5440 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh update: add base Mesh Gate functionality.

A Mesh Gate should transmit a Mesh Action frame containing
ieee80211_meshgann_ie as its only information element periodically
every ieee80211_mesh_gateint ms. Unless the mesh gate is also configure
as a ROOT, then these frames should not be send.
This is according to 802.11 2012 standard;

* Introduce new SYSCTL net.wlan.mesh.gateint, with 10s default;
* Add two new functions mesh_gatemode_setup and mesh_gatemode_cb. This
is similar to how HWMP setups up a callout;
* Add two new action handlers mesh_recv_action_meshgate and
mesh_send_action_meshgate;
* Added ieee80211_add_meshgate to ieee80211_mesh.h;
* Modified mesh_send_action to look similar to hwmp_send_action. This is
because we need to send out broadcast management frames.
* Introduced a new flag for mesh state IEEE80211_MESHFLAGS_ROOT. This flag
is now set by HWMP code when a mesh STA is configured as a ROOT. This
is then checked by mesh_gatemode_cb before scheduling a new callout;
* Added to new field to ieee80211_mesh_state:
+ struct callout ms_gatetimer
+ ieee80211_mesh_seq ms_gateseq;

Approved by: adrian (mentor)


# cd47d75c 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh: management mesh action frames are to be discarded
when not peered.

* Modified ieee80211_recv_action to check if neighbour is peered for
IEEE80211_ACTION_CAT_MESH frames, if not frame is discarded. This is
according to IEEE802.11 2012 standard;
* Removed duplicate checks in each hwmp_recv_* handlers because HWMP
is a subtype of mesh action;

Approved by: adrian (mentor)


# 40c44a6b 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

HWMP: Accept a PERR even if path is valid.

* An HWMP PERR should be accepted even if path is valid. Because
we check if we recevied it from a neighbour that we use as a next hop;

Approved by: adrian (mentor)


# 8c751dd5 07-Feb-2013 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Fix mesh path flag.

* A bug occurs while in discovery mode which leaves a path marked with
both Discover and Valid flag. This happens when receiving/sending
PREQ and PREP in a particular order. Solution is to assign the Valid bit
instead of oring it;

Approved by: adrian (mentor)


# 17b08c43 05-Jan-2013 Adrian Chadd <adrian@FreeBSD.org>

Handle HWMP if_transmit() failure gracefully.

If if_transmit() fails, the node ref may need freeing.

This is based on the same logic used by the ageq, which the mesh code
(re) uses for frames which need to be staged before transmitting.
It also does the same thing - if M_ENCAP is set on the mbuf, it treats
the recvif pointer as a node reference and derefs it.


# eb1b1807 05-Dec-2012 Gleb Smirnoff <glebius@FreeBSD.org>

Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags within sys.

Exceptions:

- sys/contrib not touched
- sys/mbuf.h edited manually


# 33a2506f 31-Jul-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Fixed some debug output in hwmp_recv_prep.


# cfe15694 31-Jul-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Fix a PREQ comparison error in 11s HWMP.

* Earlier we compared two not equal metrics, one was what we recevied
in the 'new PREQ' while the other was what we already have saved which
was 'old PREQ' + link metric for the last hop;
* Fixed by adding 'new PREQ' + link metric for the last hop in a
temporary variable;


# b06953a4 31-Jul-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Fix bugs in net80211s found with wtap simulator.

For description of the test scripts refer to projects/net80211_testsuite/wtap.

* Test 007 showed a bug in intermediate PREP for a proxy entry. Resolved;
* Test 002 showed a bug in the Addressing Mode flag for a PREQ. Resolved;


# 46684c91 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Update HWMP Proactive code and mesh route flags.

* Modified hwmp_recv_preq:
o cleaned up code, removed rootmac variable because preq->origaddr
is the root when we recevie a Proactive PREQ;
o Modified so that a PREP in response of a Proactive PREQ is unicast,
a PREP is ALWAYS unicast;
* Modified hwmp_recv_prep:
o Before we mark a route to be valid we should remove the discovery
flag and then mark it valid in such a way we wont lose the isgate flag;

Approved by: adrian


# 47451c66 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

PREQ discovery update.

* Added a new discovery flag IEEE80211_MESHRT_FLAGS_DISCOVER;
* Modified ieee80211_ioctl.h to include IEEE80211_MESHRT_FLAGS_DISCOVER;
* Added hwmp_rediscover_cb, which will be called by a timeout to do
rediscovery if we have not reach max number of preq discovery;
* Modified hwmp_discover to setup a callout for path rediscovery;
* Added to ieee80211req_mesh_route to have a back pointer to ieee80211vap
for the discovery callout context;
* Modified mesh_rt_add_locked arguemnt from ieee80211_mesh_state to
ieee80211vap, this because we have to initialize the above back pointer;

Approved by: adrian


# 9fc85253 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Net80211s update: Mesh Gate Announcement and removal of Portal Announcement.

* Renamed IEEE80211_ELEMID_MESHPANN to IEEE80211_ELEMID_MESHGANN according to
amendment;
* Added IEEE80211_IOC_MESH_GATE that controls whether Mesh Gate Announcement
is activated or not;
* Renamed all flags from Portal to Gate in HWMP frames;
* Removed IEEE80211_ACTION_MESHPANN enum cause its part of the Mesh Action
category now as per amendment;
* Renamed IEEE80211_MESHFLAGS_PORTAL to IEEE80211_MESHFLAGS_GATE in
ieee80211_mesh_state flags;
* Modified ieee80211_hwmp.c/ieee80211_mesh.c to use new GATE flags;

Approved by: adrian


# f02ce81b 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

RANN update

* Introduced a new HWMP sysctl, Root Confirmation Interval;
* Added hr_lastrootconf to hwmp_route, is for ratecheck for a specific ROOT;
* We missed reading RANN.interval subfield from a RANN frame before;
* Updated hwmp_recv_rann according to amendment, see comments;

Approved by: adrian


# 3db82516 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

PERR update to be called from mesh code.

* Added mpp_senderror for Mesh Path Selection protocol;
* Added hwmp_senderror that will send an HWMP PERR according to the
supplied reason code;
* Call mpp_senderror when deleting a route with correct reason code
for whether the route is marked proxy or not;
* Call mpp_senderror when trying to forward an individually addressed
frame and there is no forwarding information;

Approved by: adrian


# d421a252 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

* Modified PERR acceptance criteria according to amendment;
* Modified how PERR is handled and propagated according to amendment;

Approved by: adrian


# c0985dbc 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Updated PREQ propagation code;

* When receiving a Proactive PREQ dont return after processing it but propagate;
* When we propagate we should not enforce ratechecking;
* Added checking for multiple pred ID detection;
* Storing proxy orig address when PREQ is not for us;

Approved by: adrian


# 52e45fc0 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

* PREQ acceptance criteria updated to check for proxy condition as in amendment;

Approved by: adrian


# 53c35d21 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

* Proactive PREQ (original transmission) must also set
IEEE80211_MESHPREQ_TFLAGS_USN flag in target_flag field;

Approved by: adrian


# 7b977be4 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

* Fixed hwmp_discover code to populate a PREQ packet correctly;
* Removed IEEE80211_MESHPREQ_TFLAGS_RF which is no longer part of the
amendment spec;

Approved by: adrian


# 3d7486ce 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

* Fixed PREQ flag field Adressing mode subfiled according to amendment specs;

Approved by: adria


# 79b9f8c6 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

* Added a mesh max PREQ retires sysctl that governous how many times
we try to discover an address;
* Added a mesh net travelse time across an MBSS, which is used to enforce
discovery rate check;

Approved by: adrian


# 8ccfff66 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Change how we enforce PREQ minimum interval.

* Moved hs_lastpreq to be hr_lastpreq cause this rate check should be per
target mesh STA according to amendment (NB: not applicable for PERR);
* Modified hwmp_send_preq to use two extra arguments for last sent PREQ and
minimum PREQ interval;
* hwmp_send_preq is called with last two arguments equal to NULL when sending
Proactive PREQs cause the call back task enforces the rate check;

Approved by: adrian


# 644ccee4 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

PREP update

* Added assertion in mesh_rt_update;
* Fixed some prep propagation that where multicast, ALL PREPS ARE UNICAST;
* Fixed PREP acceptance criteria;
* Fixed some PREP debug messages;
* HWMP intermediate reply (PREP) should only be sent if we have newer
forwarding infomration (FI) about target;
* Fixed PREP propagation condition and PREP w/ AE handling;
* Ignore PREPs that have unknown originator.
* Removed old code inside PREP that was for proactive path building
to root mesh;

Other errors include:
* use seq number of target and not orig mesh STA;
* Metric is what we have stored in our FI;
* Error in amendment, Hop count is not 0 but equals FI hopcount for target;

Approved by: adrian


# 3c314f6d 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Mesh forwarding with proxy support.

* Modified HWMP PREP/PREQ to contain a proxy entry and also changed PREP
frame processing according to amendment as following:
o Fixed PREP to always update/create if acceptance criteria is meet;
o PREQ processing to reply if request is for a proxy entry that is
proxied by us;
o Removed hwmp_discover call from PREQ, because sending a PREP will
build the forward path, and by receving and accepting a PREQ we
have already built the reverse path (non-proactive code);
* Disabled code for pro-active in PREP for now (will make a separate patch for
pro-active HWMP routing later)
* Added proxy information for a Mesh route, mesh gate to use and proxy seqno;
* Modified ieee80211_encap according to amendment;
* Introduced Mesh control address extension enum and removed unused struct,
also rename some structure element names.
* Modified mesh_input and added mesh_recv_* that should verify and process mesh
data frames according to 9.32 Mesh forwarding framework in amendment;
* Modified mesh_decap accordingly to changes done in mesh control AE struct;

Approved by: adrian


# b5df85a6 01-May-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

Implemented so that Mesh forwarding information lifetime is dynamic.

* Introduced ieee80211_mesh_rt_update that updates a route with the
maximum(lifetime left, new lifetime);
* Modified ieee80211_mesh_route struct by adding a lock that will be used
by both ieee80211_mesh_rt_update and precursor code (added in future commit);
* Modified in ieee80211_hwmp.c HWMP code to use new ieee80211_mesh_rt_update;
* Modified mesh_rt_flush_invalid to use new ieee80211_mesh_rt_update;
* mesh_rt_flush also checks that lifetime == 0, this gives route discovery
a change to complete;
* Modified mesh_recv_mgmt case IEEE80211_FC0_SUBTYPE_BEACON:
when ever we received a beacon from a neighbor we update route lifetime;

Approved by: adrian


# 1f88a92b 06-Mar-2012 Adrian Chadd <adrian@FreeBSD.org>

Modify HWMP to be able to allocate memory for PREQ/PREP/PERR for all scenarios.

* Added verify_mesh_*_len functions that verify the length
according to the amendment spec and return number of destination addresses
for allocation of appropriate struct size in memory;
* Modified hwmp_recv_action_meshpath to allocate HWMP ie instead of
storing them on the stack and store all available field according the flags;
* Modify hwmp_add_mesh* to work with all cases of HWMP according to amendment.
* Modify hwmp_send_* to calculate correct len of bytes for the HWMP ie.
* Added new M_80211_MESH_* malloc defines.
* Added macros with magic numbers for HWMP ie sizes according to amendment.
* Added the external address to all HWMP ie structs.

Submitted by: monthadar@gmail.com


# bdd2a076 03-Mar-2012 Adrian Chadd <adrian@FreeBSD.org>

* Added IEEE80211_ACTION_CAT_MESH in ieee80211.h as specified amendment spec;
* Moved old categories as specified by D4.0 to be action fields of MESH category
as specified in amendment spec;
* Modified functions to use MESH category and its action fields:
+ ieee80211_send_action_register
+ ieee80211_send_action
+ ieee80211_recv_action_register
+ieee80211_recv_action;
* Modified ieee80211_hwmp_init and hwmp_send_action so they uses correct
action fields as specified in amendment spec;
* Modified ieee80211_parse_action so that it verifies MESH frames.
* Change Mesh Link Metric to use one information element as amendment spec.
Draft 4.0 defined two different information elements for request and response.

Submitted by: monthadar@gmail.com


# dfdcd4c7 29-Jan-2012 Adrian Chadd <adrian@FreeBSD.org>

Missing code for receiving MESH PREP that should be part of r230409.

Submitted by: <monthadar@gmail.com>


# e148ff49 20-Jan-2012 Adrian Chadd <adrian@FreeBSD.org>

Fix the hwmp code to handle nodes in a "line" topology.

For example, this particular topology didn't work correctly from all
nodes:

[A] - [B] - [C] - [D]

Submitted by: Monthadar Al Jaberi <monthadar@gmail.com>
Reviewed by: bschmidt, adrian


# f7c90cbb 20-Jan-2012 Adrian Chadd <adrian@FreeBSD.org>

Change the hwmp debugging to use %6D rather than ether_sprintf().

This allows for multiple MAC addresses to be printed on the same
debugging line. ether_sprintf() uses a static char buffer and
thus isn't very useful here.

Submitted by: Monthadar Al Jaberi <monthadar@gmail.com>


# 6472ac3d 07-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# dd7fc699 10-Jun-2010 Rui Paulo <rpaulo@FreeBSD.org>

Add missing braces.

Submitted by: sam
MFC after: 3 days


# 8b7b5858 05-Jun-2010 Rui Paulo <rpaulo@FreeBSD.org>

MFC r208696:
Don't reference null pointer in hwmp_recv_preq().

Found with: Coverity Prevent(tm)
CID: 3912
Approved by: re (bz)


# db309534 01-Jun-2010 Rui Paulo <rpaulo@FreeBSD.org>

Don't reference null pointer in hwmp_recv_preq().

Found with: Coverity Prevent(tm)
CID: 3912
MFC after: 3 days


# db463c13 03-Nov-2009 Rui Paulo <rpaulo@FreeBSD.org>

MFC r198581:
Update the route's sequence number upon receiving a RANN.


# e22a16d5 30-Oct-2009 Rui Paulo <rpaulo@FreeBSD.org>

MFC r198230, r198242, r198260, r198346, r198369, r198384:

More mesh fixes to comply with latest draft.


# 71a77504 28-Oct-2009 Rui Paulo <rpaulo@FreeBSD.org>

Update the route's sequence number upon receiving a RANN.

MFC after: 3 days


# 038abe36 22-Oct-2009 Rui Paulo <rpaulo@FreeBSD.org>

Initialize rann_flags properly.

MFC after: 2 days


# d5e9eabe 19-Oct-2009 Rui Paulo <rpaulo@FreeBSD.org>

Fix a bug in composing PERR frames introduced by latest draft update.

MFC after: 3 days


# 34413c0e 19-Oct-2009 Rui Paulo <rpaulo@FreeBSD.org>

HWMP fixes, namely:
* fix the processing of RANN frames
* the originator and target addresses were swapped and while it worked
fine, it was not spec compliant.

MFC after: 3 days


# 596646ae 17-Oct-2009 Rui Paulo <rpaulo@FreeBSD.org>

MFC 197975, 197977, 197980, 198027:
Update for latest 802.11s changes in meshconf format.

Approved by: re (kib)


# 6b8c1829 12-Oct-2009 Rui Paulo <rpaulo@FreeBSD.org>

Another 3.03 draft bit that I missed in the previous 802.11s stack
update. The Mesh Configuration IE has changed quite a bit. Refactor the
code to handle this change.

MFC after: 3 days


# f785216c 28-Sep-2009 Rui Paulo <rpaulo@FreeBSD.org>

Update 802.11s mesh support to draft 3.03. This includes a revised frame
format for peering and changes to the PERR frames.
Note that this is incompatible with the previous code.

Reviewed by: sam
Approved by: re (kib)


# c77735e2 22-Sep-2009 Rui Paulo <rpaulo@FreeBSD.org>

Update 802.11s mesh support to draft 3.03. This includes a revised frame
format for peering and changes to the PERR frames.
Note that this is incompatible with the previous code.

Reviewed by: sam
MFC after: 1 week


# 3ca80f0d 27-Jul-2009 Rui Paulo <rpaulo@FreeBSD.org>

Mesh fixes, namely:
* don't clobber proxy entries
* HWMP seq number processing, including discard of old frames
* flush routing table entries based on nexthop
* print route flags in ifconfig
* more debugging messages and comments

Proxy changes submitted by sam.

Approved by: re (kib)


# e50821ab 21-Jul-2009 Sam Leffler <sam@FreeBSD.org>

store mesh timers as ticks and sysctls for changing the defaults

Reviewed by: rpaulo
Approved by: re (kib)


# c104cff2 20-Jul-2009 Rui Paulo <rpaulo@FreeBSD.org>

More mesh bits, namely:
* bridge support (sam)
* handling of errors (sam)
* deletion of inactive routing entries
* more debug msgs (sam)
* fixed some inconsistencies with the spec.
* decap is now specific to mesh (sam)
* print mesh seq. no. on ifconfig list mesh
* small perf. improvements

Reviewed by: sam
Approved by: re (kib)


# 59aa14a9 11-Jul-2009 Rui Paulo <rpaulo@FreeBSD.org>

Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.

Authentication and encryption are not implemented.

There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).

A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.

Drivers that support mesh networks right now are: ath, ral and mwl.

More information at: http://wiki.freebsd.org/WifiMesh

Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.

Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.

Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s