summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-06-26 10:48:03 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2018-07-02 17:55:14 +0200
commitfc99aad3780946bd036fad9a82845f6735f3c719 (patch)
tree21b7110967e75b45b0f80d1f4c504b00270c2b84
parent3f9f9f7fa228615967efd6000804f30011f33576 (diff)
downloadNetworkManager-bg/ip-tunnel-gretap-bgo796645.tar.gz
ip-tunnel: allow wired setting for some tunnel modesbg/ip-tunnel-gretap-bgo796645
gretap and ip6gretap ip-tunnel interfaces encapsulate L2 packets over IP. Allow adding a wired setting for such connections so that users can change the interface MAC.
-rw-r--r--clients/common/nm-meta-setting-desc.c1
-rw-r--r--libnm-core/nm-connection.c21
-rw-r--r--libnm-core/nm-setting-ip-tunnel.c14
-rw-r--r--src/devices/nm-device-ip-tunnel.c16
4 files changed, 52 insertions, 0 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index 649cbf4ef5..34c9d8e59f 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -7778,6 +7778,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
.valid_parts = NM_META_SETTING_VALID_PARTS (
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
NM_META_SETTING_VALID_PART_ITEM (IP_TUNNEL, TRUE),
+ NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE),
),
),
SETTING_INFO (MACSEC,
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 8a66afc61a..07b72c169c 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -1158,6 +1158,26 @@ _normalize_ovs_interface_type (NMConnection *self, GHashTable *parameters)
}
static gboolean
+_normalize_ip_tunnel_wired_setting (NMConnection *self, GHashTable *parameters)
+{
+ NMSettingIPTunnel *s_ip_tunnel;
+
+ s_ip_tunnel = nm_connection_get_setting_ip_tunnel (self);
+ if (!s_ip_tunnel)
+ return FALSE;
+
+ if ( nm_connection_get_setting_wired (self)
+ && !NM_IN_SET (nm_setting_ip_tunnel_get_mode (s_ip_tunnel),
+ NM_IP_TUNNEL_MODE_GRETAP,
+ NM_IP_TUNNEL_MODE_IP6GRETAP)) {
+ nm_connection_remove_setting (self, NM_TYPE_SETTING_WIRED);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
_normalize_required_settings (NMConnection *self, GHashTable *parameters)
{
NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth (self);
@@ -1502,6 +1522,7 @@ nm_connection_normalize (NMConnection *connection,
was_modified |= _normalize_team_port_config (connection, parameters);
was_modified |= _normalize_bluetooth_type (connection, parameters);
was_modified |= _normalize_ovs_interface_type (connection, parameters);
+ was_modified |= _normalize_ip_tunnel_wired_setting (connection, parameters);
/* Verify anew. */
success = _nm_connection_verify (connection, error);
diff --git a/libnm-core/nm-setting-ip-tunnel.c b/libnm-core/nm-setting-ip-tunnel.c
index 880d6d05ff..12ccd6a949 100644
--- a/libnm-core/nm-setting-ip-tunnel.c
+++ b/libnm-core/nm-setting-ip-tunnel.c
@@ -458,6 +458,20 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
+ if ( nm_connection_get_setting_wired (connection)
+ && !NM_IN_SET (priv->mode,
+ NM_IP_TUNNEL_MODE_GRETAP,
+ NM_IP_TUNNEL_MODE_IP6GRETAP)) {
+ g_set_error (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("wired setting not allowed for mode %s"),
+ nm_utils_enum_to_str (nm_ip_tunnel_mode_get_type (), priv->mode));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_IP_TUNNEL_SETTING_NAME,
+ NM_SETTING_IP_TUNNEL_MODE);
+ return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
+ }
+
return TRUE;
}
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
index a497461cc0..35c9b0b6f6 100644
--- a/src/devices/nm-device-ip-tunnel.c
+++ b/src/devices/nm-device-ip-tunnel.c
@@ -952,6 +952,21 @@ set_property (GObject *object, guint prop_id,
}
}
+static NMActStageReturn
+act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
+{
+ NMActStageReturn ret;
+
+ ret = NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class)->act_stage1_prepare (device, out_failure_reason);
+ if (ret != NM_ACT_STAGE_RETURN_SUCCESS)
+ return ret;
+
+ if (!nm_device_hw_addr_set_cloned (device, nm_device_get_applied_connection (device), FALSE))
+ return NM_ACT_STAGE_RETURN_FAILURE;
+
+ return NM_ACT_STAGE_RETURN_SUCCESS;
+}
+
/*****************************************************************************/
static void
@@ -1028,6 +1043,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ip_tunnel);
+ device_class->act_stage1_prepare = act_stage1_prepare;
device_class->link_changed = link_changed;
device_class->can_reapply_change = can_reapply_change;
device_class->complete_connection = complete_connection;