mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-04 17:40:33 +01:00
device: store the original MTU before force-setting it
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:e23798a5e5('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 (cherry picked from commit3f42e2005a) (cherry picked from commit7730547721)
This commit is contained in:
parent
ca122d1a14
commit
9121b961eb
1 changed files with 21 additions and 15 deletions
|
|
@ -10522,10 +10522,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);
|
||||
|
|
@ -10544,20 +10564,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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue