device: also configure MTU while assuming devices

The sys-iface-state "assume" means to gracefully take over a device (for
example, after a restart). The end result is a fully managed interface.
The flag only has meaning while activating, and for most practical
purposes, such devices should be treated the same as fully activated
ones.

Without this, the MTU is not reset until the device reaches fully
activated state, at which point the sys-iface-state switches from
"assume" to "managed". With the previous commit, at that point we also
schedule an idle commit, which ends up also setting the MTU. Before
that, the MTU was only reset some undefined time later, when we happened
to do another NML3Cfg commit. Nonetheless, even waiting until we reach
fully activated state is wrong. Also during activation, commit the MTU.

I guess, what theoretically could happen is that we get our MTU via
ip-config (like DHCP). Then, during assuming we hit _commit_mtu()
without having the DHCP lease yet. This happens after a restart, so it
would be wrong to first reset the MTU, before we re-receive the DHCP
lease. However, if the MTU is really to be set due via
NM_DEVICE_MTU_SOURCE_IP_CONFIG, then all other MTU sources are also not
in effect (because ip-config has a low priority). In that case, we would
not have an MTU to reset and the code would not commit a new MTU. Thus
this should still be fine, also during activation when we didn't yet get
the DHCP lease (or other information to dynamically set the MTU).
This commit is contained in:
Thomas Haller 2023-03-21 09:08:20 +01:00
parent e773559d9d
commit 15101447c3
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -11327,10 +11327,8 @@ _commit_mtu(NMDevice *self)
if (ifindex <= 0)
return;
if (!nm_device_get_applied_connection(self)
|| nm_device_sys_iface_state_is_external_or_assume(self)) {
/* we don't tamper with the MTU of disconnected and
* external/assumed devices. */
if (!nm_device_get_applied_connection(self) || nm_device_sys_iface_state_is_external(self)) {
/* we don't tamper with the MTU of disconnected and external devices. */
return;
}