History log of /freebsd-current/sys/dev/wtap/if_wtap.c
Revision Date Author Comments
# 026520a5 21-Apr-2024 Gordon Bergling <gbe@FreeBSD.org>

wtap: Fix typos in kernel messages

- s/cant/can't/

MFC after: 1 week


# 1c6dd33d 03-Nov-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

Revert "Widen EPOCH(9) usage in PCI WLAN drivers."

This reverts commit b65f813c1ab99448278961c5ca80dc422b1eae29.
As a side effect this also seems to fix wtap which seems to have
lost the epoch over the input path in between.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\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


# c0b65123 15-Aug-2022 En-Wei Wu <enweiwu@FreeBSD.org>

wtap: Implement IBSS mode on wtap(4)

For TSF and beacon generation, each STA has to start its local TSF timer
and sends beacon frames when it reaches the state IEEE80211_S_RUN.
The TSF timer will be used for IBSS merge and beacon frame transmission.

The TSF timer is kept in the HAL of wtap(4). It is working by
continuously updating its value on timer interrupt simulated
by callout_reset().

When receiving beacons, the STA will be merged into the IBSS if
- the STA has the same SSID as the beacon sender
- the STA's TSF timer is smaller than the beacon sender's TSF timer.

After the merging process, the younger STA will be in the IBSS
created by the older STA and the younger STA stops sending beacon
frames. So beacon frames will always be sent by the oldest STA
in IBSS.

Sponsored by: Google, Inc. (GSoC 2022)
Reviewed By: lwhsu, adrian
Differential Revision: https://reviews.freebsd.org/D35841


# fb1526ca 01-Aug-2022 En-Wei Wu <enweiwu@FreeBSD.org>

wtap(4): Fix bug in wtap_node_write() and wtap_vap_create()

Originally, wtap_node_write() gets the wrong softc by iterating V_inet and
gets the ifp by string comparison, then gets softc by ifp->if_softc.
However, ifp->if_softc will not point to the correct softc owned by
ieee80211com, and thus causes a kernel panic.
Fix it by assigning softc to cdev's si_drv1 in wtap_vap_create()
and get the softc directly via dev->si_drv1 in wtap_node_write().

The cdev created by wtap_vap_create() use the name of ieee80211com
rather than the vap's name. It will cause the second vap based on
the same ieee80211com as first vap fail to create a device node
because the device node is already exists. Fix it by assigning
vap->iv_ifp->if_xname to cdev's name.

Sponsored by: Google, Inc. (GSoC 2022)
Reviewed by: adrian, cy, bz
Differential Revision: https://reviews.freebsd.org/D35752


# cf337fcd 28-Jun-2022 En-Wei Wu <enweiwu@FreeBSD.org>

Remove store-only variable and unnecessary bzero()

- Remove the variable set but not used to fix build on -CURRENT
- Remove bzero() on the space malloc'd with M_ZERO flag.

Signed-off-by: En-Wei Wu <enweiwu@FreeBSD.org>

Sponsored by: Google, Inc. (GSoC 2022)
Differential Revision: https://reviews.freebsd.org/D35624


# c6167b4b 07-Sep-2020 Bjoern A. Zeeb <bz@FreeBSD.org>

WiFi: fix ieee80211_media_change() callers

In r178354 with the introduction of multi-bss ("vap") support factoring
out started and with r193340 ieee80211_media_change() no longer returned
ENETRESET but only 0 or error.
As ieee80211(9) tells the ieee80211_media_change() function should not
be called directly but is registered with ieee80211_vap_attach() instead.

Some drivers have not been fully converted. After fixing the return
checking some of these functions were simply wrappers between
ieee80211_vap_attach() and ieee80211_media_change(), so remove the extra
function, where possible as well.

PR: 248955
Submitted by: Tong Zhang (ztong0001 gmail.com) (original)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation


# 70b1e1c6 04-Mar-2020 Gleb Smirnoff <glebius@FreeBSD.org>

Remove unused function.


# 6c3e93cb 11-Feb-2020 Gleb Smirnoff <glebius@FreeBSD.org>

Use NET_TASK_INIT() and NET_GROUPTASK_INIT() for drivers that process
incoming packets in taskqueue context.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D23518


# b65f813c 30-Jan-2020 Hans Petter Selasky <hselasky@FreeBSD.org>

Widen EPOCH(9) usage in PCI WLAN drivers.

Make sure all occurrences of ieee80211_input_xxx() in sys/dev are
covered by a network epoch section. Do not depend on the interrupt
handler nor any taskqueues being in a network epoch section.

This patch should unbreak the PCI WLAN drivers after r357004.

Pointy hat: glebius@
Sponsored by: Mellanox Technologies


# 4215ce48 02-Feb-2019 Andriy Voskoboinyk <avos@FreeBSD.org>

sys/dev/wtap: Check return value from malloc(..., M_NOWAIT) and
drop unneeded cast.

MFC after: 3 days


# a68cc388 08-Jan-2019 Gleb Smirnoff <glebius@FreeBSD.org>

Mechanical cleanup of epoch(9) usage in network stack.

- Remove macros that covertly create epoch_tracker on thread stack. Such
macros a quite unsafe, e.g. will produce a buggy code if same macro is
used in embedded scopes. Explicitly declare epoch_tracker always.

- Unmask interface list IFNET_RLOCK_NOSLEEP(), interface address list
IF_ADDR_RLOCK() and interface AF specific data IF_AFDATA_RLOCK() read
locking macros to what they actually are - the net_epoch.
Keeping them as is is very misleading. They all are named FOO_RLOCK(),
while they no longer have lock semantics. Now they allow recursion and
what's more important they now no longer guarantee protection against
their companion WLOCK macros.
Note: INP_HASH_RLOCK() has same problems, but not touched by this commit.

This is non functional mechanical change. The only functionally changed
functions are ni6_addrs() and ni6_store_addrs(), where we no longer enter
epoch recursively.

Discussed with: jtl, gallatin


# 4f6c66cc 23-May-2018 Matt Macy <mmacy@FreeBSD.org>

UDP: further performance improvements on tx

Cumulative throughput while running 64
netperf -H $DUT -t UDP_STREAM -- -m 1
on a 2x8x2 SKL went from 1.1Mpps to 2.5Mpps

Single stream throughput increases from 910kpps to 1.18Mpps

Baseline:
https://people.freebsd.org/~mmacy/2018.05.11/udpsender2.svg

- Protect read access to global ifnet list with epoch
https://people.freebsd.org/~mmacy/2018.05.11/udpsender3.svg

- Protect short lived ifaddr references with epoch
https://people.freebsd.org/~mmacy/2018.05.11/udpsender4.svg

- Convert if_afdata read lock path to epoch
https://people.freebsd.org/~mmacy/2018.05.11/udpsender5.svg

A fix for the inpcbhash contention is pending sufficient time
on a canary at LLNW.

Reviewed by: gallatin
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D15409


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

sys/dev: further 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.


# b790c193 02-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

etc: minor spelling fixes.

Mostly comments but also some user-visible strings.

MFC after: 2 weeks


# f9e5b382 22-Oct-2015 Andriy Voskoboinyk <avos@FreeBSD.org>

wtap: remove some obsolete radiotap(9) code

This code is not needed since r192468.

Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D3975


# 210ab3c2 03-Oct-2015 Adrian Chadd <adrian@FreeBSD.org>

net80211: drop ieee80211_beacon_offsets parameter from ieee80211_beacon_alloc() and ieee80211_beacon_update()

Submitted by: <s3erios@gmail.com>
Differential Revision: https://reviews.freebsd.org/D3659


# 0cf00015 22-Sep-2015 Adrian Chadd <adrian@FreeBSD.org>

net80211: include one copy of struct ieee80211_beacon_offsets into ieee80211vap

Submitted by: Andriy Voskoboinyk <s3erios@gmail.com>
Differential Revision: https://reviews.freebsd.org/D3658


# 7a79cebf 27-Aug-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Replay r286410. Change KPI of how device drivers that provide wireless
connectivity interact with the net80211 stack.

Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.

Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:

- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.

Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.

Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to pluknet@, Oliver Hartmann,
Olivier Cochard, gjb@, mmoll@, op@ and lev@, who also participated in
testing.

Reviewed by: adrian
Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# ba2c1fbc 07-Aug-2015 Adrian Chadd <adrian@FreeBSD.org>

Revert the wifi ifnet changes until things are more baked and tested.

* 286410
* 286413
* 286416

The initial commit broke a variety of debug and features that aren't
in the GENERIC kernels but are enabled in other platforms.


# 79d2c5e8 07-Aug-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Change KPI of how device drivers that provide wireless connectivity interact
with the net80211 stack.

Historical background: originally wireless devices created an interface,
just like Ethernet devices do. Name of an interface matched the name of
the driver that created. Later, wlan(4) layer was introduced, and the
wlanX interfaces become the actual interface, leaving original ones as
"a parent interface" of wlanX. Kernelwise, the KPI between net80211 layer
and a driver became a mix of methods that pass a pointer to struct ifnet
as identifier and methods that pass pointer to struct ieee80211com. From
user point of view, the parent interface just hangs on in the ifconfig
list, and user can't do anything useful with it.

Now, the struct ifnet goes away. The struct ieee80211com is the only
KPI between a device driver and net80211. Details:

- The struct ieee80211com is embedded into drivers softc.
- Packets are sent via new ic_transmit method, which is very much like
the previous if_transmit.
- Bringing parent up/down is done via new ic_parent method, which notifies
driver about any changes: number of wlan(4) interfaces, number of them
in promisc or allmulti state.
- Device specific ioctls (if any) are received on new ic_ioctl method.
- Packets/errors accounting are done by the stack. In certain cases, when
driver experiences errors and can not attribute them to any specific
interface, driver updates ic_oerrors or ic_ierrors counters.

Details on interface configuration with new world order:
- A sequence of commands needed to bring up wireless DOESN"T change.
- /etc/rc.conf parameters DON'T change.
- List of devices that can be used to create wlan(4) interfaces is
now provided by net.wlan.devices sysctl.

Most drivers in this change were converted by me, except of wpi(4),
that was done by Andriy Voskoboinyk. Big thanks to Kevin Lo for testing
changes to at least 8 drivers. Thanks to Olivier Cochard, gjb@, mmoll@,
op@ and lev@, who also participated in testing. Details here:

https://wiki.freebsd.org/projects/ifnet/net80211

Still, drivers: ndis, wtap, mwl, ipw, bwn, wi, upgt, uath were not
tested. Changes to mwl, ipw, bwn, wi, upgt are trivial and chances
of problems are low. The wtap wasn't compilable even before this change.
But the ndis driver is complex, and it is likely to be broken with this
commit. Help with testing and debugging it is appreciated.

Differential Revision: D2655, D2740
Sponsored by: Nginx, Inc.
Sponsored by: Netflix


# e369e734 06-Aug-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Make it compilable. No idea if it works.


# 272f6ade 25-May-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Change three methods in struct ieee80211com, namely ic_updateslot,
ic_update_mcast and ic_update_promisc, to pass pointer to the ieee80211com,
not to the ifnet.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# 59686fe9 25-May-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Set ic_softc in all 802.11 drivers. Not required right now, but will be
used quite soon.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


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

Make net80211 drivers supply their device name to the net80211 layer, so
that the latter doesn't need to go through struct ifnet to get their name.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# c8dfaf38 18-Sep-2014 Gleb Smirnoff <glebius@FreeBSD.org>

Mechanically convert to if_inc_counter().


# 398228fc 18-Dec-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

wtap should not set the IEEE80211_F_DATAPAD flag;

Approved by: adrian (mentor)


# e605766a 18-Dec-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

wtap fix malloc/free.

* Remove malloc/free pointer cast;
* Check return value from malloc;

Submitted by: glebius
Approved by: adrian (mentor)


# 263bbda9 18-Dec-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

wtap should check if ieee80211_vap_setup fails.

* If ieee80211_vap_setup fails, we free allocated M_80211_VAP
memory and return NULL;

Approved by: adrian (mentor)


# 3c6b7169 18-Dec-2012 Monthadar Al Jaberi <monthadar@FreeBSD.org>

wtap: fix clang warning.

* The warning message was:
'warning error: format string is not a string literal';
* Changed how make_dev is called, now a string literal
for formatting is used;

Approved by: adrian (mentor)


# c6499ecc 04-Dec-2012 Gleb Smirnoff <glebius@FreeBSD.org>

Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags in sys/dev.


# a1d97d2e 27-Aug-2012 Adrian Chadd <adrian@FreeBSD.org>

Don't grab an unreferenced pointer to the VAP bss node.


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

Fix wtap to not panic in wtap_beacon_intrp.

* Changed KASSERT to be debug printf (DWTAP_PRINTF). If state is not
IEEE80211_S_RUN we return without scheduling a new callout;
* When net80211 stack changes state to IEEE802_11_INIT we stop the
beacon callout task;


# b850e3b8 19-Mar-2012 Adrian Chadd <adrian@FreeBSD.org>

Remove this - it's not needed as it's defined in ieee80211_freebsd.h.


# c4b72ba1 14-Mar-2012 Adrian Chadd <adrian@FreeBSD.org>

Correctly calculate the callout interval for beacon generation.

Submitted by: monthadar@gmail.com


# 3c77ac7c 09-Mar-2012 Adrian Chadd <adrian@FreeBSD.org>

Enforce that wtap requires VIMAGE to be useful.


# 7870adb6 09-Feb-2012 Ed Schouten <ed@FreeBSD.org>

Remove direct access to si_name.

Code should just use the devtoname() function to obtain the name of a
character device. Also add const keywords to pieces of code that need it
to build properly.

MFC after: 2 weeks


# 04d19802 11-Jan-2012 Adrian Chadd <adrian@FreeBSD.org>

Introduce wtap, the beginnings of a net80211 wlan simulator.

This introduces:

* a basic wtap interface
* a HAL, which implements an abstraction layer for implementing
different device behavious;
* A visibility plugin, which allows for control over which nodes
see other nodes (useful for mesh work.)

It doesn't yet implement sta/adhoc/hostap modes but these are quite
feasible to implement.

Monthadar uses it to do 802.11s mesh verification.

The userland tools will be committed in a follow-up commit.

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