Skip to content

manager: use the right reason for managing devices after wake/reenable

Beniamino Galvani requested to merge bg/wake-assume-rh2193422 into main

When managing the interface after wake/reenable, the reason determines whether the device will be sys-iface-state=managed or external.

Commit 5a9a7623 ('core: set STATE_REASON_CONNECTION_ASSUMED when waking up') changed the reason from 'now-managed' to 'connection-assumed'; the effect was that devices that were fully managed before sleeping become external after a wake up. For example:

  $ nmcli connection add type ethernet ifname enp1s0
  Connection 'ethernet-enp1s0' (47fcd81e-bf00-4c02-b25b-354894f5657e) successfully added.
  $ nmcli device | grep enp1s0
  enp1s0  ethernet  connected               ethernet-enp1s0
  $ nmcli networking off
  $ nmcli device | grep enp1s0
  enp1s0  ethernet  unmanaged    --
  $ nmcli networking on
  $ nmcli device | grep enp1s0
  enp1s0  ethernet  unavailable  --

Introduce a hash table to store the previous state so that the correct reason can be set while managing the device.

Fixes: 5a9a7623 ('core: set STATE_REASON_CONNECTION_ASSUMED when waking up') https://bugzilla.redhat.com/show_bug.cgi?id=2193422

Merge request reports