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
This commit is contained in:
Thomas Haller 2017-06-13 12:26:51 +02:00
parent d2b4332b36
commit 4ca3002b86
7 changed files with 6 additions and 10 deletions

View file

@ -655,7 +655,7 @@ ipv6.ip6-privacy=0
</varlistentry>
<varlistentry>
<term><varname>ethernet.mtu</varname></term>
<listitem><para>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.</para></listitem>
<listitem><para>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.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ethernet.wake-on-lan</varname></term>

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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;
}
/*****************************************************************************/

View file

@ -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;
}
/*****************************************************************************/

View file

@ -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