mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 09:30:16 +01:00
device: reset MTU when VLAN's parent device changes MTU
Kernel does not allow setting the MTU of a VLAN larger then the MTU of the underlying device. Hence, we might initially fail to set a large MTU of the VLAN, but we have to retry when the MTU of the parent changes. https://bugzilla.redhat.com/show_bug.cgi?id=1414901
This commit is contained in:
parent
05c4497bdd
commit
667aed8aeb
3 changed files with 39 additions and 3 deletions
|
|
@ -118,6 +118,8 @@ gint64 nm_device_get_configured_mtu_from_connection_default (NMDevice *self,
|
|||
|
||||
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config);
|
||||
|
||||
void nm_device_commit_mtu (NMDevice *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_DEVICE_CLASS_DECLARE_TYPES(klass, conn_type, ...) \
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVlan,
|
|||
typedef struct {
|
||||
gulong parent_state_id;
|
||||
gulong parent_hwaddr_id;
|
||||
gulong parent_mtu_id;
|
||||
guint vlan_id;
|
||||
} NMDeviceVlanPrivate;
|
||||
|
||||
|
|
@ -85,6 +86,17 @@ parent_state_changed (NMDevice *parent,
|
|||
nm_device_set_unmanaged_by_flags (NM_DEVICE (self), NM_UNMANAGED_PARENT, !nm_device_get_managed (parent, FALSE), reason);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_mtu_maybe_changed (NMDevice *parent,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
/* the MTU of a VLAN device is limited by the parent's MTU.
|
||||
*
|
||||
* When the parent's MTU changes, try to re-set the MTU. */
|
||||
nm_device_commit_mtu (user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_hwaddr_maybe_changed (NMDevice *parent,
|
||||
GParamSpec *pspec,
|
||||
|
|
@ -143,6 +155,7 @@ parent_changed_notify (NMDevice *device,
|
|||
* parent_changed_notify(). */
|
||||
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
||||
nm_clear_g_signal_handler (old_parent, &priv->parent_hwaddr_id);
|
||||
nm_clear_g_signal_handler (old_parent, &priv->parent_mtu_id);
|
||||
|
||||
if (new_parent) {
|
||||
priv->parent_state_id = g_signal_connect (new_parent,
|
||||
|
|
@ -154,6 +167,10 @@ parent_changed_notify (NMDevice *device,
|
|||
G_CALLBACK (parent_hwaddr_maybe_changed), device);
|
||||
parent_hwaddr_maybe_changed (new_parent, NULL, self);
|
||||
|
||||
priv->parent_mtu_id = g_signal_connect (new_parent, "notify::" NM_DEVICE_MTU,
|
||||
G_CALLBACK (parent_mtu_maybe_changed), device);
|
||||
parent_mtu_maybe_changed (new_parent, NULL, self);
|
||||
|
||||
/* Set parent-dependent unmanaged flag */
|
||||
nm_device_set_unmanaged_by_flags (device,
|
||||
NM_UNMANAGED_PARENT,
|
||||
|
|
@ -482,8 +499,10 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
|||
|
||||
/* Change MAC address to parent's one if needed */
|
||||
parent_device = nm_device_parent_get_device (device);
|
||||
if (parent_device)
|
||||
if (parent_device) {
|
||||
parent_hwaddr_maybe_changed (parent_device, NULL, device);
|
||||
parent_mtu_maybe_changed (parent_device, NULL, device);
|
||||
}
|
||||
|
||||
s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN);
|
||||
if (s_vlan) {
|
||||
|
|
|
|||
|
|
@ -7231,8 +7231,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
|||
return;
|
||||
|
||||
if (nm_device_sys_iface_state_is_external_or_assume (self)) {
|
||||
/* for assumed connections we don't tamper with the MTU. This is
|
||||
* a bug and supposed to be fixed by the unmanaged/assumed rework. */
|
||||
/* for assumed connections we don't tamper with the MTU. */
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -7354,6 +7353,22 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
|||
#undef _IP6_MTU_SYS
|
||||
}
|
||||
|
||||
void
|
||||
nm_device_commit_mtu (NMDevice *self)
|
||||
{
|
||||
NMDeviceState state;
|
||||
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
|
||||
state = nm_device_get_state (self);
|
||||
if ( state >= NM_DEVICE_STATE_CONFIG
|
||||
&& state < NM_DEVICE_STATE_DEACTIVATING) {
|
||||
_LOGT (LOGD_DEVICE, "mtu: commit-mtu...");
|
||||
_commit_mtu (self, NM_DEVICE_GET_PRIVATE (self)->ip4_config);
|
||||
} else
|
||||
_LOGT (LOGD_DEVICE, "mtu: commit-mtu... skip due to state %s", nm_device_state_to_str (state));
|
||||
}
|
||||
|
||||
static void
|
||||
ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, NMDevice *self)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue