supplicant: large rework of wpa_supplicant handling

System Internals / NetworkManager - Thomas Haller [redhat.com] - 12 March 2020 09:16 EDT

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.

b83f07916 supplicant: large rework of wpa_supplicant handling
src/devices/nm-device-ethernet.c | 238 +-
src/devices/nm-device-macsec.c | 294 ++-
src/devices/wifi/nm-device-iwd.c | 124 +-
src/devices/wifi/nm-device-wifi-p2p.c | 179 +-
src/devices/wifi/nm-device-wifi.c | 311 +--
src/devices/wifi/nm-wifi-ap.c | 295 +--
src/devices/wifi/nm-wifi-ap.h | 12 +-
src/devices/wifi/nm-wifi-p2p-peer.c | 108 +-
src/devices/wifi/nm-wifi-p2p-peer.h | 10 +-
src/supplicant/nm-supplicant-interface.c | 3937 +++++++++++++++++-------------
src/supplicant/nm-supplicant-interface.h | 49 +-
src/supplicant/nm-supplicant-manager.c | 1354 +++++++---
src/supplicant/nm-supplicant-manager.h | 36 +-
src/supplicant/nm-supplicant-types.h | 63 +
14 files changed, 4147 insertions(+), 2863 deletions(-)

Upstream: cgit.freedesktop.org


  • Share