summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-05-15 09:49:06 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2020-05-15 09:49:06 +0200
commit2d8c87e22e66b9076c83dd25e17529c76d8986f4 (patch)
tree0ce576e9bdae78b554bf83fea4007a96ed811401
parent623cb3dc871e5a15e46eb37a6c237fb1fb1ca27f (diff)
parentfa4fbd3333989dc2f5abc865a95b5a39ca9dba09 (diff)
downloadNetworkManager-2d8c87e22e66b9076c83dd25e17529c76d8986f4.tar.gz
ip-tunnel: merge branch 'bg/ip-tunnel-cloned-mac-rh1832170'
https://bugzilla.redhat.com/show_bug.cgi?id=1832170 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/503
-rw-r--r--libnm-core/nm-core-internal.h5
-rw-r--r--libnm-core/nm-setting-ip-tunnel.c12
-rw-r--r--src/devices/nm-device-ip-tunnel.c35
-rw-r--r--src/platform/nm-platform.h4
-rw-r--r--src/platform/tests/test-common.c2
5 files changed, 43 insertions, 15 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index 57f46f94be..00645a7618 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -927,4 +927,9 @@ gboolean _nmtst_variant_attribute_spec_assert_sorted (const NMVariantAttributeSp
const NMVariantAttributeSpec *_nm_variant_attribute_spec_find_binary_search (const NMVariantAttributeSpec *const*array,
gsize len,
const char *name);
+
+/*****************************************************************************/
+
+gboolean _nm_ip_tunnel_mode_is_layer2 (NMIPTunnelMode mode);
+
#endif
diff --git a/libnm-core/nm-setting-ip-tunnel.c b/libnm-core/nm-setting-ip-tunnel.c
index f6690e8b5f..5db2dde59b 100644
--- a/libnm-core/nm-setting-ip-tunnel.c
+++ b/libnm-core/nm-setting-ip-tunnel.c
@@ -291,6 +291,14 @@ nm_setting_ip_tunnel_get_flags (NMSettingIPTunnel *setting)
/*****************************************************************************/
+gboolean
+_nm_ip_tunnel_mode_is_layer2 (NMIPTunnelMode mode)
+{
+ return NM_IN_SET (mode,
+ NM_IP_TUNNEL_MODE_GRETAP,
+ NM_IP_TUNNEL_MODE_IP6GRETAP);
+}
+
static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
@@ -444,9 +452,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
}
if ( nm_connection_get_setting_wired (connection)
- && !NM_IN_SET (priv->mode,
- NM_IP_TUNNEL_MODE_GRETAP,
- NM_IP_TUNNEL_MODE_IP6GRETAP)) {
+ && !_nm_ip_tunnel_mode_is_layer2 (priv->mode)) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c
index 0a33c82e9b..2c9a605039 100644
--- a/src/devices/nm-device-ip-tunnel.c
+++ b/src/devices/nm-device-ip-tunnel.c
@@ -667,7 +667,8 @@ create_and_realize (NMDevice *device,
mode = nm_setting_ip_tunnel_get_mode (s_ip_tunnel);
- if ( nm_device_hw_addr_get_cloned (device,
+ if ( _nm_ip_tunnel_mode_is_layer2 (mode)
+ && nm_device_hw_addr_get_cloned (device,
connection,
FALSE,
&hwaddr,
@@ -686,13 +687,6 @@ create_and_realize (NMDevice *device,
g_return_val_if_reached (FALSE);
}
- if (NM_IN_SET (mode, NM_IP_TUNNEL_MODE_GRE)) {
- g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED,
- "Invalid hardware address '%s' for tunnel type",
- hwaddr);
- return FALSE;
- }
-
mac_address_valid = TRUE;
}
@@ -849,7 +843,10 @@ create_and_realize (NMDevice *device,
lnk_ip6tnl.is_tap = (mode == NM_IP_TUNNEL_MODE_IP6GRETAP);
r = nm_platform_link_ip6gre_add (nm_device_get_platform (device),
- iface, &lnk_ip6tnl, out_plink);
+ iface,
+ mac_address_valid ? mac_address : NULL,
+ mac_address_valid ? ETH_ALEN : 0,
+ &lnk_ip6tnl, out_plink);
} else {
lnk_ip6tnl.proto = nm_setting_ip_tunnel_get_mode (s_ip_tunnel) == NM_IP_TUNNEL_MODE_IPIP6
? IPPROTO_IPIP
@@ -929,6 +926,23 @@ can_reapply_change (NMDevice *device,
error);
}
+static NMActStageReturn
+act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
+{
+ NMDeviceIPTunnel *self = NM_DEVICE_IP_TUNNEL (device);
+ NMDeviceIPTunnelPrivate *priv = NM_DEVICE_IP_TUNNEL_GET_PRIVATE (self);
+
+ if ( _nm_ip_tunnel_mode_is_layer2 (priv->mode)
+ && !nm_device_hw_addr_set_cloned (device,
+ nm_device_get_applied_connection (device),
+ FALSE)) {
+ *out_failure_reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
+ return NM_ACT_STAGE_RETURN_FAILURE;
+ }
+
+ return NM_ACT_STAGE_RETURN_SUCCESS;
+}
+
/*****************************************************************************/
static void
@@ -1078,7 +1092,8 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass)
NM_LINK_TYPE_IPIP,
NM_LINK_TYPE_SIT);
- device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
+
+ 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;
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 931ab16391..260b5356ff 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -1511,13 +1511,15 @@ nm_platform_link_ip6tnl_add (NMPlatform *self,
static inline int
nm_platform_link_ip6gre_add (NMPlatform *self,
const char *name,
+ const void *address,
+ size_t address_len,
const NMPlatformLnkIp6Tnl *props,
const NMPlatformLink **out_link)
{
g_return_val_if_fail (props, -NME_BUG);
g_return_val_if_fail (props->is_gre, -NME_BUG);
- return nm_platform_link_add (self, props->is_tap ? NM_LINK_TYPE_IP6GRETAP : NM_LINK_TYPE_IP6GRE, name, 0, NULL, 0, props, out_link);
+ return nm_platform_link_add (self, props->is_tap ? NM_LINK_TYPE_IP6GRETAP : NM_LINK_TYPE_IP6GRE, name, 0, address, address_len, props, out_link);
}
static inline int
diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c
index f393ae933e..f28dfa3a72 100644
--- a/src/platform/tests/test-common.c
+++ b/src/platform/tests/test-common.c
@@ -1380,7 +1380,7 @@ nmtstp_link_ip6gre_add (NMPlatform *platform,
100);
}
} else
- success = NMTST_NM_ERR_SUCCESS (nm_platform_link_ip6gre_add (platform, name, lnk, &pllink));
+ success = NMTST_NM_ERR_SUCCESS (nm_platform_link_ip6gre_add (platform, name, NULL, 0, lnk, &pllink));
_assert_pllink (platform, success, pllink, name, lnk->is_tap ? NM_LINK_TYPE_IP6GRETAP : NM_LINK_TYPE_IP6GRE);