mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 21:48:08 +02:00
macvlan: update MTU according to parent's one
This commit is contained in:
parent
438a0a9ad5
commit
4875745bc0
1 changed files with 29 additions and 1 deletions
|
|
@ -34,6 +34,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;
|
||||||
|
|
||||||
|
|
@ -120,6 +121,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,
|
||||||
|
|
@ -136,12 +148,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,
|
||||||
|
|
@ -447,6 +462,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,
|
||||||
|
|
@ -470,6 +496,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;
|
||||||
|
|
||||||
|
|
@ -478,13 +505,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_set_hwaddr_ethernet = TRUE;
|
device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
|
||||||
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;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue