summaryrefslogtreecommitdiff
path: root/libnm-core
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core')
-rw-r--r--libnm-core/nm-connection.c15
-rw-r--r--libnm-core/nm-setting-vlan.c14
2 files changed, 27 insertions, 2 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index ce6f405c35..08edec70c8 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -986,6 +986,18 @@ _normalize_team_port_config (NMConnection *self, GHashTable *parameters)
return FALSE;
}
+static gboolean
+_normalize_required_settings (NMConnection *self, GHashTable *parameters)
+{
+ if (nm_connection_get_setting_vlan (self)) {
+ if (!nm_connection_get_setting_wired (self)) {
+ nm_connection_add_setting (self, nm_setting_wired_new ());
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
/**
* nm_connection_verify:
* @connection: the #NMConnection to verify
@@ -1233,8 +1245,9 @@ nm_connection_normalize (NMConnection *connection,
was_modified |= _normalize_connection_uuid (connection);
was_modified |= _normalize_connection_type (connection);
was_modified |= _normalize_connection_slave_type (connection);
- was_modified |= _normalize_ethernet_link_neg (connection);
+ was_modified |= _normalize_required_settings (connection, parameters);
was_modified |= _normalize_ip_config (connection, parameters);
+ was_modified |= _normalize_ethernet_link_neg (connection);
was_modified |= _normalize_infiniband_mtu (connection, parameters);
was_modified |= _normalize_bond_mode (connection, parameters);
was_modified |= _normalize_wireless_mac_address_randomization (connection, parameters);
diff --git a/libnm-core/nm-setting-vlan.c b/libnm-core/nm-setting-vlan.c
index 6126478479..bbda72d7bb 100644
--- a/libnm-core/nm-setting-vlan.c
+++ b/libnm-core/nm-setting-vlan.c
@@ -600,7 +600,7 @@ nm_setting_vlan_init (NMSettingVlan *setting)
{
}
-static gboolean
+static int
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
@@ -681,6 +681,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
return FALSE;
}
+ if (connection && !s_wired) {
+ /* technically, a VLAN setting does not require an ethernet setting. However,
+ * the ifcfg-rh reader always adds a ethernet setting when reading a vlan setting.
+ * Thus, in order to be consistent, always add one via normalization. */
+ g_set_error_literal (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
+ _("vlan setting should have a ethernet setting as well"));
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_FLAGS);
+ return NM_SETTING_VERIFY_NORMALIZABLE;
+ }
+
return TRUE;
}