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
This commit is contained in:
Beniamino Galvani 2020-07-23 17:18:56 +02:00
parent cb73d0b1e2
commit 9c09dcedaf

View file

@ -10321,14 +10321,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;
}