3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-07 20:49:22 +01:00
Commit Graph

141 Commits

Author SHA1 Message Date
Andrew Zaborowski
5b7ec7689a ap: Add MACs to FILS IP Assignment responses
Try to include the gateway and DNS MAC addresses in the corresponding
fields in the FILS IP Address Assignment IEs we send to the clients.
2021-08-31 10:10:05 -05:00
Andrew Zaborowski
58d2814a92 ap: Support FILS IP Address Assignment IE
Handle the 802.11ai FILS IP Address Assignment IEs in Association
Request frames when netconfig is enabled.  Only IPv4 is supported.
Like the P2P IP Allocation mechanism, since the payload format and logic
is independent from the rest of the FILS standard this is enabled
unconditionally for clients who want to use it even though we don't
actually do FILS in AP mode.
2021-08-25 08:32:16 -05:00
Andrew Zaborowski
3045ef0770 ap: Expire client's leases on disconnect
If netconfig is enabled tell the DHCP server to expire any leases owned
by the client that is disconnecting by using l_dhcp_server_expire_by_mac
to return the IPs to the IP pool.  They're added to the expired list
so they'd only be used if there are no other addresses left in the pool
and can be reactivated if the client comes back before the address is
used by somebody else.

This should ensure that we're always able to offer an address to a new
client as long as there are fewer concurrent clients than addresses in
the configured subnet or IP range.
2021-08-25 08:02:38 -05:00
Andrew Zaborowski
bc046994db ap: Implement P2P GO-side 4-way handshake IP Allocation
Use the struct handshake_state::support_ip_allocation field already
supported in eapol.c authenticator side to enable the P2P IP Allocation
mechanism in ap.c.  Add the P2P_GROUP_CAP_IP_ALLOCATION bit in P2P group
capabilities to signal the feature is now supported.

There's no harm in enabling this feature in every AP (not just P2P Group
Owner) but the clients won't know whether we support it other than
through that P2P-specific group capability bit.
2021-08-25 08:02:13 -05:00
Andrew Zaborowski
2af0166970 ap: Make station removal safer
Replace instances of the ap_del_station() +
ap_sta_free()/ap_remove_sta() with calls to ap_station_disconnect to
make sure we consistently remove the station from the ap->sta_states
queue before using ap_del_station().  ap_del_station() may generate an
event to the ap.h API user (e.g. P2P) and this may end up tearing down
the AP completely.

For that scenario we also don't want ap_sta_free() to access sta->ap so
we make sure ap_del_station() performs these cleanup steps so that
ap_sta_free() has nothing to do that accesses sta->ap.
2021-08-13 10:49:28 -05:00
Andrew Zaborowski
97a34e6b4a ap: Fix an invalid access in ap_write_wsc_ie
client_frame is not valid for a beacon frame as beacons are not sent in
response to another frame.  Move the access to client_frame->address_2
to the conditional blocks for Probe Response and Association Response
frames.
2021-08-13 10:49:28 -05:00
Denis Kenzior
08845fb19c ie: Change ie_tlv_builder_finalize signature
ie_tlv_builder_init takes a size_t as input, yet for some reason
ie_tlv_builder_finalize takes an unsigned int argument as output.  Fix
the latter to use size_t as well.
2021-07-14 09:58:42 -05:00
Denis Kenzior
75a9199bc4 ap: Do not use inet_aton 2021-06-04 12:31:36 -05:00
Andrew Zaborowski
0e865a7028 ap: Forward DHCP events to AP event handler 2021-06-04 11:55:06 -05:00
Andrew Zaborowski
ec9260fa0c ap: Fix leaking of ap->wsc_pbc_timeout 2021-06-04 11:53:20 -05:00
Andrew Zaborowski
aa9a914975 ap: Warn about APRanges having been deprecated 2021-06-04 11:53:14 -05:00
Andrew Zaborowski
e9a33524a2 ap: Drop unneeded broadcast address calculation
It's already done in l_rtnl_address_new().
2021-06-04 11:53:04 -05:00
Andrew Zaborowski
7163a9d9d7 ap: Save AP address as l_rtnl_address
Change the char *addr_str and uint8_t prefix_len pair to an
l_rtnl_address object and use ell/rtnl.h utilities that use that
directly.  Extend broadcast_from_ip to handle prefix_len.
2021-06-01 10:15:43 -05:00
Andrew Zaborowski
a6002562ef ap: Send a specific error message on async AP start failure
We generate the DBus error reply type from the errno only when
ap_start() was failing synchronously, now also send the errno through
the callbacks so that we can also return a specific DBus reply when
failing asynchronously.  Thea AP autotest relies on receiving the
AlreadyExists DBus error.
2021-06-01 10:15:16 -05:00
Andrew Zaborowski
ff2840f95f ap: Refactor global address pool loading
Deprecate the global [General].APRanges setting in favour of
[IPv4].APAddressPool with an extended (but backwards-compatible) syntax.
Drop the existing address pool creation code.

The new APAddressPool setting has the same syntax as the profile-local
[IPv4].Address setting and the subnet selection code will fall back
to the global setting if it's missing, this way we use common code to
handle both settings.
2021-06-01 10:11:37 -05:00
Andrew Zaborowski
c5d1a5c31f ap: Refactor DHCP settings loading
Extend the [IPv4].Address setting's syntax to allow a new format: a list
of <IP>/<prefix_len> -form strings that define the address space from
which a subnet is selected.  Rewrite the DHCP settings loading with
other notable changes:

 * validate some of the settings more thoroughly,
 * name all netconfig-related ap_state members with the netconfig_
   prefix,
 * make sure we always call l_dhcp_server_set_netmask(),
 * allow netmasks other than 24-bit and change the default to 28 bits,
 * as requested avoid using the l_net_ ioctl-based functions although
   l_dhcp still uses them internally,
 * as requested avoid touching the ap_state members until the end of
   some functions so that on error they're basically a no-op (for
   readability).
2021-06-01 10:04:35 -05:00
Denis Kenzior
edf7294c06 ap: Do not leak ap->server
ap_reset() seems to be called whenever the AP is stopped or removed due
to interface shutdown.  For some reason ap_reset did not remove the DHCP
server object, resulting in leaks:

==211==    at 0x483879F: malloc (vg_replace_malloc.c:307)
==211==    by 0x46B5AD: l_malloc (util.c:62)
==211==    by 0x49B0E2: l_dhcp_server_new (dhcp-server.c:715)
==211==    by 0x433AA3: ap_setup_dhcp (ap.c:2615)
==211==    by 0x433AA3: ap_load_dhcp (ap.c:2645)
==211==    by 0x433AA3: ap_load_config (ap.c:2753)
==211==    by 0x433AA3: ap_start (ap.c:2885)
==211==    by 0x434A96: ap_dbus_start_profile (ap.c:3329)
==211==    by 0x482DA9: _dbus_object_tree_dispatch (dbus-service.c:1815)
==211==    by 0x47A4D9: message_read_handler (dbus.c:285)
==211==    by 0x4720EB: io_callback (io.c:120)
==211==    by 0x47130C: l_main_iterate (main.c:478)
==211==    by 0x4713DB: l_main_run (main.c:525)
==211==    by 0x4713DB: l_main_run (main.c:507)
==211==    by 0x4715EB: l_main_run_with_signal (main.c:647)
==211==    by 0x403EE1: main (main.c:550)
2021-05-24 14:31:04 -05:00
Andrew Zaborowski
02e46542e3 ap: Make rtnl global static 2021-05-14 09:49:08 -05:00
Andrew Zaborowski
c0a1760f46 ap: Move sending CMD_START_AP to common function 2021-05-10 10:14:29 -05:00
Denis Kenzior
29dd246f5e ap: Fix invalid length argument to ap_build_beacon_pr_head
Previously resp was a simple array of bytes allocated on the stack.
This was changed to a dynamically allocated array, but the sizeof(resp)
argument to ap_build_beacon_pr_head() was never changed appropriately.

Fix this by introducing a new resp_len variable that holds the number of
bytes allocated for resp.  Also, move the allocation after the basic
sanity checks have been performed to avoid allocating/freeing memory
unnecessarily.

Fixes: 18a63f91fd ("ap: Write extra frame IEs from the user")
2021-04-30 16:37:19 -05:00
Denis Kenzior
184b19c992 ap: Fix possible memleak of 'rates' 2021-04-30 11:38:04 -05:00
Denis Kenzior
d973c347be ap: Fix l_settings leak
l_settings is leaked if l_settings_load_from_file() fails.
2021-04-30 11:36:19 -05:00
James Prestwood
06aa84ccaf ap: set link/operstate on AP start/stop
Prior to this netdev_connect_ok set setting this which really
only applies to station mode. In addition this happens for each
new station that connects to the AP. Instead set the operstate /
link mode when AP starts and stops.
2021-04-28 11:29:51 -05:00
Andrew Zaborowski
694799c9c2 ap: Deduplicate writing authorized MACs into wsc_* structs 2021-04-28 11:26:42 -05:00
Andrew Zaborowski
ab6cd7e465 ap: Drop struct ap_config in favor of l_settings
Change ap_start to load all of the AP configuration from a struct
l_settings, moving the 6 or so parameters from struct ap_config members
to the l_settings groups and keys.  This extends the ap profile concept
used for the DHCP settings.  ap_start callers create the l_settings
object and fill the values in it or read the settings in from a file.

Since ap_setup_dhcp and ap_load_profile_and_dhcp no longer do the
settings file loading, they needed to be refactored and some issues were
fixed in their logic, e.g. l_dhcp_server_set_ip_address() was never
called when the "IP pool" was used.  Also the IP pool was previously only
used if the ap->config->profile was NULL and this didn't match what the
docs said:
"If [IPv4].Address is not provided and no IP address is set on the
interface prior to calling StartProfile the IP pool will be used."
2021-04-28 11:25:46 -05:00
James Prestwood
b276e3f590 ap: remove rates requirement for fmac cards
It was seen that some full mac cards/drivers do not include any
rate information with the NEW_STATION event. This was causing
the NEW_STATION event to be ignored, preventing AP mode from
working on these cards.

Since the full mac path does not even require sta->rates the
parsing can be removed completely.
2021-04-12 14:15:18 -05:00
Andrew Zaborowski
f868c2989c ap: Handle most WSC IEs using ap_write_extra_ies
Make the WSC IE processing and writing more self-contained (i.e. so that
it can be more easily moved to a separate file if desired) by using the
new ap_write_extra_ies() mechanism.
2021-03-11 21:47:05 -06:00
Andrew Zaborowski
18a63f91fd ap: Write extra frame IEs from the user
Add an API for the ap.h users to add extra IEs to outgoing management
frames: beacons, etc.
2021-03-11 21:46:49 -06:00
Denis Kenzior
f7b5bd4a79 treewide: Use ell's useful.h header 2021-03-11 21:46:09 -06:00
Andrew Zaborowski
c19fd0ee78 ap: Pass frame IEs from clients to the ap_state user
Pass the string IEs from the incoming STA association frames to
the user in the AP event data.  I drop
ap_event_station_added_data.rsn_ie because that probably wasn't
going to ever be useful and the RSN IE is included in the .assoc_ies
array in any case.
2021-03-10 16:42:03 -06:00
Andrew Zaborowski
71ba94121d ap: Make ap_update_beacon public
Let users call ap_update_beacon when a value has changed which should be
reflected in the beacon IEs.
2021-03-10 16:42:01 -06:00
Denis Kenzior
7de5b4adef treewide: replace util_mem_is_zero with l_memeqzero 2021-03-09 15:40:35 -06:00
Andrew Zaborowski
3621e998c9 ap: Add missing ap_config_free() in error path 2021-03-05 16:20:30 -06:00
Andrew Zaborowski
b689100c1c ap: Print error messages in dhcp_load_settings 2021-02-26 11:00:25 -06:00
Andrew Zaborowski
cdb2c2b3e3 ap: Fix an inet_aton error check
inet_aton returns 0 on error, not a negative number.
2021-02-26 10:59:35 -06:00
Andrew Zaborowski
fd934aa39e ap: Don't use L_AUTO_FREE_VAR with l_settings
L_AUTO_FREE_VAR only causes l_free to be called on the variable that is
freed and may leak the rest of the l_settings object's memory.
2021-02-26 10:59:22 -06:00
Andrew Zaborowski
e8ad4f10b0 ap: Drop an outdated TODO comment 2021-02-18 14:00:30 -06:00
Denis Kenzior
6ad50ac49b ap: Make sure strerror argument is positive 2021-02-08 15:05:54 -06:00
James Prestwood
f046bed225 ap: massage code to make static analysis happy
There is no functional change here but checking the return
value makes static analysis much happier. Checking the
return and setting the default inside the if clause is also
consistent with how IWD does it many other places.
2021-02-08 14:24:06 -06:00
James Prestwood
0ae3e1c59d ap: free passphrase on error 2021-02-08 14:23:54 -06:00
James Prestwood
676ee1e4d2 ap: tie diagnostic interface to AP Start/Stop
The diagnostic interface serves no purpose until the AP has
been started. Any calls on it will return an error so instead
it makes more sense to bring it up when the AP is started, and
down when the AP is stopped.
2021-02-02 15:54:56 -06:00
James Prestwood
ec15ef1d34 ap: add Name property
Its useful being able to refer to the network Name/SSID once
an AP is started. For example opening an iwctl session with an
already started AP provides no way of obtaining the SSID.
2021-02-02 15:53:25 -06:00
Andrew Zaborowski
074bc52717 eapol,ap: Remove assumption of single cipher in authenticator IE
Allow the user of the eapol_sm & handshake_state APIs to have multiple
pairwise ciphers listed in the authenticator IE.
2021-02-01 10:06:21 -06:00
Andrew Zaborowski
436c5a45e4 ap: Set the group cipher when sending START_AP
Seems this was overlooked because an initial version of ap.c didn't have
group traffic support.
2021-02-01 10:05:55 -06:00
Andrew Zaborowski
065f19b479 ap: Fix cleanup on ap_parse_new_station_ies errors 2021-01-29 20:06:18 -06:00
James Prestwood
9f33740d41 ap: fix off by one error
The RSN element was not being allocated properly which caused
an invalid read in some cases.
2021-01-29 15:04:10 -06:00
James Prestwood
aefcaf8559 ap: handle GET_KEY error setting RSC to zero
Rather than the previous hack which disabled group traffic it
was found that the GTK RSC could be manually set to zero which
allows group traffic. This appears to fix AP mode on brcmfmac
along with the previous fixes. This is not documented in
nl80211, but appears to work with this driver.
2021-01-29 13:15:36 -06:00
James Prestwood
4635e095ba ap: rename ap_parse_ie to be more descriptive
This is only used for NEW_STATION parsing so name appropriately
2021-01-29 13:15:24 -06:00
James Prestwood
32028f6daf ap: add DEL_STATION path to fullmac AP handling
This is how a fullmac card tells userspace that a station has
left. This fixes the issue where the same client cannot re-connect
to the same AP multiple times. ap_new_station was renamed to
ap_handle_new_station for consistency.
2021-01-29 11:36:09 -06:00
James Prestwood
7429b2162d ap: allow no group traffic on GET_KEY error
Some fullmac cards were found to be buggy with getting the GTK
where it returns a BIP key for the GTK index, even after creating
a GTK with NEW_KEY explicitly. In an effort to get these cards
semi-working we can treat this just as a warning and continue with
the handshake without a GTK set which disables group traffic. A
warning is printed in this case so the user is not completely in
the dark.
2021-01-28 13:41:43 -06:00