mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-19 15:31:46 +01:00
core/connection: allow address for ovs interfaces
This commit is contained in:
parent
830a5a14cb
commit
1f25ae08fb
1 changed files with 49 additions and 36 deletions
|
|
@ -812,10 +812,21 @@ _normalize_ethernet_link_neg (NMConnection *self)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_without_ip_config (NMConnection *self)
|
||||
{
|
||||
const char *connection_type = nm_connection_get_connection_type (self);
|
||||
|
||||
g_return_val_if_fail (connection_type, FALSE);
|
||||
if (strcmp (connection_type, NM_SETTING_OVS_INTERFACE_SETTING_NAME) == 0)
|
||||
return FALSE;
|
||||
|
||||
return !!nm_setting_connection_get_master (nm_connection_get_setting_connection (self));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_normalize_ip_config (NMConnection *self, GHashTable *parameters)
|
||||
{
|
||||
NMSettingConnection *s_con = nm_connection_get_setting_connection (self);
|
||||
const char *default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
|
||||
const char *default_ip6_method = NULL;
|
||||
NMSettingIPConfig *s_ip4, *s_ip6;
|
||||
|
|
@ -833,7 +844,7 @@ _normalize_ip_config (NMConnection *self, GHashTable *parameters)
|
|||
s_ip6 = nm_connection_get_setting_ip6_config (self);
|
||||
s_proxy = nm_connection_get_setting_proxy (self);
|
||||
|
||||
if (nm_setting_connection_get_master (s_con)) {
|
||||
if (_without_ip_config (self)) {
|
||||
/* Slave connections don't have IP configuration. */
|
||||
|
||||
if (s_ip4)
|
||||
|
|
@ -1289,40 +1300,42 @@ _nm_connection_verify (NMConnection *connection, GError **error)
|
|||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
s_proxy = nm_connection_get_setting_proxy (connection);
|
||||
|
||||
if (nm_setting_connection_get_master (s_con)) {
|
||||
if ( NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS,
|
||||
NM_SETTING_VERIFY_NORMALIZABLE)
|
||||
&& (s_ip4 || s_ip6 || s_proxy)) {
|
||||
g_clear_error (&normalizable_error);
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_SETTING,
|
||||
_("setting not allowed in slave connection"));
|
||||
g_prefix_error (&normalizable_error, "%s: ",
|
||||
s_ip4
|
||||
? NM_SETTING_IP4_CONFIG_SETTING_NAME
|
||||
: (s_ip6
|
||||
? NM_SETTING_IP6_CONFIG_SETTING_NAME
|
||||
: NM_SETTING_PROXY_SETTING_NAME));
|
||||
/* having a slave with IP config *was* and is a verify() error. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
||||
}
|
||||
} else {
|
||||
if ( NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS)
|
||||
&& (!s_ip4 || !s_ip6 || !s_proxy)) {
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||
_("setting is required for non-slave connections"));
|
||||
g_prefix_error (&normalizable_error, "%s: ",
|
||||
!s_ip4
|
||||
? NM_SETTING_IP4_CONFIG_SETTING_NAME
|
||||
: (!s_ip6
|
||||
? NM_SETTING_IP6_CONFIG_SETTING_NAME
|
||||
: NM_SETTING_PROXY_SETTING_NAME));
|
||||
/* having a master without IP config was not a verify() error, accept
|
||||
* it for backward compatibility. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
nm_assert (normalizable_error_type != NM_SETTING_VERIFY_ERROR);
|
||||
if (NM_IN_SET (normalizable_error_type, NM_SETTING_VERIFY_SUCCESS,
|
||||
NM_SETTING_VERIFY_NORMALIZABLE)) {
|
||||
if (_without_ip_config (connection)) {
|
||||
if (s_ip4 || s_ip6 || s_proxy) {
|
||||
g_clear_error (&normalizable_error);
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_SETTING,
|
||||
_("setting not allowed in slave connection"));
|
||||
g_prefix_error (&normalizable_error, "%s: ",
|
||||
s_ip4
|
||||
? NM_SETTING_IP4_CONFIG_SETTING_NAME
|
||||
: (s_ip6
|
||||
? NM_SETTING_IP6_CONFIG_SETTING_NAME
|
||||
: NM_SETTING_PROXY_SETTING_NAME));
|
||||
/* having a slave with IP config *was* and is a verify() error. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
||||
}
|
||||
} else {
|
||||
if ( normalizable_error_type == NM_SETTING_VERIFY_SUCCESS
|
||||
&& (!s_ip4 || !s_ip6 || !s_proxy)) {
|
||||
g_set_error_literal (&normalizable_error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_SETTING,
|
||||
_("setting is required for non-slave connections"));
|
||||
g_prefix_error (&normalizable_error, "%s: ",
|
||||
!s_ip4
|
||||
? NM_SETTING_IP4_CONFIG_SETTING_NAME
|
||||
: (!s_ip6
|
||||
? NM_SETTING_IP6_CONFIG_SETTING_NAME
|
||||
: NM_SETTING_PROXY_SETTING_NAME));
|
||||
/* having a master without IP config was not a verify() error, accept
|
||||
* it for backward compatibility. */
|
||||
normalizable_error_type = NM_SETTING_VERIFY_NORMALIZABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue