summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2021-08-06 09:01:37 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2021-08-06 15:31:02 +0200
commit3f42e2005aa768c73d6c455f57ac2753c9fd97c2 (patch)
tree44cb987124a5f10380b448e34166fc00c1c42491
parenta9279d1e89690443d405c4420b395e7f64121f27 (diff)
downloadNetworkManager-bg/mtu-init.tar.gz
device: store the original MTU before force-setting itbg/mtu-init
In case the MTU is force-set (e.g. for bridges), priv->mtu_initial and priv->ip6_mtu_initial must be initialized before changing the MTU, otherwise the wrong value will be restored on deactivation. Fixes: e23798a5e5e8 ('bridge: force (hack)-set of the MTU when explicitly set in the profile') https://bugzilla.redhat.com/show_bug.cgi?id=1973536 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/955
-rw-r--r--src/core/devices/nm-device.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index eef31c39c2..97c92d5611 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -10689,10 +10689,30 @@ _commit_mtu(NMDevice *self, const NMIP4Config *config)
}
}
+#define _IP6_MTU_SYS() \
+ ({ \
+ if (!ip6_mtu_sysctl.initialized) { \
+ ip6_mtu_sysctl.value = nm_device_sysctl_ip_conf_get_int_checked(self, \
+ AF_INET6, \
+ "mtu", \
+ 10, \
+ 0, \
+ G_MAXUINT32, \
+ 0); \
+ ip6_mtu_sysctl.initialized = TRUE; \
+ } \
+ ip6_mtu_sysctl.value; \
+ })
+
if (mtu_desired && NM_DEVICE_GET_CLASS(self)->mtu_force_set && !priv->mtu_force_set_done) {
priv->mtu_force_set_done = TRUE;
-
if (mtu_desired == mtu_plat) {
+ if (!priv->mtu_initial && !priv->ip6_mtu_initial) {
+ /* before touching any of the MTU parameters, record the
+ * original setting to restore on deactivation. */
+ priv->mtu_initial = mtu_plat;
+ priv->ip6_mtu_initial = _IP6_MTU_SYS();
+ }
mtu_plat--;
if (NM_DEVICE_GET_CLASS(self)->set_platform_mtu(self, mtu_desired - 1)) {
_LOGD(LOGD_DEVICE, "mtu: force-set MTU to %u", mtu_desired - 1);
@@ -10711,20 +10731,6 @@ _commit_mtu(NMDevice *self, const NMIP4Config *config)
ip6_mtu == ip6_mtu_orig ? "" : nm_sprintf_buf(sbuf2, " (was %u)", (guint) ip6_mtu_orig),
ifindex);
-#define _IP6_MTU_SYS() \
- ({ \
- if (!ip6_mtu_sysctl.initialized) { \
- ip6_mtu_sysctl.value = nm_device_sysctl_ip_conf_get_int_checked(self, \
- AF_INET6, \
- "mtu", \
- 10, \
- 0, \
- G_MAXUINT32, \
- 0); \
- ip6_mtu_sysctl.initialized = TRUE; \
- } \
- ip6_mtu_sysctl.value; \
- })
if ((mtu_desired && mtu_desired != mtu_plat) || (ip6_mtu && ip6_mtu != _IP6_MTU_SYS())) {
gboolean anticipated_failure = FALSE;