mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 05:58:01 +02:00
device: merge branch 'bg/parent-mtu-rh1723690-part1'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/273 (cherry picked from commitfacfc94744) (cherry picked from commit188911ae7d)
This commit is contained in:
commit
eefc12866b
15 changed files with 165 additions and 43 deletions
|
|
@ -1374,13 +1374,15 @@ act_stage3_ip_config_start (NMDevice *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
get_configured_mtu (NMDevice *device,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
/* MTU only set for plain ethernet */
|
/* MTU only set for plain ethernet */
|
||||||
if (NM_DEVICE_ETHERNET_GET_PRIVATE ((NMDeviceEthernet *) device)->ppp_manager)
|
if (NM_DEVICE_ETHERNET_GET_PRIVATE ((NMDeviceEthernet *) device)->ppp_manager)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return nm_device_get_configured_mtu_for_wired (device, out_source);
|
return nm_device_get_configured_mtu_for_wired (device, out_source, out_force);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,9 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
get_configured_mtu (NMDevice *device,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
return nm_device_get_configured_mtu_from_connection (device,
|
return nm_device_get_configured_mtu_from_connection (device,
|
||||||
NM_TYPE_SETTING_INFINIBAND,
|
NM_TYPE_SETTING_INFINIBAND,
|
||||||
|
|
|
||||||
|
|
@ -854,7 +854,9 @@ create_and_realize (NMDevice *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
get_configured_mtu (NMDevice *device,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
return nm_device_get_configured_mtu_from_connection (device,
|
return nm_device_get_configured_mtu_from_connection (device,
|
||||||
NM_TYPE_SETTING_IP_TUNNEL,
|
NM_TYPE_SETTING_IP_TUNNEL,
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceMacsec,
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMPlatformLnkMacsec props;
|
NMPlatformLnkMacsec props;
|
||||||
gulong parent_state_id;
|
gulong parent_state_id;
|
||||||
|
gulong parent_mtu_id;
|
||||||
Supplicant supplicant;
|
Supplicant supplicant;
|
||||||
guint supplicant_timeout_id;
|
guint supplicant_timeout_id;
|
||||||
NMActRequestGetSecretsCallId *macsec_secrets_id;
|
NMActRequestGetSecretsCallId *macsec_secrets_id;
|
||||||
|
|
@ -114,6 +115,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);
|
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 MACsec 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
|
static void
|
||||||
parent_changed_notify (NMDevice *device,
|
parent_changed_notify (NMDevice *device,
|
||||||
int old_ifindex,
|
int old_ifindex,
|
||||||
|
|
@ -134,12 +146,16 @@ parent_changed_notify (NMDevice *device,
|
||||||
* because NMDevice's dispose() will unset the parent, which in turn calls
|
* because NMDevice's dispose() will unset the parent, which in turn calls
|
||||||
* parent_changed_notify(). */
|
* parent_changed_notify(). */
|
||||||
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
||||||
|
nm_clear_g_signal_handler (old_parent, &priv->parent_mtu_id);
|
||||||
|
|
||||||
if (new_parent) {
|
if (new_parent) {
|
||||||
priv->parent_state_id = g_signal_connect (new_parent,
|
priv->parent_state_id = g_signal_connect (new_parent,
|
||||||
NM_DEVICE_STATE_CHANGED,
|
NM_DEVICE_STATE_CHANGED,
|
||||||
G_CALLBACK (parent_state_changed),
|
G_CALLBACK (parent_state_changed),
|
||||||
device);
|
device);
|
||||||
|
priv->parent_mtu_id = g_signal_connect (new_parent, "notify::" NM_DEVICE_MTU,
|
||||||
|
G_CALLBACK (parent_mtu_maybe_changed), device);
|
||||||
|
|
||||||
|
|
||||||
/* Set parent-dependent unmanaged flag */
|
/* Set parent-dependent unmanaged flag */
|
||||||
nm_device_set_unmanaged_by_flags (device,
|
nm_device_set_unmanaged_by_flags (device,
|
||||||
|
|
@ -792,11 +808,15 @@ static void
|
||||||
dispose (GObject *object)
|
dispose (GObject *object)
|
||||||
{
|
{
|
||||||
NMDeviceMacsec *self = NM_DEVICE_MACSEC (object);
|
NMDeviceMacsec *self = NM_DEVICE_MACSEC (object);
|
||||||
|
NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self);
|
||||||
|
|
||||||
macsec_secrets_cancel (self);
|
macsec_secrets_cancel (self);
|
||||||
supplicant_interface_release (self);
|
supplicant_interface_release (self);
|
||||||
|
|
||||||
G_OBJECT_CLASS (nm_device_macsec_parent_class)->dispose (object);
|
G_OBJECT_CLASS (nm_device_macsec_parent_class)->dispose (object);
|
||||||
|
|
||||||
|
nm_assert (priv->parent_state_id == 0);
|
||||||
|
nm_assert (priv->parent_mtu_id == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const NMDBusInterfaceInfoExtended interface_info_device_macsec = {
|
static const NMDBusInterfaceInfoExtended interface_info_device_macsec = {
|
||||||
|
|
@ -839,6 +859,7 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *klass)
|
||||||
device_class->connection_type_supported = NM_SETTING_MACSEC_SETTING_NAME;
|
device_class->connection_type_supported = NM_SETTING_MACSEC_SETTING_NAME;
|
||||||
device_class->connection_type_check_compatible = NM_SETTING_MACSEC_SETTING_NAME;
|
device_class->connection_type_check_compatible = NM_SETTING_MACSEC_SETTING_NAME;
|
||||||
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_MACSEC);
|
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_MACSEC);
|
||||||
|
device_class->mtu_parent_delta = 32;
|
||||||
|
|
||||||
device_class->act_stage2_config = act_stage2_config;
|
device_class->act_stage2_config = act_stage2_config;
|
||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
|
|
@ -848,7 +869,7 @@ nm_device_macsec_class_init (NMDeviceMacsecClass *klass)
|
||||||
device_class->is_available = is_available;
|
device_class->is_available = is_available;
|
||||||
device_class->parent_changed_notify = parent_changed_notify;
|
device_class->parent_changed_notify = parent_changed_notify;
|
||||||
device_class->state_changed = device_state_changed;
|
device_class->state_changed = device_state_changed;
|
||||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
device_class->get_configured_mtu = nm_device_get_configured_mtu_wired_parent;
|
||||||
|
|
||||||
obj_properties[PROP_SCI] =
|
obj_properties[PROP_SCI] =
|
||||||
g_param_spec_uint64 (NM_DEVICE_MACSEC_SCI, "", "",
|
g_param_spec_uint64 (NM_DEVICE_MACSEC_SCI, "", "",
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceMacvlan,
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gulong parent_state_id;
|
gulong parent_state_id;
|
||||||
|
gulong parent_mtu_id;
|
||||||
NMPlatformLnkMacvlan props;
|
NMPlatformLnkMacvlan props;
|
||||||
} NMDeviceMacvlanPrivate;
|
} NMDeviceMacvlanPrivate;
|
||||||
|
|
||||||
|
|
@ -135,6 +136,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);
|
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 macvlan/macvtap 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
|
static void
|
||||||
parent_changed_notify (NMDevice *device,
|
parent_changed_notify (NMDevice *device,
|
||||||
int old_ifindex,
|
int old_ifindex,
|
||||||
|
|
@ -151,12 +163,15 @@ parent_changed_notify (NMDevice *device,
|
||||||
* because NMDevice's dispose() will unset the parent, which in turn calls
|
* because NMDevice's dispose() will unset the parent, which in turn calls
|
||||||
* parent_changed_notify(). */
|
* parent_changed_notify(). */
|
||||||
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
|
||||||
|
nm_clear_g_signal_handler (old_parent, &priv->parent_mtu_id);
|
||||||
|
|
||||||
if (new_parent) {
|
if (new_parent) {
|
||||||
priv->parent_state_id = g_signal_connect (new_parent,
|
priv->parent_state_id = g_signal_connect (new_parent,
|
||||||
NM_DEVICE_STATE_CHANGED,
|
NM_DEVICE_STATE_CHANGED,
|
||||||
G_CALLBACK (parent_state_changed),
|
G_CALLBACK (parent_state_changed),
|
||||||
device);
|
device);
|
||||||
|
priv->parent_mtu_id = g_signal_connect (new_parent, "notify::" NM_DEVICE_MTU,
|
||||||
|
G_CALLBACK (parent_mtu_maybe_changed), device);
|
||||||
|
|
||||||
/* Set parent-dependent unmanaged flag */
|
/* Set parent-dependent unmanaged flag */
|
||||||
nm_device_set_unmanaged_by_flags (device,
|
nm_device_set_unmanaged_by_flags (device,
|
||||||
|
|
@ -475,6 +490,17 @@ nm_device_macvlan_init (NMDeviceMacvlan *self)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dispose (GObject *object)
|
||||||
|
{
|
||||||
|
NMDeviceMacvlanPrivate *priv = NM_DEVICE_MACVLAN_GET_PRIVATE (object);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (nm_device_macvlan_parent_class)->dispose (object);
|
||||||
|
|
||||||
|
nm_assert (priv->parent_state_id == 0);
|
||||||
|
nm_assert (priv->parent_mtu_id == 0);
|
||||||
|
}
|
||||||
|
|
||||||
static const NMDBusInterfaceInfoExtended interface_info_device_macvlan = {
|
static const NMDBusInterfaceInfoExtended interface_info_device_macvlan = {
|
||||||
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
|
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
|
||||||
NM_DBUS_INTERFACE_DEVICE_MACVLAN,
|
NM_DBUS_INTERFACE_DEVICE_MACVLAN,
|
||||||
|
|
@ -498,6 +524,7 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
||||||
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
|
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
|
||||||
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = dispose;
|
||||||
object_class->get_property = get_property;
|
object_class->get_property = get_property;
|
||||||
object_class->set_property = set_property;
|
object_class->set_property = set_property;
|
||||||
|
|
||||||
|
|
@ -506,13 +533,14 @@ nm_device_macvlan_class_init (NMDeviceMacvlanClass *klass)
|
||||||
device_class->connection_type_supported = NM_SETTING_MACVLAN_SETTING_NAME;
|
device_class->connection_type_supported = NM_SETTING_MACVLAN_SETTING_NAME;
|
||||||
device_class->connection_type_check_compatible = NM_SETTING_MACVLAN_SETTING_NAME;
|
device_class->connection_type_check_compatible = NM_SETTING_MACVLAN_SETTING_NAME;
|
||||||
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP);
|
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_MACVLAN, NM_LINK_TYPE_MACVTAP);
|
||||||
|
device_class->mtu_parent_delta = 0;
|
||||||
|
|
||||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
device_class->check_connection_compatible = check_connection_compatible;
|
device_class->check_connection_compatible = check_connection_compatible;
|
||||||
device_class->complete_connection = complete_connection;
|
device_class->complete_connection = complete_connection;
|
||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
device_class->get_configured_mtu = nm_device_get_configured_mtu_wired_parent;
|
||||||
device_class->is_available = is_available;
|
device_class->is_available = is_available;
|
||||||
device_class->link_changed = link_changed;
|
device_class->link_changed = link_changed;
|
||||||
device_class->parent_changed_notify = parent_changed_notify;
|
device_class->parent_changed_notify = parent_changed_notify;
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,11 @@ guint32 nm_device_get_configured_mtu_from_connection (NMDevice *device,
|
||||||
GType setting_type,
|
GType setting_type,
|
||||||
NMDeviceMtuSource *out_source);
|
NMDeviceMtuSource *out_source);
|
||||||
|
|
||||||
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, NMDeviceMtuSource *out_source);
|
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, NMDeviceMtuSource *out_source, gboolean *out_force);
|
||||||
|
|
||||||
|
guint32 nm_device_get_configured_mtu_wired_parent (NMDevice *self,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force);
|
||||||
|
|
||||||
void nm_device_commit_mtu (NMDevice *self);
|
void nm_device_commit_mtu (NMDevice *self);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -523,26 +523,6 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
|
||||||
get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source)
|
|
||||||
{
|
|
||||||
guint32 mtu = 0;
|
|
||||||
int ifindex;
|
|
||||||
|
|
||||||
mtu = nm_device_get_configured_mtu_for_wired (self, out_source);
|
|
||||||
if (*out_source != NM_DEVICE_MTU_SOURCE_NONE)
|
|
||||||
return mtu;
|
|
||||||
|
|
||||||
/* Inherit the MTU from parent device, if any */
|
|
||||||
ifindex = nm_device_parent_get_ifindex (self);
|
|
||||||
if (ifindex > 0) {
|
|
||||||
mtu = nm_platform_link_get_mtu (nm_device_get_platform (NM_DEVICE (self)), ifindex);
|
|
||||||
*out_source = NM_DEVICE_MTU_SOURCE_PARENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mtu;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -598,13 +578,14 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
||||||
device_class->connection_type_supported = NM_SETTING_VLAN_SETTING_NAME;
|
device_class->connection_type_supported = NM_SETTING_VLAN_SETTING_NAME;
|
||||||
device_class->connection_type_check_compatible = NM_SETTING_VLAN_SETTING_NAME;
|
device_class->connection_type_check_compatible = NM_SETTING_VLAN_SETTING_NAME;
|
||||||
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_VLAN);
|
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_VLAN);
|
||||||
|
device_class->mtu_parent_delta = 0; /* VLANs can have the same MTU of parent */
|
||||||
|
|
||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
device_class->link_changed = link_changed;
|
device_class->link_changed = link_changed;
|
||||||
device_class->unrealize_notify = unrealize_notify;
|
device_class->unrealize_notify = unrealize_notify;
|
||||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
device_class->get_configured_mtu = get_configured_mtu;
|
device_class->get_configured_mtu = nm_device_get_configured_mtu_wired_parent;
|
||||||
device_class->is_available = is_available;
|
device_class->is_available = is_available;
|
||||||
device_class->parent_changed_notify = parent_changed_notify;
|
device_class->parent_changed_notify = parent_changed_notify;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1378,7 +1378,7 @@ act_stage3_ip_config_start (NMDevice *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source, gboolean *out_force)
|
||||||
{
|
{
|
||||||
/* When "MTU" for `wg-quick up` is unset, it calls `ip route get` for
|
/* When "MTU" for `wg-quick up` is unset, it calls `ip route get` for
|
||||||
* each configured endpoint, to determine the suitable MTU how to reach
|
* each configured endpoint, to determine the suitable MTU how to reach
|
||||||
|
|
|
||||||
|
|
@ -9068,13 +9068,59 @@ nm_device_get_configured_mtu_from_connection (NMDevice *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
nm_device_get_configured_mtu_for_wired (NMDevice *self, NMDeviceMtuSource *out_source)
|
nm_device_get_configured_mtu_for_wired (NMDevice *self,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
return nm_device_get_configured_mtu_from_connection (self,
|
return nm_device_get_configured_mtu_from_connection (self,
|
||||||
NM_TYPE_SETTING_WIRED,
|
NM_TYPE_SETTING_WIRED,
|
||||||
out_source);
|
out_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guint32
|
||||||
|
nm_device_get_configured_mtu_wired_parent (NMDevice *self,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
|
{
|
||||||
|
guint32 mtu = 0;
|
||||||
|
guint32 parent_mtu = 0;
|
||||||
|
int ifindex;
|
||||||
|
|
||||||
|
ifindex = nm_device_parent_get_ifindex (self);
|
||||||
|
if (ifindex > 0) {
|
||||||
|
parent_mtu = nm_platform_link_get_mtu (nm_device_get_platform (self), ifindex);
|
||||||
|
if (parent_mtu >= NM_DEVICE_GET_CLASS (self)->mtu_parent_delta)
|
||||||
|
parent_mtu -= NM_DEVICE_GET_CLASS (self)->mtu_parent_delta;
|
||||||
|
else
|
||||||
|
parent_mtu = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mtu = nm_device_get_configured_mtu_for_wired (self, out_source, NULL);
|
||||||
|
|
||||||
|
if (parent_mtu && mtu > parent_mtu) {
|
||||||
|
/* Trying to set a MTU that is out of range from configuration:
|
||||||
|
* fall back to the parent MTU and set force flag so that it
|
||||||
|
* overrides an MTU with higher priority already configured.
|
||||||
|
*/
|
||||||
|
*out_source = NM_DEVICE_MTU_SOURCE_PARENT;
|
||||||
|
*out_force = TRUE;
|
||||||
|
return parent_mtu;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*out_source != NM_DEVICE_MTU_SOURCE_NONE) {
|
||||||
|
nm_assert (mtu > 0);
|
||||||
|
return mtu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inherit the MTU from parent device, if any */
|
||||||
|
if (parent_mtu) {
|
||||||
|
mtu = parent_mtu;
|
||||||
|
*out_source = NM_DEVICE_MTU_SOURCE_PARENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mtu;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -9126,15 +9172,34 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
||||||
|
|
||||||
{
|
{
|
||||||
guint32 mtu = 0;
|
guint32 mtu = 0;
|
||||||
|
gboolean force = FALSE;
|
||||||
|
|
||||||
/* preferably, get the MTU from explicit user-configuration.
|
/* We take the MTU from various sources: (in order of increasing
|
||||||
* Only if that fails, look at the current @config (which contains
|
* priority) parent link, IP configuration (which contains the
|
||||||
* MTUs from DHCP/PPP) or maybe fallback to a device-specific MTU. */
|
* MTU from DHCP/PPP), connection profile.
|
||||||
|
*
|
||||||
|
* We could just compare it with the platform MTU and apply it
|
||||||
|
* when different, but this would revert at random times manual
|
||||||
|
* changes done by the user with the MTU from the connection.
|
||||||
|
*
|
||||||
|
* Instead, we remember the source of the currently configured
|
||||||
|
* MTU and apply the new one only when the new source has a
|
||||||
|
* higher priority, so that we don't set a MTU from same source
|
||||||
|
* multiple times. An exception to this is for the PARENT
|
||||||
|
* source, since we need to keep tracking the parent MTU when it
|
||||||
|
* changes.
|
||||||
|
*
|
||||||
|
* The subclass can set the @force argument to TRUE to signal that the
|
||||||
|
* returned MTU should be applied even if it has a lower priority. This
|
||||||
|
* is useful when the value from a lower source should
|
||||||
|
* preempt the one from higher ones.
|
||||||
|
*/
|
||||||
|
|
||||||
if (NM_DEVICE_GET_CLASS (self)->get_configured_mtu)
|
if (NM_DEVICE_GET_CLASS (self)->get_configured_mtu)
|
||||||
mtu = NM_DEVICE_GET_CLASS (self)->get_configured_mtu (self, &source);
|
mtu = NM_DEVICE_GET_CLASS (self)->get_configured_mtu (self, &source, &force);
|
||||||
|
|
||||||
if ( config
|
if ( config
|
||||||
|
&& !force
|
||||||
&& source < NM_DEVICE_MTU_SOURCE_IP_CONFIG
|
&& source < NM_DEVICE_MTU_SOURCE_IP_CONFIG
|
||||||
&& nm_ip4_config_get_mtu (config)) {
|
&& nm_ip4_config_get_mtu (config)) {
|
||||||
mtu = nm_ip4_config_get_mtu (config);
|
mtu = nm_ip4_config_get_mtu (config);
|
||||||
|
|
@ -9143,14 +9208,16 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
|
||||||
|
|
||||||
if (mtu != 0) {
|
if (mtu != 0) {
|
||||||
_LOGT (LOGD_DEVICE,
|
_LOGT (LOGD_DEVICE,
|
||||||
"mtu: value %u from source '%s' (%u), current source '%s' (%u)",
|
"mtu: value %u from source '%s' (%u), current source '%s' (%u)%s",
|
||||||
(guint) mtu,
|
(guint) mtu,
|
||||||
mtu_source_to_str (source), (guint) source,
|
mtu_source_to_str (source), (guint) source,
|
||||||
mtu_source_to_str (priv->mtu_source), (guint) priv->mtu_source);
|
mtu_source_to_str (priv->mtu_source), (guint) priv->mtu_source,
|
||||||
|
force ? " (forced)" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mtu != 0
|
if ( mtu != 0
|
||||||
&& ( source > priv->mtu_source
|
&& ( force
|
||||||
|
|| source > priv->mtu_source
|
||||||
|| (priv->mtu_source == NM_DEVICE_MTU_SOURCE_PARENT && source == priv->mtu_source)))
|
|| (priv->mtu_source == NM_DEVICE_MTU_SOURCE_PARENT && source == priv->mtu_source)))
|
||||||
mtu_desired = mtu;
|
mtu_desired = mtu;
|
||||||
else {
|
else {
|
||||||
|
|
@ -14575,6 +14642,7 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->mtu_source = NM_DEVICE_MTU_SOURCE_NONE;
|
priv->mtu_source = NM_DEVICE_MTU_SOURCE_NONE;
|
||||||
|
priv->ip6_mtu = 0;
|
||||||
if (priv->mtu_initial || priv->ip6_mtu_initial) {
|
if (priv->mtu_initial || priv->ip6_mtu_initial) {
|
||||||
ifindex = nm_device_get_ip_ifindex (self);
|
ifindex = nm_device_get_ip_ifindex (self);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,10 @@ typedef struct _NMDeviceClass {
|
||||||
|
|
||||||
const NMLinkType *link_types;
|
const NMLinkType *link_types;
|
||||||
|
|
||||||
|
/* if the device MTU is set based on parent's one, this specifies
|
||||||
|
* a delta in the MTU allowed value due the encapsulation overhead */
|
||||||
|
guint16 mtu_parent_delta;
|
||||||
|
|
||||||
/* Whether the device type is a master-type. This depends purely on the
|
/* Whether the device type is a master-type. This depends purely on the
|
||||||
* type (NMDeviceClass), not the actual device instance. */
|
* type (NMDeviceClass), not the actual device instance. */
|
||||||
bool is_master:1;
|
bool is_master:1;
|
||||||
|
|
@ -330,7 +334,9 @@ typedef struct _NMDeviceClass {
|
||||||
NMSettingsConnection *sett_conn,
|
NMSettingsConnection *sett_conn,
|
||||||
char **specific_object);
|
char **specific_object);
|
||||||
|
|
||||||
guint32 (*get_configured_mtu) (NMDevice *self, NMDeviceMtuSource *out_source);
|
guint32 (*get_configured_mtu) (NMDevice *self,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force);
|
||||||
|
|
||||||
const char *(*get_auto_ip_config_method) (NMDevice *self, int addr_family);
|
const char *(*get_auto_ip_config_method) (NMDevice *self, int addr_family);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1911,7 +1911,9 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
get_configured_mtu (NMDevice *device,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
return nm_device_get_configured_mtu_from_connection (device,
|
return nm_device_get_configured_mtu_from_connection (device,
|
||||||
NM_TYPE_SETTING_WIRELESS,
|
NM_TYPE_SETTING_WIRELESS,
|
||||||
|
|
|
||||||
|
|
@ -628,7 +628,9 @@ deactivate (NMDevice *device)
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
get_configured_mtu (NMDevice *device,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
*out_source = NM_DEVICE_MTU_SOURCE_NONE;
|
*out_source = NM_DEVICE_MTU_SOURCE_NONE;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -2901,7 +2901,9 @@ act_stage3_ip_config_start (NMDevice *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint32
|
static guint32
|
||||||
get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
|
get_configured_mtu (NMDevice *device,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
return nm_device_get_configured_mtu_from_connection (device,
|
return nm_device_get_configured_mtu_from_connection (device,
|
||||||
NM_TYPE_SETTING_WIRELESS,
|
NM_TYPE_SETTING_WIRELESS,
|
||||||
|
|
|
||||||
|
|
@ -858,7 +858,9 @@ nm_modem_stage3_ip6_config_start (NMModem *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source)
|
nm_modem_get_configured_mtu (NMDevice *self,
|
||||||
|
NMDeviceMtuSource *out_source,
|
||||||
|
gboolean *out_force)
|
||||||
{
|
{
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
NMSetting *setting;
|
NMSetting *setting;
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,6 @@ void nm_modem_emit_ip6_config_result (NMModem *self,
|
||||||
|
|
||||||
const char *nm_modem_ip_type_to_string (NMModemIPType ip_type);
|
const char *nm_modem_ip_type_to_string (NMModemIPType ip_type);
|
||||||
|
|
||||||
guint32 nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source);
|
guint32 nm_modem_get_configured_mtu (NMDevice *self, NMDeviceMtuSource *out_source, gboolean *out_force);
|
||||||
|
|
||||||
#endif /* __NETWORKMANAGER_MODEM_H__ */
|
#endif /* __NETWORKMANAGER_MODEM_H__ */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue