mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 12:20:36 +01:00
libnm-core: add ethernet setting for vlan connection
A "vlan" setting can optionally have an ethernet setting. However, ifcfg-rh reader always adds such a setting, because well... Anyway, the result is that writing a VLAN setting without ethernet section will yield a different result on re-read. Let's have normalization add the ethernet setting, so that two we consistently have it present.
This commit is contained in:
parent
53018b92e8
commit
cf213216fd
3 changed files with 28 additions and 5 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8403,8 +8403,6 @@ test_team_reread_slave (void)
|
|||
"permissions=\n"
|
||||
"slave-type=team\n"
|
||||
"\n"
|
||||
"[ethernet]\n"
|
||||
"\n"
|
||||
"[vlan]\n"
|
||||
"egress-priority-map=\n"
|
||||
"flags=1\n"
|
||||
|
|
@ -8427,7 +8425,7 @@ test_team_reread_slave (void)
|
|||
NM_SETTING_VLAN_PARENT, "enp31s0f1",
|
||||
NULL);
|
||||
nm_connection_add_setting (connection_2, nm_setting_team_port_new ());
|
||||
nm_connection_add_setting (connection_2, nm_setting_wired_new ());
|
||||
nmtst_connection_normalize (connection_2);
|
||||
|
||||
nmtst_assert_connection_equals (connection_1, FALSE, connection_2, FALSE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue