Blame SOURCES/1007-core-no-warn-setting-mtu-with-ipv6-disabled-rh1840989.patch

146a1d
From 7aa3b439df293b16597df3a0a2baa6caf3bb1322 Mon Sep 17 00:00:00 2001
146a1d
From: Beniamino Galvani <bgalvani@redhat.com>
146a1d
Date: Thu, 23 Jul 2020 17:18:56 +0200
146a1d
Subject: [PATCH 1/1] device: downgrade warning about IPv6 MTU if IPv6 is
146a1d
 disabled
146a1d
146a1d
If IPv6 is disabled, changing the IPv6 MTU fails and NM complains with
146a1d
a warning. Since this error is expected and doesn't do any harm,
146a1d
downgrade the logging level to DEBUG.
146a1d
146a1d
Since IPv6 kernel support can be built as a module, we have to check
146a1d
the existence of /proc/sys/net/ipv6 every time. Instead of checking it
146a1d
and then setting the MTU (adding one /proc access for everyone), just try
146a1d
to set the MTU; in case of failure, determine the reason for the error.
146a1d
146a1d
https://bugzilla.redhat.com/show_bug.cgi?id=1840989
146a1d
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/585
146a1d
(cherry picked from commit 9c09dcedafd51da65c04669b830bc9652000d462)
146a1d
(cherry picked from commit ce3dffd24eb21924a332794bc66705dbd6c052a2)
146a1d
---
146a1d
 src/devices/nm-device.c | 23 +++++++++++++++++------
146a1d
 1 file changed, 17 insertions(+), 6 deletions(-)
146a1d
146a1d
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
146a1d
index 57c32cef8f09..24209c8614f1 100644
146a1d
--- a/src/devices/nm-device.c
146a1d
+++ b/src/devices/nm-device.c
146a1d
@@ -10268,14 +10268,25 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
146a1d
 			if (!nm_device_sysctl_ip_conf_set (self, AF_INET6, "mtu",
146a1d
 			                                   nm_sprintf_buf (sbuf, "%u", (unsigned) ip6_mtu))) {
146a1d
 				int errsv = errno;
146a1d
+				NMLogLevel level = LOGL_WARN;
146a1d
+				const char *msg = NULL;
146a1d
 
146a1d
-				_NMLOG (anticipated_failure && errsv == EINVAL ? LOGL_DEBUG : LOGL_WARN,
146a1d
-				        LOGD_DEVICE,
146a1d
-				        "mtu: failure to set IPv6 MTU%s",
146a1d
-				        anticipated_failure && errsv == EINVAL
146a1d
-				           ? ": Is the underlying MTU value successfully set?"
146a1d
-				           : "");
146a1d
 				success = FALSE;
146a1d
+
146a1d
+				if (anticipated_failure && errsv == EINVAL) {
146a1d
+					level = LOGL_DEBUG;
146a1d
+					msg = "Is the underlying MTU value successfully set?";
146a1d
+				} else if (!g_file_test ("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) {
146a1d
+					level = LOGL_DEBUG;
146a1d
+					msg = "IPv6 is disabled";
146a1d
+					success = TRUE;
146a1d
+				}
146a1d
+
146a1d
+				_NMLOG (level,
146a1d
+				        LOGD_DEVICE,
146a1d
+				        "mtu: failure to set IPv6 MTU%s%s",
146a1d
+				        msg ? ": " : "",
146a1d
+				        msg ?: "");
146a1d
 			}
146a1d
 			priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_msec () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
146a1d
 		}
146a1d
-- 
146a1d
2.26.2
146a1d