From 676fe327d4c1fe0d11dae41b39e232ea64f4e1ea Mon Sep 17 00:00:00 2001 From: barinet Date: Fri, 9 Oct 2020 09:40:08 +0000 Subject: [PATCH] libnm,core: allow VXLAN connections without an explicit remote VTEP [thaller@redhat.com: squashed commits, resolve merge conflict and coding style] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/645 --- libnm-core/nm-setting-vxlan.c | 38 ++++++++++++++++------------------- src/devices/nm-device-vxlan.c | 8 +++++--- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/libnm-core/nm-setting-vxlan.c b/libnm-core/nm-setting-vxlan.c index 213219baaa..3beb5463c6 100644 --- a/libnm-core/nm-setting-vxlan.c +++ b/libnm-core/nm-setting-vxlan.c @@ -315,27 +315,23 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting); int family = AF_UNSPEC; - if (!priv->remote) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property is missing")); - g_prefix_error(error, "%s.%s: ", NM_SETTING_VXLAN_SETTING_NAME, NM_SETTING_VXLAN_REMOTE); - return FALSE; - } - - if (nm_utils_ipaddr_is_valid(AF_INET, priv->remote)) - family = AF_INET; - else if (nm_utils_ipaddr_is_valid(AF_INET6, priv->remote)) - family = AF_INET6; - else { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' is not a valid IP address"), - priv->remote); - g_prefix_error(error, "%s.%s: ", NM_SETTING_VXLAN_SETTING_NAME, NM_SETTING_VXLAN_REMOTE); - return FALSE; + if (priv->remote) { + if (nm_utils_ipaddr_is_valid(AF_INET, priv->remote)) + family = AF_INET; + else if (nm_utils_ipaddr_is_valid(AF_INET6, priv->remote)) + family = AF_INET6; + else { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid IP address"), + priv->remote); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_VXLAN_SETTING_NAME, + NM_SETTING_VXLAN_REMOTE); + return FALSE; + } } if (priv->local) { diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 4522662449..2ed66a644d 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -180,9 +180,11 @@ create_and_realize(NMDevice * device, } str = nm_setting_vxlan_get_remote(s_vxlan); - if (!nm_utils_parse_inaddr_bin(AF_INET, str, NULL, &props.group) - && !nm_utils_parse_inaddr_bin(AF_INET6, str, NULL, &props.group6)) - return FALSE; + if (str) { + if (!nm_utils_parse_inaddr_bin(AF_INET, str, NULL, &props.group) + && !nm_utils_parse_inaddr_bin(AF_INET6, str, NULL, &props.group6)) + return FALSE; + } props.tos = nm_setting_vxlan_get_tos(s_vxlan); props.ttl = nm_setting_vxlan_get_ttl(s_vxlan);