Commit Graph

432 Commits

Author SHA1 Message Date
msaitoh 48b6679adf s/ we we / we / 2020-11-30 05:30:56 +00:00
mlelstv 133f2ddbfa Use kmem_* instead of malloc/free and use interrupt versions as the
code can be called from interrupt.
2020-11-03 15:06:50 +00:00
roy b4de43c2d1 net80211: Initialise the interface with a decent link state.
Link state transitions to UP when a node is joined and DOWN when left.
This means that with the interface UP, the link state could be UNKNOWN
for a while, implying it can be used in BSS mode.
Which is of course false.

Add a function to set an initial link state based on the operating mode.
Also call this when the operating mode changes.

Basically in BSS and MONITOR it starts off down.
BSS will transition UP and DOWN as before, MONITOR will stay down.
IBSS, AHDEMO and HOSTAP will remain as link unknown because the state is
..... unknown.
2020-10-06 23:51:05 +00:00
riastradh 849deab67e Omit now-unused function.
Ceased to be needed with the AES CCM changes.

For some reason gcc didn't complain about this, but clang did.
2020-07-28 15:41:26 +00:00
riastradh c79a1e3b24 Convert malloc -> kmem.
Switch order of members for better alignment.  Sort includes.
2020-07-25 22:27:05 +00:00
riastradh 789f2860cf Convert ieee80211_crypto_ccmp.c to new aes_ccm API.
This will make it easier to provide better hardware acceleration
without fpu enabling/disabling overhead for each block of data.
2020-07-25 22:26:23 +00:00
msaitoh 984bb2b315 s/reseting/resetting/ 2020-07-22 01:24:39 +00:00
mrg fb9981acab i hit an assert in this code but we weren't sure why.
for now, add the ostate and nstate values for further diagnosis
to the assert message.
2020-07-13 05:40:25 +00:00
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