diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-07-23 17:18:56 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-07-24 13:46:27 +0200 |
commit | dcb48bc9d9745b7d3915270a7aabac44372dbe72 (patch) | |
tree | 3567ee56a5b21b2c4a2972a6aeebf05408394df5 | |
parent | 8dc357dc11f735703965193a235b4a401bd38f31 (diff) | |
download | NetworkManager-dcb48bc9d9745b7d3915270a7aabac44372dbe72.tar.gz |
device: downgrade warning about IPv6 MTU if IPv6 is disabled
If IPv6 is disabled, changing the IPv6 MTU fails and NM complains with
a warning. Since this error is expected and doesn't do any harm,
downgrade the logging level to DEBUG.
Since IPv6 kernel support can be built as a module, we have to check
the existence of /proc/sys/net/ipv6 every time. Instead of checking it
and then setting the MTU (adding one /proc access for everyone), just try
to set the MTU; in case of failure, determine the reason for the error.
https://bugzilla.redhat.com/show_bug.cgi?id=1840989
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/585
(cherry picked from commit 9c09dcedafd51da65c04669b830bc9652000d462)
(cherry picked from commit ce3dffd24eb21924a332794bc66705dbd6c052a2)
-rw-r--r-- | src/devices/nm-device.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 433be66220..e6b3624c73 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -9988,14 +9988,25 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config) if (!nm_device_sysctl_ip_conf_set (self, AF_INET6, "mtu", nm_sprintf_buf (sbuf, "%u", (unsigned) ip6_mtu))) { int errsv = errno; + NMLogLevel level = LOGL_WARN; + const char *msg = NULL; - _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?" - : ""); success = FALSE; + + if (anticipated_failure && errsv == EINVAL) { + level = LOGL_DEBUG; + msg = "Is the underlying MTU value successfully set?"; + } else if (!g_file_test ("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) { + level = LOGL_DEBUG; + msg = "IPv6 is disabled"; + success = TRUE; + } + + _NMLOG (level, + LOGD_DEVICE, + "mtu: failure to set IPv6 MTU%s%s", + msg ? ": " : "", + msg ?: ""); } priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_msec () + CARRIER_WAIT_TIME_AFTER_MTU_MS; } |