summaryrefslogtreecommitdiff
path: root/src/supplicant/nm-supplicant-interface.c
AgeCommit message (Collapse)AuthorFilesLines
2021-02-04all: move "src/" directory to "src/core/"Thomas Haller1-3522/+0
Currently "src/" mostly contains the source code of the daemon. I say mostly, because that is not true, there are also the device, settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp helper, and probably more. Also we have source code under libnm-core/, libnm/, clients/, and shared/ directories. That is all confusing. We should have one "src" directory, that contains subdirectories. Those subdirectories should contain individual parts (libraries or applications), that possibly have dependencies on other subdirectories. There should be a flat hierarchy of directories under src/, which contains individual modules. As the name "src/" is already taken, that prevents any sensible restructuring of the code. As a first step, move "src/" to "src/core/". This gives space to reorganize the code better by moving individual components into "src/". For inspiration, look at systemd's "src/" directory. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-01-18wifi: fix caching ap-flags for supplicant-interfaceThomas Haller1-1/+1
Fixes: b83f07916a54 ('supplicant: large rework of wpa_supplicant handling') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/631
2021-01-05all: update deprecated SPDX license identifiersThomas Haller1-1/+1
These SPDX license identifiers are deprecated ([1]). Update them. [1] https://spdx.org/licenses/ sed \ -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \ -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \ -i \ $(git grep -l SPDX-License-Identifier -- \ ':(exclude)shared/c-*/' \ ':(exclude)shared/n-*/' \ ':(exclude)shared/systemd/src' \ ':(exclude)src/systemd/src')
2020-12-22wifi: merge branch 'ac/wpa3eap_suiteb192'Antonio Cardace1-0/+2
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/709
2020-12-22wifi: add WPA-EAP-SUITE-B-192 supportAntonio Cardace1-0/+2
Add a new key management option to support WPA3 Enteprise wifi connection. Only supported with wpa_supplicant for the time being. Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-12-22all: explicit include <linux/if_{ether,infiniband,vlan}.h> as neededThomas Haller1-0/+1
Currently libnm headers include <linux/if_{ether,infiniband,vlan}.h>. These are public headers, that means we drag in the linux header to all users of <NetworkManager.h>. Often the linux headers work badly together with certain headers from libc. Depending on the libc version, you have to order linux headers in the right order with respect to libc headers. We should do better about libnm headers. As a first step, assume that the linux headers don't get included by libnm, and explicitly include them where they are needed.
2020-12-10wifi: fix evaluating the scanning state for wpa-supplicantThomas Haller1-3/+1
wpa_supplicant has a property "scanning" and a "state=scanning". Previously, NetworkManager considered both parts to indicate whether supplicant is currently scanning (if either the property or the state indicated scanning, it took that as indication for scanning). If NetworkManager thinks that supplicant is scanning, it suppresses explicit "Scan" requests. That alone is not severe, because the "Scan" request is only to trigger a scan in supplicant (which supplicant possibly is already doing in state "scanning"). However, what is severe is that NetworkManager will also block autoconnect while supplicant is scanning. That is because NetworkManager wants to get a complete scan result before deciding which network to connect to. It seems that wpa_supplicant can get into "state=scanning" and stay there indefinitely. This prevents NetworkManager from autoactivating a profile. Fix that, to only honor the "scanning" property. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/597 Fixes: b83f07916a54 ('supplicant: large rework of wpa_supplicant handling')
2020-11-19wifi: use NMEtherAddr struct for bssidThomas Haller1-6/+4
2020-10-13wifi: set the BridgeIfname supplicant property when neededBeniamino Galvani1-0/+48
When a wifi device is in a bridge, the supplicant must be aware of it, as a socket must be opened on the bridge to receive packets. Set the BridgeIfname property of the supplicant Interface object before starting the association. Note that the property was read-only in the past and recently [1] became read-write. When using a supplicant version without the patch, writing the property will return an InvalidArgs error and NetworkManager will print a warning. [1] https://w1.fi/cgit/hostap/commit/?id=1c58317f56e312576b6872440f125f794e45f991 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/83
2020-10-12wifi: re-add code for tracking a peers groupsBenjamin Berg1-0/+9
The code to track the property was accidentally removed in commit 21d4a2618868 ('core: remove code for unused NM_WIFI_P2P_PEER_GROUPS property') causing all P2P connections to fail after 5 seconds. Fixes: 21d4a2618868 ('core: remove code for unused NM_WIFI_P2P_PEER_GROUPS property') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/551 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/650
2020-10-12device/wifi: fix leak of NMSupplicantPeerInfo.peer_path in NMSupplicantInterfaceThomas Haller1-0/+2
Fixes: b83f07916a54 ('supplicant: large rework of wpa_supplicant handling')
2020-10-01shared: add ether_addr field of type NMEtherAddr to NMIPAddr unionThomas Haller1-2/+2
2020-09-29all: unify comment style for SPDX-License-Identifier tagThomas Haller1-1/+1
Our coding style recommends C style comments (/* */) instead of C++ (//). Also, systemd (which we partly fork) uses C style comments for the SPDX-License-Identifier. Unify the style. $ sed -i '1 s#// SPDX-License-Identifier: \([^ ]\+\)$#/* SPDX-License-Identifier: \1 */#' -- $(git ls-files -- '*.[hc]' '*.[hc]pp')
2020-09-28format: replace tabs for indentation in code commentsThomas Haller1-48/+48
sed -i \ -e 's/^'$'\t'' \*/ */g' \ -e 's/^'$'\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t\t\t\t'' \*/ */g' \ $(git ls-files -- '*.[hc]')
2020-09-28all: reformat all with new clang-format styleAntonio Cardace1-2726/+2680
Run: ./contrib/scripts/nm-code-format.sh -i ./contrib/scripts/nm-code-format.sh -i Yes, it needs to run twice because the first run doesn't yet produce the final result. Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-07-07all: fix minor typosYuri Chornoivan1-1/+1
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/565
2020-07-03all: fix typo in man pagesSayed Shah1-1/+1
There should be a comma after 'Otherwise' and 'Currently'. https://bugzilla.redhat.com/show_bug.cgi?id=1852452 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/560
2020-07-01supplicant,device: support AP isolationBeniamino Galvani1-15/+104
Support setting the ApIsolate property of the supplicant interface during association and resetting it to zero during disconnection.
2020-06-18supplicant: fix memory leakBeniamino Galvani1-0/+1
Fixes: b83f07916a54 ('supplicant: large rework of wpa_supplicant handling')
2020-06-09nm-supplicant-interface: parse 802.11 IEs after securityDavid Bauer1-12/+14
Psrse the 802.11 IEs after parsing the security information. Previously the OWE transition mode flag was potentially removed in case the security properties changed. Signed-off-by: David Bauer <mail@david-bauer.net>
2020-06-09nm-supplicant-interface: fix removal of OWE flag from non-transition mode BSSIDsDavid Bauer1-2/+2
Commit 37e7fa38c2ed ("nm-supplicant-interface: enable OWE security when transition mode is available") adds the OWE security flag in case a valid OWE transtition mode IE is present on the beacon. It also removes the OWE security flag in case the Iinformation elements of a beacon are updated and a OWE transition mode IE can't be found. When a pure OWE AP updates it's Information Elements (e.g. BSS Load Element), the OWE security flag is falsely removed. Introduce a new NM_802_11_AP_SEC_KEY_MGMT_OWE_TM security flag and use it exclusively for OWE transition mode. Don't use the M_802_11_AP_SEC_KEY_MGMT_OWE security flag on transition-mode APs. Signed-off-by: David Bauer <mail@david-bauer.net>
2020-04-29wifi: don't limit active scans for SSIDs to 5Thomas Haller1-22/+40
As far as NMSupplicantInterface is concerned, don't clamp the max-scan-ssids to 5. We should track the real value that wpa_supplicant announces, and it's up to the caller to provide fewer SSIDs. In particular, we want to limit the number of hidden SSIDs that we accept from connection profiles, but we don't want to limit the number of active scans via `nmcli device wifi rescan ssid $SSID [...]`. (cherry picked from commit c9ae23af5e1fdf85e3fc34b29440b4de1d67a2ab)
2020-04-29supplicant: log changes to max-scan-ssids of NMSupplicantInterfaceThomas Haller1-3/+8
(cherry picked from commit a7476ff082c6f1c13c46447b61360093f4aa82d1)
2020-04-24wifi: add callback to nm_supplicant_interface_request_scan()Thomas Haller1-15/+77
While we request a scan, we are not yet actually scanning. That means, the supplicant's "scanning" property will only change to TRUE a while after we initiate the scan. It may even never happen. We thus need to handle that the request is currently pending and react when the request completes. (cherry picked from commit 16c1869476106859b684151eb1b101c24cff3451)
2020-04-24wifi: add more trace logging to supplicant interfaceThomas Haller1-4/+13
(cherry picked from commit 8ecc325f29f5cba83daf6fca0003c7e13bafba31)
2020-04-20wifi: change return type of p2p-connect D-Bus method callBeniamino Galvani1-1/+1
Fix the following error when invoking the Connect() p2p method: call-p2p-connect: failed with Method “fi.w1.wpa_supplicant1.Interface.P2PDevice.Connect” returned type “(s)”, but expected “()” Fixes: b83f07916a54 ('supplicant: large rework of wpa_supplicant handling') (cherry picked from commit a5338affb5e64c48fcdb90f1b7bbf9a93cae4342)
2020-04-03wifi/trivial: rename function nm_supplicant_interface_state_is_operational() ↵Thomas Haller1-3/+3
from upper case name
2020-04-03wifi: fix and improve handling of Wi-Fi scanning stateThomas Haller1-39/+31
In NMSupplicantInterface, we determine whether we currently are scanning both on the "scanning" supplicant state and the "Scanning" property. Extend that. If we currently are scanning and are about to clear the scanning state, then pretend to still scan as long as we are still initializing BSS instances. What otherwise happens is that we declare that we finished scanning, but the NMWifiAP instances are not yet ready. The result is, that `nmcli device wifi` will already start printing the scan list, when we didn't yet fully process all access points. Now, _notify_maybe_scanning() will delay switching the scanning state to disabled, as long as we have BSS initializing (bss_initializing_lst_head). Also, ignore the "ScanDone" signal. It's redundant to the "Scanning" property anyway. Also, only set priv->last_scan_msec when we switch the scanning state off. That is the right (and only) place where the last-scan timestamp needs updating.
2020-04-03supplicant: cleanup notify signals for combined properties in supplicant (2)Thomas Haller1-42/+37
2020-04-03supplicant: cleanup notify signals for combined properties in supplicantThomas Haller1-30/+43
Certain properties (for example "scanning") are combined from multiple other properties. So, we want to notify a changed signal, exactly when something relevant changes. We also may not want to emit a signal while we are still in the middle of changing multiple properties together. Only at certain places we want to check and emit the signal. Simplify the implementation for that by tracking the property value that we currently expose, and keeping state about when it changes.
2020-04-03supplicant: log message whenever we request scanningThomas Haller1-4/+6
It's important to clearly see in the log when we actually request a scan.
2020-03-23all: use nm_clear_pointer() instead of g_clear_pointer()Thomas Haller1-2/+2
g_clear_pointer() would always cast the destroy notify function pointer to GDestroyNotify. That means, it lost some type safety, like GPtrArray *ptr_arr = ... g_clear_pointer (&ptr_arr, g_array_unref); Since glib 2.58 ([1]), g_clear_pointer() is also more type safe. But this is not used by NetworkManager, because we don't set GLIB_VERSION_MIN_REQUIRED to 2.58. [1] https://gitlab.gnome.org/GNOME/glib/-/commit/f9a9902aac826ab4aecc25f6eb533a418a4fa559 We have nm_clear_pointer() to avoid this issue for a long time (pre 1.12.0). Possibly we should redefine in our source tree g_clear_pointer() as nm_clear_pointer(). However, I don't like to patch glib functions with our own variant. Arguably, we do patch g_clear_error() in such a manner. But there the point is to make the function inlinable. Also, nm_clear_pointer() returns a boolean that indicates whether anything was cleared. That is sometimes useful. I think we should just consistently use nm_clear_pointer() instead, which does always the preferable thing. Replace: sed 's/\<g_clear_pointer *(\([^;]*\), *\([a-z_A-Z0-9]\+\) *)/nm_clear_pointer (\1, \2)/g' $(git grep -l g_clear_pointer) -i
2020-03-22core/wifi: minor cleanup in _bss_info_properties_changed()Thomas Haller1-5/+2
Move local variables to inner scope. Also, drop code comment that doesn't give additional information beyond what is already plainly visible in source code.
2020-03-22nm-supplicant-interface: enable OWE security when transition mode is availableDavid Bauer1-1/+9
This pull requests sets the OWE flag for an open network advertising an OWE enabled transition BSSID. This way, hostapd will automatically connect to the OWE secured BSSID advertised in the transition mode information element. Signed-off-by: David Bauer <mail@david-bauer.net> https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/442
2020-03-20supplicant: fix crash setting supplicant state downThomas Haller1-0/+1
When we receive a "InterfaceRemoved" signal, we will end up calling set_state_down(). That emits a "state" change signal, which causes NMDeviceWifi to unref the supplicant interface. This may already give up the last reference, and we cleanup the supplicant state (by again calling set_state_down()). When we return, set_state_down() will crash because it operates on an already destroyed instance. Avoid that by keeping a reference to the interface during set_state_down(). Fixes: b83f07916a54 ('supplicant: large rework of wpa_supplicant handling') https://bugzilla.redhat.com/show_bug.cgi?id=1815058
2020-03-12supplicant: large rework of wpa_supplicant handlingThomas Haller1-1655/+2126
Avoid GDBusProxy, instead use GDBusConnection directly. I very much prefer this because that way we have explicit control over what happens on D-Bus. With GDBusProxy this is hidden under another layer of complex code. The hardest part when using a D-Bus interface is to manage the state via an asynchronous medium. GDBusProxy contains state about the D-Bus interface and duplicate the state that we track. This makes it hard to reason about things. Rework creation of NMSupplicantInterface. Previously, a NMSupplicantInterface had multiple initialization states. In particular, the first state would not yet tie the interface to a certain D-Bus object path. Instead, NMSupplicantInterface would try and retry to create the D-Bus object. Now, NMSupplicantManager has an asynchronous method to create interface instances. The manager only creates an interface instance after the D-Bus path is known. That means, a NMSupplicantInterface instance is now strongly tied to a name-owner and D-Bus path. It follows that the state of NMSupplicantInterface can only go from STARTING, via the supplicant states, to DOWN. Never back. That was already previously the case that the state from DOWN was final and once the 3 initial states were passed, the interface's state would never go back to the initial state. Now this is more strict and more formalized. The 3 initialization states are combined. I think the tighter state handling simplifies users of NMSupplicantInterface. See for example "nm-device-ethernet.c". It's still complicated, because handling state is fundamentally difficult. NMSupplicantManager will take care to D-Bus activate wpa_supplicant only when necessary (poke). Previously, creating the manager instance would always start suppliant service. Now, it's started on demand.
2020-02-26supplicant: allocate blobs hash table lazily for supplicant configThomas Haller1-16/+19
It's very unlikely that we have actual blobs for a Wi-Fi network. That is because the settings plugins (keyfile, ifcfg-rh) convert blobs to files on disk when writing the profile. So, you can only have them by editing the files directly to contain blobs. At that point, don't always create the GHashTable for blobs.
2020-02-14all: drop explicit casts from _GET_PRIVATE() macro callsThomas Haller1-2/+2
The _GET_PRIVATE() macros are all implemented based on _NM_GET_PRIVATE(). That macro tries to be more type safe and uses _Generic() to do the right thing. Explicitly casting is not only unnecessary, it defeats these (static) type checks. Don't do that.
2020-02-14supplicant: expose nm_supplicant_driver_to_string() helper functionThomas Haller1-13/+3
Will be useful later.
2020-02-13shared: drop _STATIC variant of macros that define functionsThomas Haller1-1/+2
Several macros are used to define function. They had a "_STATIC" variant, to define the function as static. I think those macros should not try to abstract entirely what they do. They should not accept the function scope as argument (or have two variants per scope). This also because it might make sense to add additional __attribute__(()) to the function. That only works, if the macro does not pretend to *not* define a plain function. Instead, embrace what the function does and let the users place the function scope as they see fit. This also follows what is already done with static NM_CACHED_QUARK_FCN ("autoconnect-root", autoconnect_root_quark)
2020-02-13shared: add entry_cmd argument to NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*() macroThomas Haller1-0/+1
This extra argument allows to tweak whether to assert for the input argument name.
2020-02-10supplicant: move defines for supplicant D-Bus API to headerThomas Haller1-17/+1
2020-02-10supplicant: use nm_utils_error_is_cancelled() instead of g_error_matches()Thomas Haller1-26/+19
2020-02-10supplicant: drop unused detection for credreqThomas Haller1-48/+2
2020-02-10supplicant: drop unused NM_SUPPLICANT_INTERFACE_CREDENTIALS_REQUEST signalThomas Haller1-25/+0
2020-02-10supplicant: remove unused nm_supplicant_interface_credentials_reply()Thomas Haller1-34/+0
Also, it is a synchronous D-Bus call. Get rid of the unused function.
2020-02-10supplicant: define wpas_state_string_to_enum() via ↵Thomas Haller1-27/+16
NM_UTILS_STRING_TABLE_LOOKUP_DEFINE() We frequently have code that converts a string to number/enum. Use a preferred implementation via the NM_UTILS_STRING_TABLE_LOOKUP_DEFINE() macro. Also, this does binary search, so in most cases it's (slightly) faster.
2020-02-10supplicant: track supplicant interface instances in manager via embedded CListThomas Haller1-9/+14
2020-02-10supplicant/trivial: give WPAS defines an NM prefixThomas Haller1-31/+31
Defines in our header files should all have an NM specific prefix. Rename. Also rename the related defines in the source file. Usually declarations in a source file should not have an NM prefix. But here they have for consistency.
2020-02-10supplicant: rework handling of capabilities (features) to use capabilities ↵Thomas Haller1-289/+106
enumeration We keep adding capabilities. Tracking them individually via boolean (or ternary) properties is cumbersome. Instead, use an enum NMSupplCapType and a corresponding bitmask NMSupplCapMask. The latter can track whether a capability is detected, detected to be absent or not detected (unknown).