From 4ca3002b86948847711cd5b1937008baef3c30da Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 13 Jun 2017 12:26:51 +0200 Subject: [PATCH] device: don't set MTU of device unless explicitly configured Since commit 2b51d3967 "device: merge branch 'th/device-mtu-bgo777251'", we always set the MTU for certain device types during activation. Even if the MTU is neither specified via the connection nor other means, like DHCP. Revert that change. On activation, if nothing explicitly configures the MTU, leave it unchanged. This is like what we do with ethernet's cloned-mac-address, which has a default value "preserve". So, as last resort the default value for MTU is now 0 (don't change), instead of depending on the device type. Note that you also can override the default value in global configuration via NetworkManager.conf. This behavior makes sense, because whenever NM actively resets the MTU, it remembers the previous value and restores it when deactivating the connection. That wasn't implemented before 2b51d3967, and the MTU would depend on which connection was previously active. That is no longer an issue as the MTU gets reset when deactivating. https://bugzilla.redhat.com/show_bug.cgi?id=1460760 --- man/NetworkManager.conf.xml | 2 +- src/devices/nm-device-infiniband.c | 2 +- src/devices/nm-device-ip-tunnel.c | 2 +- src/devices/nm-device-private.h | 4 ---- src/devices/nm-device-vlan.c | 2 +- src/devices/nm-device.c | 2 +- src/devices/wifi/nm-device-wifi.c | 2 +- 7 files changed, 6 insertions(+), 10 deletions(-) diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml index 944c4ab603..0dc1b700d9 100644 --- a/man/NetworkManager.conf.xml +++ b/man/NetworkManager.conf.xml @@ -655,7 +655,7 @@ ipv6.ip6-privacy=0 ethernet.mtu - If configured explicitly to 0, the MTU is not reconfigured during device activation unless it is required due to IPv6 constraints. If left unspecified, a DHCP/IPv6 SLAAC provided value is used or a default of 1500. + If configured explicitly to 0, the MTU is not reconfigured during device activation unless it is required due to IPv6 constraints. If left unspecified, a DHCP/IPv6 SLAAC provided value is used or the MTU is not reconfigured during activation. ethernet.wake-on-lan diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index f7875d0992..7e04127035 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -139,7 +139,7 @@ get_configured_mtu (NMDevice *device, gboolean *out_is_user_config) } } *out_is_user_config = (mtu != 0); - return mtu ?: NM_DEVICE_DEFAULT_MTU_INFINIBAND; + return mtu; } static gboolean diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 53b7cf4e5f..2f505ef4cf 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -767,7 +767,7 @@ get_configured_mtu (NMDevice *self, gboolean *out_is_user_config) } } *out_is_user_config = (mtu != 0); - return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED; + return mtu; } static NMDeviceCapabilities diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h index 1081580c48..05cb3f7d84 100644 --- a/src/devices/nm-device-private.h +++ b/src/devices/nm-device-private.h @@ -112,10 +112,6 @@ gboolean nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const /*****************************************************************************/ -#define NM_DEVICE_DEFAULT_MTU_WIRED ((guint32) 1500) -#define NM_DEVICE_DEFAULT_MTU_WIRELESS ((guint32) 1500) -#define NM_DEVICE_DEFAULT_MTU_INFINIBAND ((guint32) 0) - gint64 nm_device_get_configured_mtu_from_connection_default (NMDevice *self, const char *property_name); diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 06db644656..a74da8f229 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -586,7 +586,7 @@ get_configured_mtu (NMDevice *self, gboolean *out_is_user_config) if (ifindex > 0) mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)), ifindex); - return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED; + return mtu; } /*****************************************************************************/ diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 25b1184740..d7635dcfac 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7094,7 +7094,7 @@ nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_co } *out_is_user_config = FALSE; - return NM_DEVICE_DEFAULT_MTU_WIRED; + return 0; } /*****************************************************************************/ diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 633bcd6aae..9638a40c26 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -2937,7 +2937,7 @@ get_configured_mtu (NMDevice *device, gboolean *out_is_user_config) } } *out_is_user_config = (mtu != 0); - return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRELESS; + return mtu; } static gboolean