From 7aa3b439df293b16597df3a0a2baa6caf3bb1322 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Thu, 23 Jul 2020 17:18:56 +0200
Subject: [PATCH 1/1] 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)
---
src/devices/nm-device.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 57c32cef8f09..24209c8614f1 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -10268,14 +10268,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;
}
--
2.26.2