mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-04 15:21:12 +00:00
device: make the MTU globally configurable via connection-defaults
This allows a user to restore the previous behavior where NetworkManager would not reconfigure the MTU during device activation, if no MTU is available (commit "22e8af6 device: set a per-device default MTU on activation"). Well, not exactly. The previous behavior was to use per-connection configuration, then DHCP provided value, or finally leave the MTU unspecified. Now, we prefer a per-connection configuration, followed by a global connection default. If "ethernet.mtu=0", the MTU is left unspecified. In absense of a global connection default, the value from DHCP is used or finally a per-device-type default. That is effectively 1500 for most types, except for infiniband where the MTU is still left unspecified.
This commit is contained in:
parent
215152d0a1
commit
be813707f0
|
@ -610,9 +610,21 @@ ipv6.ip6-privacy=0
|
|||
<varlistentry>
|
||||
<term><varname>ethernet.generate-mac-address-mask</varname></term>
|
||||
</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>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ethernet.wake-on-lan</varname></term>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>infiniband.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 the MTU is left unspecified on activation.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ip-tunnel.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>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dad-timeout</varname></term>
|
||||
</varlistentry>
|
||||
|
@ -650,6 +662,10 @@ ipv6.ip6-privacy=0
|
|||
This setting is deprecated for <literal>wifi.cloned-mac-address</literal>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>wifi.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>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>wifi.powersave</varname></term>
|
||||
<listitem><para>If left unspecified, the default value
|
||||
|
|
|
@ -122,6 +122,7 @@ static guint32
|
|||
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
||||
{
|
||||
NMSettingInfiniband *setting;
|
||||
gint64 mtu_default;
|
||||
guint32 mtu;
|
||||
|
||||
nm_assert (NM_IS_DEVICE (device));
|
||||
|
@ -132,6 +133,13 @@ get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
|||
g_return_val_if_reached (0);
|
||||
|
||||
mtu = nm_setting_infiniband_get_mtu (setting);
|
||||
if (mtu == 0) {
|
||||
mtu_default = nm_device_get_configured_mtu_from_connection_default (device, "infiniband.mtu");
|
||||
if (mtu_default >= 0) {
|
||||
*out_is_user_config = TRUE;
|
||||
return (guint32) mtu_default;
|
||||
}
|
||||
}
|
||||
*out_is_user_config = (mtu != 0);
|
||||
return mtu ?: NM_DEVICE_DEFAULT_MTU_INFINIBAND;
|
||||
}
|
||||
|
|
|
@ -748,6 +748,7 @@ static guint32
|
|||
get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
|
||||
{
|
||||
NMSettingIPTunnel *setting;
|
||||
gint64 mtu_default;
|
||||
guint32 mtu;
|
||||
|
||||
nm_assert (NM_IS_DEVICE (self));
|
||||
|
@ -758,6 +759,13 @@ get_configured_mtu (NMDevice *self, gboolean *out_is_user_config)
|
|||
g_return_val_if_reached (0);
|
||||
|
||||
mtu = nm_setting_ip_tunnel_get_mtu (setting);
|
||||
if (mtu == 0) {
|
||||
mtu_default = nm_device_get_configured_mtu_from_connection_default (self, "ip-tunnel.mtu");
|
||||
if (mtu_default >= 0) {
|
||||
*out_is_user_config = TRUE;
|
||||
return (guint32) mtu_default;
|
||||
}
|
||||
}
|
||||
*out_is_user_config = (mtu != 0);
|
||||
return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,9 @@ gboolean nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const
|
|||
#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);
|
||||
|
||||
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -6573,11 +6573,22 @@ linklocal6_start (NMDevice *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
gint64
|
||||
nm_device_get_configured_mtu_from_connection_default (NMDevice *self,
|
||||
const char *property_name)
|
||||
{
|
||||
gs_free char *str = NULL;
|
||||
|
||||
str = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA, property_name, self);
|
||||
return _nm_utils_ascii_str_to_int64 (str, 10, 0, G_MAXUINT32, -1);
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMSettingWired *setting;
|
||||
gint64 mtu_default;
|
||||
guint32 mtu;
|
||||
|
||||
nm_assert (NM_IS_DEVICE (self));
|
||||
|
@ -6596,6 +6607,13 @@ nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_co
|
|||
return mtu;
|
||||
}
|
||||
}
|
||||
|
||||
mtu_default = nm_device_get_configured_mtu_from_connection_default (self, "ethernet.mtu");
|
||||
if (mtu_default >= 0) {
|
||||
*out_is_user_config = TRUE;
|
||||
return (guint32) mtu_default;
|
||||
}
|
||||
|
||||
*out_is_user_config = FALSE;
|
||||
return NM_DEVICE_DEFAULT_MTU_WIRED;
|
||||
}
|
||||
|
@ -6637,7 +6655,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
|||
if (NM_DEVICE_GET_CLASS (self)->get_configured_mtu)
|
||||
mtu = NM_DEVICE_GET_CLASS (self)->get_configured_mtu (self, &mtu_is_user_config);
|
||||
|
||||
if (mtu && mtu_is_user_config)
|
||||
if (mtu_is_user_config)
|
||||
mtu_desired = mtu;
|
||||
else {
|
||||
if (config)
|
||||
|
|
|
@ -2745,6 +2745,7 @@ static guint32
|
|||
get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
||||
{
|
||||
NMSettingWireless *setting;
|
||||
gint64 mtu_default;
|
||||
guint32 mtu;
|
||||
|
||||
nm_assert (NM_IS_DEVICE (device));
|
||||
|
@ -2755,6 +2756,13 @@ get_configured_mtu (NMDevice *device, gboolean *out_is_user_config)
|
|||
g_return_val_if_reached (0);
|
||||
|
||||
mtu = nm_setting_wireless_get_mtu (setting);
|
||||
if (mtu == 0) {
|
||||
mtu_default = nm_device_get_configured_mtu_from_connection_default (device, "wifi.mtu");
|
||||
if (mtu_default >= 0) {
|
||||
*out_is_user_config = TRUE;
|
||||
return (guint32) mtu_default;
|
||||
}
|
||||
}
|
||||
*out_is_user_config = (mtu != 0);
|
||||
return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRELESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue