Commit Graph

424 Commits

Author SHA1 Message Date
thorpej
7a9a30c5e7 Define and implement a locking protocol for the ifmedia / mii layers:
- MP-safe drivers provide a mutex to ifmedia that is used to serialize
  access to media-related structures / hardware regsiters.  Converted
  drivers use the new ifmedia_init_with_lock() function for this.  The
  new name is provided to ease the transition.
- Un-converted drivers continue to call ifmedia_init(), which will supply
  a compatibility lock to be used instead.  Several media-related entry
  points must be aware of this compatibility lock, and are able to acquire
  it recursively a limited number of times, if needed.  This is a SPIN
  mutex with priority IPL_NET.
- This same lock is used to serialize access to PHY registers and other
  MII-related data structures.

The PHY drivers are modified to acquire and release the lock, as needed,
and assert the lock is held as a diagnostic aid.

The "usbnet" framework has had an overhaul of its internal locking
protocols to fit in with the media / mii changes, and the drivers adapted.

USB wifi drivers have been changed to provide their own adaptive mutex
to the ifmedia later via a new ieee80211_media_init_with_lock() function.
This is required because the USB drivers need an adaptive mutex.

Besised "usbnet", a few other drivers are converted: vmx, wm, ixgbe / ixv.

mcx also now calls ifmedia_init_with_lock() because it needs to also use
an adaptive mutex.  The mcx driver still needs to be fully converted to
NET_MPSAFE.
2020-03-15 23:04:50 +00:00
mlelstv
68e96ced7e Fix printf to handle various datatypes for MHLEN. 2020-02-29 16:56:58 +00:00
rin
4ecd76e535 0x%p --> %p for non-external codes. 2020-02-24 12:20:29 +00:00
thorpej
4947e861f2 Use ifmedia_fini(). 2020-02-04 05:44:14 +00:00
thorpej
1a2cab1766 Adopt <net/if_stats.h>. 2020-01-29 05:20:26 +00:00
msaitoh
a5effc3ce9 s/inital/initial/ 2019-12-27 09:25:57 +00:00
kamil
953f1255fa Avoid changing signedness bit with << 24 in ieee80211_crypto_tkip.c
Reported by <prlw1>
2019-12-19 16:29:50 +00:00
jakllsch
d906a817cb Add comment for previous. 2019-12-19 15:54:21 +00:00
jakllsch
f634dfed5c Do not associate with with any access point if no SSID has been configured. 2019-12-19 15:27:07 +00:00
chs
d47bcd296c in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
2019-11-10 21:16:21 +00:00
mrg
49e1839354 remove __packed attribute from struct ieee80211_radiotap_header
and all the structures that include it.

this should not change anything while avoiding packed vs alignment
warnings from GCC 8, and potentially pessimised code generation
due to the packed marker (there are no misaligned members, just
that the per-device parts may end unaligned.)

all consumers of these members are done from the properly aligned
packet members directly, or, as a union with a 64 byte member,
also properly aligned.  codegen didn't appear to change, except
for the definition of sizeof(struct driver_[rt]x_radiotap_header)
in debug info, which is not directly used anywhere.
2019-10-05 23:27:20 +00:00
jmcneill
f1768a45f2 ieee80211_announce: Print supported rates with aprint_debug 2019-10-03 17:46:56 +00:00
christos
eb1a88a41d Include <net/if.h> for IFNAMSIZ 2019-08-20 09:28:00 +00:00
msaitoh
593915784e Remove extra OSIOCSIFMEDIA. This old ioctl is converted to new one in
doifioctl().
2019-05-17 04:08:54 +00:00
kamil
894a43424d Fix CVS Id
NFCI
2019-04-11 11:40:58 +00:00
pgoyette
8c2f80f160 Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.

NFCI intended.

Ride the earlier kernel bump - it;s getting crowded.
2019-03-01 11:06:55 +00:00
pgoyette
c1283e70fa Normalize all the compat hooks' names to the form
<subsystem>_<function>_<version>_hook

NFCI

XXX Note that although this introduces a change in the kernel-to-
XXX module interface, we are NOT bumping the kernel version number.
XXX We will bump the version number once the interface stabilizes.
2019-01-29 09:28:50 +00:00
christos
40fd447032 - Don't expose random data conversion functions, but expose the high level
entry point (such as ioctl) instead.
- Attempt to autoload the module before using it.

Naming: Should the names of the hooks be:
    <category>_<version>_<function>_hook_t
or:
    <category>_<function>_<version>_hook_t

We should make those consistent.
2019-01-28 21:13:58 +00:00
pgoyette
d91f98a871 Merge the [pgoyette-compat] branch 2019-01-27 02:08:33 +00:00
maxv
5b040abec8 Replace M_ALIGN and MH_ALIGN by m_align. 2018-12-22 14:28:56 +00:00
maxv
fc568a6805 Move m_align() back into the kernel, and switch M_ALIGN and MH_ALIGN to it.
Forcing a distinction between M_ALIGN and MH_ALIGN is too bug-friendly and
serves no particular purpose.
2018-12-22 13:55:56 +00:00
maxv
b1305a6d63 Replace: M_MOVE_PKTHDR -> m_move_pkthdr. No functional change, since the
former is a macro to the latter.
2018-12-22 13:11:37 +00:00
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
msaitoh
3cd62456f9 Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

 This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
2018-06-26 06:47:57 +00:00
maxv
1f639d0627 remove unused arguments 2018-06-21 17:03:45 +00:00
maxv
0a9aff6f39 Fix use-after-free, m_cat can free m. 2018-06-21 16:53:10 +00:00
maxv
2b9c280811 Remove three useless debug messages, remove meaningless XXXs, and remove
ieee80211_note_frame (unused).
2018-05-08 07:02:07 +00:00
maxv
eced41b4e7 Remove duplicate macros. Reported in PR/29786. 2018-05-04 11:25:24 +00:00
maxv
eb485b2186 Remove ovbcopy from net80211. 2018-05-03 17:14:37 +00:00
maxv
3f23c9efec Move m_align and m_append into iee80211_netbsd.c. They are part of
net80211, and shouldn't be used outside.
2018-04-27 06:56:21 +00:00
christos
87fd18f8e5 s/static inline/static __inline/g for consistency. 2018-04-19 21:50:06 +00:00
maxv
f412fe9bd5 Improve an XXX of mine, and fix one stat. 2018-04-10 07:53:36 +00:00
maxv
6cbd9d0315 Switch sp_timoff to u_int16_t, to prevent possible overflow in
ieee80211_recv_mgmt_beacon(). Actually this field is unused.
2018-01-21 14:18:21 +00:00
maxv
03cb445009 Appease the overflow check, 4 is enough. 2018-01-21 14:13:49 +00:00
maxv
64b112643a Style, no functional change. 2018-01-19 07:58:25 +00:00
maxv
5b9905a59d Style, and check the return value of m_append. 2018-01-19 07:57:50 +00:00
maxv
5e3a8040f2 Style, no functional change. 2018-01-19 07:53:46 +00:00
maxv
fd8bca6477 Style, and make sure that there is a header+trailer included in the
packet. The crypto functions can touch the trailer, but they don't check
whether it's there in the first place.
2018-01-19 07:52:37 +00:00
maxv
c153ca3cd5 Style, no functional change. 2018-01-18 17:59:29 +00:00
maxv
f43b144132 Style, and zero out 'ns' entirely, otherwise some bytes get leaked to
userland (eg ns_rsvd0).
2018-01-18 17:57:49 +00:00
maxv
b37f61bc9b Several changes:
* Make the code more readable.

 * Add a panic in ieee80211_compute_duration(). I'm not sure there's
   a bug here - I don't have the hardware -, but looking at the code, it
   may be possible for 'paylen' to go negative. Obviously that's not the
   correct way to fix it, but at least we'll see if it happens.
2018-01-18 16:23:43 +00:00
maxv
4d4ed9988c Several changes:
* Make the code more readable. In particular, declare variables as const
   along the way.

 * Explain what we're doing in ieee80211_send_mgmt(). The
   IEEE80211_FC0_SUBTYPE_PROBE_RESP case has some inconsistencies, but
   they are not inherently wrong so I'm not changing that.

 * When sending IEEE80211_FC0_SUBTYPE_REASSOC_RESP frames, make sure to
   zero out the 'association ID', otherwise two bytes are leaked.

 * Fix a possible memory leak in ieee80211_send_probereq().
2018-01-18 13:24:01 +00:00
maxv
d89ae4bbdd Style, and fix two pretty bad mistakes in the crypto functions:
* They call M_PREPEND, but don't pass the updated pointer back to the
   caller.

 * They use memmove on the mbuf data, but they don't ensure that the
   area they touch is contiguous.

This fix is not complete, ieee80211_crypto_encap too needs to pass back
the updated pointer. This will be done in another commit.
2018-01-17 17:41:38 +00:00
maxv
a45976c272 Several changes:
* Style in several places, to make the code more readable or easier to
   understand.

 * Instead of checking m->m_pkthdr.len, check m->m_len. m_pkthdr.len is
   the total size of the packet, not the size of the current mbuf (which
   may be smaller).

 * Add a missing length check when handling QoS frames.

 * Cast the lengths passed in IEEE80211_VERIFY_LENGTH to size_t.

 * Remove the length check on scan.sp_xrates, that I added yesterday.
   xrates gets silently truncated in ieee80211_setup_rates().

 * Fix several buffer overflows in the parsers of the MANAGEMENT frames.
2018-01-17 16:03:16 +00:00
maxv
11a42b5c1a Various fixes: style, remove tiring XXXs, and prevent integer overflow in
ieee80211_setup_rates (normally it already can't happen, because I added a
length check on xrates in ieee80211_recv_mgmt_beacon).
2018-01-16 18:53:32 +00:00
maxv
1df75eef54 Prepend 'sp_' to the name of the fields, so that they can easily be found
via NXR or grep.
2018-01-16 18:42:43 +00:00
maxv
3b005d6b1f Add comments about the length checks, and check xrates. 2018-01-16 16:54:54 +00:00
maxv
1551d983f8 Gather related code. 2018-01-16 16:31:37 +00:00
maxv
0170309ae1 Style on the new functions. 2018-01-16 16:20:57 +00:00
maxv
82e96ed75b Introduce ieee80211_recv_mgmt_disassoc. 2018-01-16 16:09:30 +00:00