diff options
author | Thomas Haller <thaller@redhat.com> | 2017-10-23 15:41:07 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-10-23 18:00:23 +0200 |
commit | de16305472db90fc95980fbf17863fe8b6e45ecb (patch) | |
tree | e2011057e1ede5588d0559944c75e590db7eda02 | |
parent | 81a1207bcd4ae9ca07b2be4aa3317f602d99a44d (diff) | |
download | NetworkManager-de16305472db90fc95980fbf17863fe8b6e45ecb.tar.gz |
device: show better logging message when setting MTU failsth/device-mtu-rh1414901
Setting the MTU might fail when the underlying device's MTU
is not set.
Detect that case, and log a better warning message.
Unfortunately, it's tricky to detect whether this is a complete
failure, or whether we will later try again to change the MTU.
So, we log a failure, altough later we might fix it. It would
be better not to warn about non-errors.
-rw-r--r-- | src/devices/nm-device.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 18789ba88c..3060c60959 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -72,6 +72,7 @@ #include "nm-arping-manager.h" #include "nm-connectivity.h" #include "nm-dbus-interface.h" +#include "nm-device-vlan.h" #include "nm-device-logging.h" _LOG_DECLARE_SELF (NMDevice); @@ -7346,6 +7347,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config) }) if ( (mtu_desired && mtu_desired != mtu_plat) || (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) { + gboolean anticipated_failure = FALSE; if (!priv->mtu_initial && !priv->ip6_mtu_initial) { /* before touching any of the MTU paramters, record the @@ -7355,13 +7357,30 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config) } if (mtu_desired && mtu_desired != mtu_plat) { - nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, mtu_desired); + if (nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, mtu_desired) == NM_PLATFORM_ERROR_CANT_SET_MTU) { + anticipated_failure = TRUE; + _LOGW (LOGD_DEVICE, "mtu: failure to set MTU. %s", + NM_IS_DEVICE_VLAN (self) + ? "Is the parent's MTU size large enough?" + : (!c_list_is_empty (&priv->slaves) + ? "Are the MTU sizes of the slaves large enough?" + : "Did you configure the MTU correctly?")); + } priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS; } if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) { - nm_device_ipv6_sysctl_set (self, "mtu", - nm_sprintf_buf (sbuf, "%u", (unsigned) ip6_mtu)); + if (!nm_device_ipv6_sysctl_set (self, "mtu", + nm_sprintf_buf (sbuf, "%u", (unsigned) ip6_mtu))) { + int errsv = errno; + + _NMLOG (anticipated_failure && errsv == EINVAL ? LOGL_DEBUG : LOGL_WARN, + LOGD_DEVICE, + "mtu: failure to set IPv6 MTU%s", + anticipated_failure && errsv == EINVAL + ? ": Is the underlying MTU value successfully set?" + : ""); + } priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS; } } |