From 6455a4e52852a936ae34e6596a2d309a44fb8fcc Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 11 Sep 2019 10:57:07 +0200 Subject: [PATCH] device: expand comment on MTU selection --- src/devices/nm-device.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 09241d8ffb..440a94c238 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -9376,9 +9376,21 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config) { guint32 mtu = 0; - /* preferably, get the MTU from explicit user-configuration. - * Only if that fails, look at the current @config (which contains - * MTUs from DHCP/PPP) or maybe fallback to a device-specific MTU. */ + /* We take the MTU from various sources: (in order of increasing + * priority) parent link, IP configuration (which contains the + * MTU from DHCP/PPP), connection profile. + * + * We could just compare it with the platform MTU and apply it + * when different, but this would revert at random times manual + * changes done by the user with the MTU from the connection. + * + * Instead, we remember the source of the currently configured + * MTU and apply the new one only when the new source has a + * higher priority, so that we don't set a MTU from same source + * multiple times. An exception to this is for the PARENT + * source, since we need to keep tracking the parent MTU when it + * changes. + */ if (NM_DEVICE_GET_CLASS (self)->get_configured_mtu) mtu = NM_DEVICE_GET_CLASS (self)->get_configured_mtu (self, &source);