Bug 2117352

Summary: Improve reapply to reset the device according to the profile
Product: Red Hat Enterprise Linux 9 Reporter: Thomas Haller <thaller>
Component: NetworkManagerAssignee: Wen Liang <wenliang>
Status: CLOSED ERRATA QA Contact: Matej Berezny <mberezny>
Severity: unspecified Docs Contact: Mayur Patil <maypatil>
Priority: medium    
Version: 9.1CC: bgalvani, djasa, fge, lrintel, rkhan, sfaye, sukulkar, till, vbenes, wenliang
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: NetworkManager-1.41.8-1.el9 Doc Type: Bug Fix
Doc Text:
.NetworkManager now preserves IP addresses during reapply before acquiring a new DHCP lease Previously, after changing the connection settings and then using `nmcli device reapply` command, NetworkManager did not preserve the DHCP lease. Consequently, the IP address got removed temporarily. With this fix, NetworkManager preserves the DHCP lease and uses it until the lease expires or the client requests a new one. As a result, when the `nmcli device reapply` command restarts DHCP client, it does not temporarily remove the IP address.
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:17:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Thomas Haller 2022-08-10 17:51:12 UTC
Background:

When we activate a profile in NetworkManager, we create an internal copy of what was activated.

When later the profile gets modified (via `nmcli connection modify`), the changes don't take effect immediately (*). Changes to a profile only take effect after reactivating the profile.

(*) except "connection.zone" and "connection.metered", which take effect immediately, unless the modification happens with `NM_SETTINGS_UPDATE2_FLAG_NO_REAPPLY` flag.

Btw, you can get the content of the copy, wia the `GetAppliedConnection()` D-Bus call.


Now, there is the `Reapply()` D-Bus call,which takes a new profile and applies the changes right away, without requiring a full activation.

That is used by `nmcli device reapply` and `nmcli device modify` commands.


Reapply tries to do two conflicting things.

- apply all the changes as requested
- do not disrupt the connectivity. That means for example, avoid restarting DHCP and if we restart it, then do in a way that does not temporarily loose all IP addresses.

---

There are problem with this.

1) If there are no changes to the profile, then often reapply does not actually do anything.

  nmcli device reapply eth0
  ip link set eth0 mtu 2000
  nmcli device reapply eth0

one might expect that the second reapply call fixes the MTU. However, it might not. Here we should lean more towards: make sure that the settings are really as requested, and take all necessary measures to make sure that's the case.


2) when we reapply the IP configuration and need to restart DHCP, then the IP address goes away. I think reapply should always restart DHCP, even if presumably no configuration changed. This is problem 1) above. The problem 2) is that while we restart DHCP, that the IP address gets removed temporarily. We should instead leave the IP address there, until we get a new lease. NMDhcpClient should abstract this. Similar things for RA, link-local, etc.

Comment 11 errata-xmlrpc 2023-05-09 08:17:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (NetworkManager bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2485