Commit Graph

297 Commits

Author SHA1 Message Date
Denis Kenzior 0238ffb8d9 netdev: Use -EOPNOTSUPP instead of -ENOTSUPP
The kernel uses -EOPNOTSUPP in the case of change_station operation not
being provided.  On most systems -EOPNOTSUPP is defined to be the same
as -ENOTSUPP, but seemingly not all systems.
2019-12-12 10:19:24 -06:00
Denis Kenzior 738184d491 device/netdev: init scan in netdev instead of device
Commit 1057d8aa74 changed the device interface creation logic
from being unconditional inside netdev.c to instead use NETDEV_WATCH_*
events.  However, this broke the assumption that the device interface
was created before all others.  The effect is that the scan_wdev_add
might no longer be called prior to station interface being created.  Fix
this by moving scan_wdev_add/remove calls to netdev.c instead.

Fixes: 1057d8aa74 ("device: Move device creation from netdev.c to event watch")
2019-12-06 10:12:55 -06:00
Andrew Zaborowski 59b963a121 netdev: Power P2P interfaces up like other interfaces
After all we will want to power these iftypes up on init just like
station, etc.
2019-11-20 20:29:34 -06:00
Andrew Zaborowski 81be5fbae5 rtnlutil: Move rtnl_set_powered from netdev to rtnlutil
This function fits with the other utilities in rtnlutil and netdev.c
can slim down.
2019-11-20 20:28:48 -06:00
Andrew Zaborowski 1057d8aa74 device: Move device creation from netdev.c to event watch
Create and destroy the device state struct and the DBus interfaces in a
way more similar to the Station, AdHoc and AP interfaces.  Drop
netdev_get_device() and the device specific code in netdev that as far
as I can tell wasn't needed.
2019-11-20 20:24:48 -06:00
Marcel Holtmann ab5742bb32 module: Move declarations into separate header file 2019-11-07 23:40:13 +01:00
Andrew Zaborowski 77e9df23c1 netdev: Drop unused netdev_connect_wsc 2019-10-30 14:36:23 -05:00
Andrew Zaborowski 6d3ae88a21 wsc: Replace netdev_connect_wsc with netdev_connect usage
netdev_connect can achieve the same effect as netdev_connect_wsc but is
more flexible as it allows us to supply additional association IEs.  We
will need this capability to make P2P connections.  This way we're also
moving the WSC-specific bits to wsc.c from the crowded netdev.c.
2019-10-30 14:35:10 -05:00
Andrew Zaborowski 0651c2c430 eapol: Drop unused eapol_sm_set_event_func 2019-10-30 14:34:20 -05:00
Andrew Zaborowski 0cccbea904 handshake: Convert handshake event callbacks variadic functions
Convert the handshake event callback type to use variable argument
list to allow for more flexibility in event-specific arguments
passed to the callbacks.

Note the uint16_t reason code is promoted to an int when using variable
arguments so va_arg(args, int) has to be used.
2019-10-30 14:24:05 -05:00
Denis Kenzior ccc114fa5f dbus: Use the new /net/connman/iwd root path 2019-10-28 11:32:57 -05:00
Denis Kenzior 27afe6c49f netdev: Use CamelCase for pae over nl80211 setting 2019-10-24 21:36:53 -05:00
Denis Kenzior 43d386bbe4 netdev: Use CamelCase for roam threshold setting 2019-10-24 21:36:53 -05:00
Marcel Holtmann 152b56a12a treewide: Move the Intel copyright forward to 2019 2019-10-25 00:43:08 +02:00
Andrew Zaborowski 1d29221ef0 netdev: Extend checks for P2P scenarios
Extend the iftype-based checks to handle the P2P iftypes and remove a
warning that may be triggered in normal situations in the P2P scenarios.
2019-10-21 22:35:31 -05:00
Denis Kenzior a043f26134 netdev: Skip IE processing of no request IEs sent 2019-10-17 17:30:11 -05:00
James Prestwood 369c5fbd0b eapol: utilize IWD_MODULE
This converts eapol to using IWD modules. The init/exit APIs did need
to remain exposed for unit tests.

Netdev was updated to depend on eapol.
2019-10-11 15:36:45 -05:00
Denis Kenzior cb57d44cb4 netdev: Fix resource leaks in netdev_init 2019-10-11 15:34:54 -05:00
James Prestwood d42c4a57b8 netdev: utilize IWD_MODULE
Since iwd_modules_init is now defered until nl80211_appeared, we can
assume the nl80211 object is available. This removes the need for
netdev_set_nl80211 completely.
2019-10-11 15:30:28 -05:00
James Prestwood 96998a83c5 netdev: handle QoS Map IE/Frame
The QoS Map can come in either as a management frame or via the
Associate Response. In either case this IE simply needs to be
forwarded back to the kernel.
2019-09-13 17:29:39 -05:00
James Prestwood 689fd7b92b netdev: make vendor_ies const on netdev_connect() 2019-09-09 09:55:12 -05:00
Antonio Quartulli 8106d82b4e fast_transition: fix crash by parsing RSN IE only if present
When performing a fast transition to another OPEN network the RSN
element won't be there and therefore the bss->rsne is gonna be NULL.

Fix crash by not accessing the rsne member when performing a fast
transition to an AP that doe snot advertise any RSN IE.

Crash caught with gdb:

 src/station.c:station_transition_start() 186, target 34:8f:27:2f:b8:fc

 Program received signal SIGSEGV, Segmentation fault.
 handshake_state_set_authenticator_ie (s=0x555555626eb0, ie=0x0) at src/handshake.c:163
 163		s->authenticator_ie = l_memdup(ie, ie[1] + 2u);
 (gdb) bt
 #0  handshake_state_set_authenticator_ie (s=0x555555626eb0, ie=0x0) at src/handshake.c:163
 #1  0x0000555555561a98 in fast_transition (netdev=0x55555562fbe0, target_bss=0x55555561f4a0,
     over_air=over_air@entry=true, cb=0x55555556d5b0 <station_fast_transition_cb>) at src/netdev.c:3164
 #2  0x0000555555565dfd in netdev_fast_transition (netdev=<optimized out>, target_bss=<optimized out>,
     cb=<optimized out>) at src/netdev.c:3232
 #3  0x000055555556ccbd in station_transition_start (bss=0x55555561f4a0, station=0x555555617da0)
     at src/station.c:1261
 #4  station_roam_scan_notify (err=<optimized out>, bss_list=<optimized out>, userdata=0x555555617da0)
     at src/station.c:1444
 #5  0x0000555555579560 in scan_finished (sc=0x55555562bf80, err=err@entry=0, bss_list=0x55555561bd90,
     sr=0x555555626b30, wiphy=<optimized out>) at src/scan.c:1234
 #6  0x0000555555579620 in get_scan_done (user=0x555555618920) at src/scan.c:1264
 #7  0x00005555555abd23 in destroy_request (data=0x55555561b000) at ell/genl.c:673
 #8  0x00005555555ac129 in process_unicast (nlmsg=0x7fffffffc310, genl=0x55555560b7a0) at ell/genl.c:940
 #9  received_data (io=<optimized out>, user_data=0x55555560b7a0) at ell/genl.c:1039
 #10 0x00005555555a8aa3 in io_callback (fd=<optimized out>, events=1, user_data=0x55555560b840)
     at ell/io.c:126
 #11 0x00005555555a7ccd in l_main_iterate (timeout=<optimized out>) at ell/main.c:473
 #12 0x00005555555a7d9c in l_main_run () at ell/main.c:520
 #13 l_main_run () at ell/main.c:502
 #14 0x00005555555a7fac in l_main_run_with_signal (callback=<optimized out>, user_data=0x0)
    at ell/main.c:642
 #15 0x000055555555e5b8 in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:519
2019-08-28 14:35:06 -05:00
Marcel Holtmann 2dc785982d netdev: Check EXT_FEATURE_CQM_RSSI_LIST before sending CMD_SET_CQM 2019-08-28 08:36:20 +02:00
Denis Kenzior 0ebe960daf netdev: Use the RM Enabled Capability IE from wiphy 2019-08-23 09:11:51 -05:00
Denis Kenzior 188e6d1237 netdev: Tweak debugging for SET_CQM 2019-08-04 04:49:24 -05:00
James Prestwood 3f794a1f20 iwd: netdev: deprecate ControlPortOverNL80211
control_port_over_nl80211 should now be used instead.
2019-07-30 14:41:49 -05:00
Denis Kenzior f557c7e6cd treewide: Use nl80211cmd_to_string
Using integer ids for event notifications received was hard to debug.
Use the nl80211cmd_to_string function to prettify these.
2019-07-15 14:06:26 -05:00
James Prestwood f57ba70235 netdev: Allow to send extra vendor IEs when connecting 2019-07-12 16:13:01 -05:00
Denis Kenzior de131b54b8 netdev: Use RRM & send RM Enabled Capabilities IE
If supported by the wiphy and if the target AP supports Radio Management
capability, then send the relevant IE and set the USE_RRM flag on
nl80211
2019-07-10 17:01:31 -05:00
Denis Kenzior fcb2d123bc netdev: Send extended capabilities IE on connect 2019-07-10 17:01:31 -05:00
Andrew Zaborowski 8cada9d1fc netdev: Add netdev_get_wdev_id 2019-07-08 11:19:32 -05:00
Denis Kenzior 8b375e1b28 netdev: Add logic to randomize address on creation 2019-07-02 15:47:05 -05:00
James Prestwood 99ce41b405 netdev: remove anqp_request functionality 2019-06-26 23:09:49 -05:00
James Prestwood be9e926c6a nl80211util: move CMD_FRAME builder into nl80211util
This will be needed outside of netdev
2019-06-26 22:52:56 -05:00
James Prestwood baf6b3ee4d netdev: optimize GAS request timeout
A not-yet-merged kernel patch will enable the FRAME_WAIT_CANCEL
event to be emitted when a CMD_FRAME duration expires. This can
shortcut the ridiculously long timeout that is required making
GAS requests with no response drastically quicker to handle.
2019-06-14 17:42:13 -05:00
James Prestwood 3a8b9a5d0c netdev: support basic ANQP requests
This adds a new API netdev_anqp_request which will send out a GAS
request, parses the GAS portion of the response and forwards the
ANQP response to the callers callback.
2019-06-14 17:40:39 -05:00
James Prestwood 2e0fed3d77 ie: add IE_RSN_AKM_SUITE_OSEN 2019-06-07 16:15:07 -05:00
James Prestwood 75e6ee98f3 handshake: simplify IE setters
The handshake object had 4 setters for authenticator/supplicant IE.
Since the IE ultimately gets put into the same buffer, there really
only needs to be a single setter for authenticator/supplicant. The
handshake object can deal with parsing to decide what kind of IE it
is (WPA or RSN).
2019-06-07 14:22:36 -05:00
James Prestwood 628c079e55 station: netdev: allow FILS-FT AKMs
This adds some checks for the FT_OVER_FILS AKMs in station and netdev
allowing the FILS-FT AKMs to be selected during a connection.

Inside netdev_connect_event we actually have to skip parsing the IEs
because FILS itself takes care of this (needs to handle them specially)
2019-05-23 15:27:29 -05:00
James Prestwood 1accf534dc ie: allow 24 byte FTE MIC
FT over FILS-SHA384 uses a 24 byte FT MIC rather than the 16 byte MIC
used for all other AKMs. This change allows both the FT builder/parser
to handle both lengths of MIC. The mic length is now passed directly
into ie_parse_fast_bss_transition and ie_build_fast_bss_transition
2019-05-23 15:23:08 -05:00
Denis Kenzior 8dced8b7f7 main: Update to the new genl api 2019-05-17 17:10:18 -05:00
Andrew Zaborowski 0b109c52b7 netdev: Add missing initialization
ifaddr is not guaranteed to be initialized, I'm not sure why there was
no compiler warning.  Also replace a | with a || for boolean conditions
and merge the wiphy check with that line.
2019-05-13 14:10:49 -05:00
Andrew Zaborowski b86af171f0 netdev: Don't warn on genl messages not matching a netdev
This is going to be a normal situation when we start using interfaces
without an ifindex.
2019-05-13 14:10:49 -05:00
Andrew Zaborowski 925095f835 netdev: Drop remaining whitelist/blacklist code 2019-05-13 14:10:49 -05:00
James Prestwood c0c8faf32f ft: netdev: station: support FT-over-DS
FT-over-DS is a way to do a Fast BSS Transition using action frames for
the authenticate step. This allows a station to start a fast transition
to a target AP while still being connected to the original AP. This,
in theory, can result in less carrier downtime.

The existing ft_sm_new was removed, and two new constructors were added;
one for over-air, and another for over-ds. The internals of ft.c mostly
remain the same. A flag to distinguish between air/ds was added along
with a new parser to parse the action frames rather than authenticate
frames. The IE parsing is identical.

Netdev now just initializes the auth-proto differently depending on if
its doing over-air or over-ds. A new TX authenticate function was added
and used for over-ds. This will send out the IEs from ft.c with an
FT Request action frame.

The FT Response action frame is then recieved from the AP and fed into
the auth-proto state machine. After this point ft-over-ds behaves the
same as ft-over-air (associate to the target AP).

Some simple code was added in station.c to determine if over-air or
over-ds should be used. FT-over-DS can be beneficial in cases where the
AP is directing us to roam, or if the RSSI falls below a threshold.
It should not be used if we have lost communication to the AP all
(beacon lost) as it only works while we can still talk to the original
AP.
2019-05-09 13:38:34 -05:00
James Prestwood a432ceeee4 netdev: modify netdev_send_action_frame for ft-over-ds
To support FT-over-DS this API needed some slight modifications:

- Instead of setting the DA to netdev->handshake->aa, it is just set to
  the same address as the 'to' parameter. The kernel actually requires
  and checks for these addresses to match. All occurences were passing
  the handshake->aa anyways so this change should have no adverse
  affects; and its actually required by ft-over-ds to pass in the
  previous BSSID, so hard coding handshake->aa will not work.

- The frequency is is also passed in now, as ft-over-ds needs to use
  the frequency of the currently connected AP (netdev->frequency get
  set to the new target in netdev_fast_transition. Previous frequency
  is also saved now).

- A new vector variant (netdev_send_action_framev) was added as well
  to support sending out the FT Request action frame since the FT
  TX authenticate function provides an iovec of the IEs. The existing
  function was already having to prepend the action frame header to
  the body, so its not any more or less copying to do the same thing
  with an iovec instead.
2019-05-09 13:32:45 -05:00
James Prestwood 03807e12e1 ft: netdev: move Authenticate IE building into ft.c
Since FT already handles processing the FT IE's (and building for
associate) it didn't make sense to have all the IE building inside
netdev_build_cmd_ft_authenticate. Instead this logic was moved into
ft.c, and an iovec is now passed from FT into
netdev_ft_tx_authenticate. This leaves the netdev command builder
unburdened by the details of FT, as well as prepares for FT-over-DS.
2019-05-09 12:22:01 -05:00
James Prestwood ce7df37132 netdev: remove in_ft checks and set_use_eapol_start
In both netdev_{authenticate,associate}_event there is no need to check
for in_ft at the start since netdev->ap will always be set if in_ft is
set.

There was also no need to set eapol_sm_set_use_eapol_start, as setting
require_handshake implies this and achieves the same result when starting
the SM.
2019-05-07 15:50:05 -05:00
James Prestwood 567f35c32f netdev: ft: refactor FT into an auth-proto
Since FT operates over Authenticate/Associate, it makes the most sense
for it to behave like the other auth-protos.

This change moves all the FT specific processing out of netdev and into
ft.c. The bulk of the changes were strait copy-pastes from netdev into
ft.c with minor API changes (e.g. remove struct netdev).

The 'in_ft' boolean unforunately is still required for a few reasons:

 - netdev_disconnect_event relies on this flag so it can ignore the
   disconnect which comes in when doing a fast transition. We cannot
   simply check netdev->ap because this would cause the other auth-protos
   to not handle a disconnect correctly.
 - netdev_associate_event needs to correctly setup the eapol_sm when
   in FT mode by setting require_handshake and use_eapol_start to false.
   This cannot be handled inside eapol by checking the AKM because an AP
   may only advertise a FT AKM, and the initial mobility association
   does require the 4-way handshake.
2019-05-07 14:19:26 -05:00
James Prestwood 87346212c9 ft: rename ftutil to ft (prep for auth-proto)
Now the 'ft' module, previously ftutil, will be used to drive FT via
the auth-proto virtual class. This renaming is in preparation as
ftutil will become obsolete since all the IE building/processing is
going to be moved out of netdev. The new ft.c module will utilize
the existing ftutil functionality, but since this is now a full blown
auth protocol naming it 'ft' is better suited.
2019-05-07 14:09:08 -05:00