summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-08-05 14:13:42 -0400
committerDan Winship <danw@gnome.org>2014-09-03 15:24:03 -0400
commita56d56ab105d5cfbcd61e066f782926341fe7bda (patch)
treeadedbf2bdabbc6bba9a209a5c4666d5dc6330183
parent95bad65aaaf0ea390b761cb929624488ebcde65a (diff)
downloadNetworkManager-a56d56ab105d5cfbcd61e066f782926341fe7bda.tar.gz
all: stop using virtual interface-name properties
The virtual :interface-name properties (eg, NMDeviceBond:interface-name) are deprecated in favor of NMSettingConnection:interface-name, and nm_connection_verify() ensures that their values are kept in sync. So (a) there is no need to set those properties when we can just set NMSettingConnection:interface-name instead, and (b) we can replace any calls to the setting-specific get_interface_name() methods with nm_connection_get_interface_name() or nm_setting_connection_get_interface_name().
-rw-r--r--clients/cli/connections.c94
-rw-r--r--clients/cli/settings.c102
-rw-r--r--clients/tui/nm-editor-bindings.c11
-rw-r--r--clients/tui/nm-editor-bindings.h3
-rw-r--r--clients/tui/nmt-page-bond.c6
-rw-r--r--clients/tui/nmt-page-bridge.c6
-rw-r--r--clients/tui/nmt-page-team.c6
-rw-r--r--clients/tui/nmt-page-vlan.c8
-rw-r--r--libnm-core/nm-setting.c11
-rw-r--r--libnm-core/tests/test-general.c4
-rw-r--r--libnm/nm-device-bond.c2
-rw-r--r--libnm/nm-device-bridge.c2
-rw-r--r--libnm/nm-device-team.c2
-rw-r--r--libnm/nm-device-vlan.c2
-rw-r--r--src/devices/nm-device-bond.c16
-rw-r--r--src/devices/nm-device-bridge.c16
-rw-r--r--src/devices/nm-device-vlan.c1
-rw-r--r--src/devices/team/nm-device-team.c16
-rw-r--r--src/settings/plugins/ibft/tests/test-ibft.c1
-rw-r--r--src/settings/plugins/ifcfg-rh/reader.c8
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c64
-rw-r--r--src/settings/plugins/ifcfg-rh/writer.c8
-rw-r--r--src/settings/plugins/keyfile/reader.c19
-rw-r--r--src/settings/plugins/keyfile/tests/test-keyfile.c2
24 files changed, 172 insertions, 238 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 21befc31bf..7394a6e15a 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -2685,34 +2685,24 @@ add_ip6_address_to_connection (NMIP6Address *ip6addr, NMConnection *connection)
static char *
unique_master_iface_ifname (GSList *list,
- const char *type,
- const char *ifname_property,
const char *try_name)
{
NMConnection *connection;
- NMSetting *setting;
char *new_name;
unsigned int num = 1;
GSList *iterator = list;
- char *ifname_val = NULL;
+ const char *ifname = NULL;
new_name = g_strdup (try_name);
while (iterator) {
connection = NM_CONNECTION (iterator->data);
- setting = nm_connection_get_setting_by_name (connection, type);
- if (!setting) {
- iterator = g_slist_next (iterator);
- continue;
- }
-
- g_object_get (setting, ifname_property, &ifname_val, NULL);
- if (g_strcmp0 (new_name, ifname_val) == 0) {
+ ifname = nm_connection_get_interface_name (connection);
+ if (g_strcmp0 (new_name, ifname) == 0) {
g_free (new_name);
new_name = g_strdup_printf ("%s%d", try_name, num++);
iterator = list;
} else
iterator = g_slist_next (iterator);
- g_free (ifname_val);
}
return new_name;
}
@@ -4144,7 +4134,6 @@ cleanup_bt:
} else if (!strcmp (con_type, NM_SETTING_VLAN_SETTING_NAME)) {
/* Build up the settings required for 'vlan' */
gboolean success = FALSE;
- const char *ifname = NULL;
const char *parent = NULL;
char *parent_ask = NULL;
const char *vlan_id = NULL;
@@ -4211,9 +4200,6 @@ cleanup_bt:
if (ask)
do_questionnaire_vlan (&mtu, &flags, &ingress, &egress);
- /* ifname is taken from connection's ifname */
- ifname = nm_setting_connection_get_interface_name (s_con);
-
if (!check_and_convert_mtu (mtu, &mtu_int, error))
goto cleanup_vlan;
if (!check_and_convert_vlan_flags (flags, &flags_int, error))
@@ -4242,8 +4228,6 @@ cleanup_bt:
if (!addr_array)
g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, parent, NULL);
- if (ifname)
- g_object_set (s_vlan, NM_SETTING_VLAN_INTERFACE_NAME, ifname, NULL);
g_object_set (s_vlan, NM_SETTING_VLAN_ID, id, NULL);
if (flags)
@@ -4271,7 +4255,6 @@ cleanup_vlan:
} else if (!strcmp (con_type, NM_SETTING_BOND_SETTING_NAME)) {
/* Build up the settings required for 'bond' */
gboolean success = FALSE;
- char *bond_ifname = NULL;
const char *ifname = NULL;
const char *bond_mode_c = NULL;
char *bond_mode = NULL;
@@ -4312,22 +4295,22 @@ cleanup_vlan:
&bond_downdelay, &bond_updelay,
&bond_arpinterval, &bond_arpiptarget);
- /* Use connection's ifname as 'bond' ifname if exists, else generate one */
+ /* Generate ifname if connection doesn't have one */
ifname = nm_setting_connection_get_interface_name (s_con);
- if (!ifname)
- bond_ifname = unique_master_iface_ifname (all_connections,
- NM_SETTING_BOND_SETTING_NAME,
- NM_SETTING_BOND_INTERFACE_NAME,
- "nm-bond");
- else
- bond_ifname = g_strdup (ifname);
+ if (!ifname) {
+ char *bond_ifname = unique_master_iface_ifname (all_connections, "nm-bond");
+
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, bond_ifname,
+ NULL);
+ g_free (bond_ifname);
+ }
/* Add 'bond' setting */
s_bond = (NMSettingBond *) nm_setting_bond_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bond));
/* Set bond options */
- g_object_set (s_bond, NM_SETTING_BOND_INTERFACE_NAME, bond_ifname, NULL);
if (bond_mode) {
GError *err = NULL;
const char *bm;
@@ -4361,7 +4344,6 @@ cleanup_vlan:
success = TRUE;
cleanup_bond:
- g_free (bond_ifname);
g_free (bond_mode);
g_free (bond_primary);
g_free (bond_miimon);
@@ -4420,7 +4402,6 @@ cleanup_bond:
} else if (!strcmp (con_type, NM_SETTING_TEAM_SETTING_NAME)) {
/* Build up the settings required for 'team' */
gboolean success = FALSE;
- char *team_ifname = NULL;
const char *ifname = NULL;
const char *config_c = NULL;
char *config = NULL;
@@ -4436,15 +4417,16 @@ cleanup_bond:
if (ask)
do_questionnaire_team (&config);
- /* Use connection's ifname as 'team' ifname if exists, else generate one */
+ /* Generate ifname if conneciton doesn't have one */
ifname = nm_setting_connection_get_interface_name (s_con);
- if (!ifname)
- team_ifname = unique_master_iface_ifname (all_connections,
- NM_SETTING_TEAM_SETTING_NAME,
- NM_SETTING_TEAM_INTERFACE_NAME,
- "nm-team");
- else
- team_ifname = g_strdup (ifname);
+ if (!ifname) {
+ char *team_ifname = unique_master_iface_ifname (all_connections, "nm-team");
+
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, team_ifname,
+ NULL);
+ g_free (team_ifname);
+ }
/* Add 'team' setting */
s_team = (NMSettingTeam *) nm_setting_team_new ();
@@ -4456,12 +4438,10 @@ cleanup_bond:
}
/* Set team options */
- g_object_set (s_team, NM_SETTING_TEAM_INTERFACE_NAME, team_ifname, NULL);
g_object_set (s_team, NM_SETTING_TEAM_CONFIG, json, NULL);
success = TRUE;
cleanup_team:
- g_free (team_ifname);
g_free (config);
g_free (json);
if (!success)
@@ -4543,7 +4523,6 @@ cleanup_team_slave:
} else if (!strcmp (con_type, NM_SETTING_BRIDGE_SETTING_NAME)) {
/* Build up the settings required for 'bridge' */
gboolean success = FALSE;
- char *bridge_ifname = NULL;
const char *ifname = NULL;
const char *stp_c = NULL;
char *stp = NULL;
@@ -4587,15 +4566,16 @@ cleanup_team_slave:
do_questionnaire_bridge (&stp, &priority, &fwd_delay, &hello_time,
&max_age, &ageing_time, &mac);
- /* Use connection's ifname as 'bridge' ifname if exists, else generate one */
+ /* Generate ifname if conneciton doesn't have one */
ifname = nm_setting_connection_get_interface_name (s_con);
- if (!ifname)
- bridge_ifname = unique_master_iface_ifname (all_connections,
- NM_SETTING_BRIDGE_SETTING_NAME,
- NM_SETTING_BRIDGE_INTERFACE_NAME,
- "nm-bridge");
- else
- bridge_ifname = g_strdup (ifname);
+ if (!ifname) {
+ char *bridge_ifname = unique_master_iface_ifname (all_connections, "nm-bridge");
+
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, bridge_ifname,
+ NULL);
+ g_free (bridge_ifname);
+ }
if (stp) {
GError *tmp_err = NULL;
@@ -4636,7 +4616,6 @@ cleanup_team_slave:
goto cleanup_bridge;
/* Set bridge options */
- g_object_set (s_bridge, NM_SETTING_BRIDGE_INTERFACE_NAME, bridge_ifname, NULL);
if (stp)
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, stp_bool, NULL);
if (priority)
@@ -4654,7 +4633,6 @@ cleanup_team_slave:
success = TRUE;
cleanup_bridge:
- g_free (bridge_ifname);
g_free (stp);
g_free (priority);
g_free (fwd_delay);
@@ -7745,16 +7723,16 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection)
/* Set a sensible bond/team/bridge interface name by default */
if (g_strcmp0 (con_type, NM_SETTING_BOND_SETTING_NAME) == 0)
- g_object_set (NM_SETTING_BOND (base_setting),
- NM_SETTING_BOND_INTERFACE_NAME, "nm-bond",
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, "nm-bond",
NULL);
if (g_strcmp0 (con_type, NM_SETTING_TEAM_SETTING_NAME) == 0)
- g_object_set (NM_SETTING_TEAM (base_setting),
- NM_SETTING_TEAM_INTERFACE_NAME, "nm-team",
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, "nm-team",
NULL);
if (g_strcmp0 (con_type, NM_SETTING_BRIDGE_SETTING_NAME) == 0)
- g_object_set (NM_SETTING_BRIDGE (base_setting),
- NM_SETTING_BRIDGE_INTERFACE_NAME, "nm-bridge",
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, "nm-bridge",
NULL);
/* Set sensible initial VLAN values */
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 3275c4793e..f91fe9ba31 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -527,28 +527,24 @@ NmcOutputField nmc_fields_setting_infiniband[] = {
/* Available fields for NM_SETTING_BOND_SETTING_NAME */
NmcOutputField nmc_fields_setting_bond[] = {
SETTING_FIELD ("name", 8), /* 0 */
- SETTING_FIELD (NM_SETTING_BOND_INTERFACE_NAME, 15), /* 1 */
- SETTING_FIELD (NM_SETTING_BOND_OPTIONS, 30), /* 2 */
+ SETTING_FIELD (NM_SETTING_BOND_OPTIONS, 30), /* 1 */
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
};
#define NMC_FIELDS_SETTING_BOND_ALL "name"","\
- NM_SETTING_BOND_INTERFACE_NAME","\
NM_SETTING_BOND_OPTIONS
#define NMC_FIELDS_SETTING_BOND_COMMON NMC_FIELDS_SETTING_BOND_ALL
/* Available fields for NM_SETTING_VLAN_SETTING_NAME */
NmcOutputField nmc_fields_setting_vlan[] = {
SETTING_FIELD ("name", 6), /* 0 */
- SETTING_FIELD (NM_SETTING_VLAN_INTERFACE_NAME, 15), /* 1 */
- SETTING_FIELD (NM_SETTING_VLAN_PARENT, 8), /* 2 */
- SETTING_FIELD (NM_SETTING_VLAN_ID, 6), /* 3 */
- SETTING_FIELD (NM_SETTING_VLAN_FLAGS, 45), /* 4 */
- SETTING_FIELD (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, 22), /* 5 */
- SETTING_FIELD (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, 22), /* 6 */
+ SETTING_FIELD (NM_SETTING_VLAN_PARENT, 8), /* 1 */
+ SETTING_FIELD (NM_SETTING_VLAN_ID, 6), /* 2 */
+ SETTING_FIELD (NM_SETTING_VLAN_FLAGS, 45), /* 3 */
+ SETTING_FIELD (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, 22), /* 4 */
+ SETTING_FIELD (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, 22), /* 5 */
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
};
#define NMC_FIELDS_SETTING_VLAN_ALL "name"","\
- NM_SETTING_VLAN_INTERFACE_NAME","\
NM_SETTING_VLAN_PARENT","\
NM_SETTING_VLAN_ID","\
NM_SETTING_VLAN_FLAGS","\
@@ -559,18 +555,16 @@ NmcOutputField nmc_fields_setting_vlan[] = {
/* Available fields for NM_SETTING_BRIDGE_SETTING_NAME */
NmcOutputField nmc_fields_setting_bridge[] = {
SETTING_FIELD ("name", 8), /* 0 */
- SETTING_FIELD (NM_SETTING_BRIDGE_INTERFACE_NAME, 15), /* 1 */
- SETTING_FIELD (NM_SETTING_BRIDGE_MAC_ADDRESS, 19), /* 2 */
- SETTING_FIELD (NM_SETTING_BRIDGE_STP, 5), /* 3 */
- SETTING_FIELD (NM_SETTING_BRIDGE_PRIORITY, 6), /* 4 */
- SETTING_FIELD (NM_SETTING_BRIDGE_FORWARD_DELAY, 6), /* 5 */
- SETTING_FIELD (NM_SETTING_BRIDGE_HELLO_TIME, 6), /* 6 */
- SETTING_FIELD (NM_SETTING_BRIDGE_MAX_AGE, 6), /* 7 */
- SETTING_FIELD (NM_SETTING_BRIDGE_AGEING_TIME, 6), /* 8 */
+ SETTING_FIELD (NM_SETTING_BRIDGE_MAC_ADDRESS, 19), /* 1 */
+ SETTING_FIELD (NM_SETTING_BRIDGE_STP, 5), /* 2 */
+ SETTING_FIELD (NM_SETTING_BRIDGE_PRIORITY, 6), /* 3 */
+ SETTING_FIELD (NM_SETTING_BRIDGE_FORWARD_DELAY, 6), /* 4 */
+ SETTING_FIELD (NM_SETTING_BRIDGE_HELLO_TIME, 6), /* 5 */
+ SETTING_FIELD (NM_SETTING_BRIDGE_MAX_AGE, 6), /* 6 */
+ SETTING_FIELD (NM_SETTING_BRIDGE_AGEING_TIME, 6), /* 7 */
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
};
#define NMC_FIELDS_SETTING_BRIDGE_ALL "name"","\
- NM_SETTING_BRIDGE_INTERFACE_NAME","\
NM_SETTING_BRIDGE_MAC_ADDRESS","\
NM_SETTING_BRIDGE_STP","\
NM_SETTING_BRIDGE_PRIORITY","\
@@ -597,12 +591,10 @@ NmcOutputField nmc_fields_setting_bridge_port[] = {
/* Available fields for NM_SETTING_TEAM_SETTING_NAME */
NmcOutputField nmc_fields_setting_team[] = {
SETTING_FIELD ("name", 8), /* 0 */
- SETTING_FIELD (NM_SETTING_TEAM_INTERFACE_NAME, 15), /* 1 */
- SETTING_FIELD (NM_SETTING_TEAM_CONFIG, 30), /* 2 */
+ SETTING_FIELD (NM_SETTING_TEAM_CONFIG, 30), /* 1 */
{NULL, NULL, 0, NULL, FALSE, FALSE, 0}
};
#define NMC_FIELDS_SETTING_TEAM_ALL "name"","\
- NM_SETTING_TEAM_INTERFACE_NAME","\
NM_SETTING_TEAM_CONFIG
#define NMC_FIELDS_SETTING_TEAM_COMMON NMC_FIELDS_SETTING_TEAM_ALL
@@ -977,9 +969,6 @@ DEFINE_GETTER (nmc_property_adsl_get_vci, NM_SETTING_ADSL_VCI)
DEFINE_HWADDR_GETTER (nmc_property_bluetooth_get_bdaddr, NM_SETTING_BLUETOOTH_BDADDR)
DEFINE_GETTER (nmc_property_bluetooth_get_type, NM_SETTING_BLUETOOTH_TYPE)
-/* --- NM_SETTING_BOND_SETTING_NAME property get functions --- */
-DEFINE_GETTER (nmc_property_bond_get_interface_name, NM_SETTING_BOND_INTERFACE_NAME)
-
static char *
nmc_property_bond_get_options (NMSetting *setting)
{
@@ -1000,7 +989,6 @@ nmc_property_bond_get_options (NMSetting *setting)
}
/* --- NM_SETTING_BRIDGE_SETTING_NAME property get functions --- */
-DEFINE_GETTER (nmc_property_bridge_get_interface_name, NM_SETTING_BRIDGE_INTERFACE_NAME)
DEFINE_HWADDR_GETTER (nmc_property_bridge_get_mac_address, NM_SETTING_BRIDGE_MAC_ADDRESS)
DEFINE_GETTER (nmc_property_bridge_get_stp, NM_SETTING_BRIDGE_STP)
DEFINE_GETTER (nmc_property_bridge_get_priority, NM_SETTING_BRIDGE_PRIORITY)
@@ -1015,7 +1003,6 @@ DEFINE_GETTER (nmc_property_bridge_port_get_path_cost, NM_SETTING_BRIDGE_PORT_PA
DEFINE_GETTER (nmc_property_bridge_port_get_hairpin_mode, NM_SETTING_BRIDGE_PORT_HAIRPIN_MODE)
/* --- NM_SETTING_TEAM_SETTING_NAME property get functions --- */
-DEFINE_GETTER (nmc_property_team_get_interface_name, NM_SETTING_TEAM_INTERFACE_NAME)
DEFINE_GETTER (nmc_property_team_get_config, NM_SETTING_TEAM_CONFIG)
/* --- NM_SETTING_TEAM_PORT_SETTING_NAME property get functions --- */
@@ -1310,7 +1297,6 @@ DEFINE_GETTER (nmc_property_serial_get_stopbits, NM_SETTING_SERIAL_STOPBITS)
DEFINE_GETTER (nmc_property_serial_get_send_delay, NM_SETTING_SERIAL_SEND_DELAY)
/* --- NM_SETTING_VLAN_SETTING_NAME property get functions --- */
-DEFINE_GETTER (nmc_property_vlan_get_interface_name, NM_SETTING_VLAN_INTERFACE_NAME)
DEFINE_GETTER (nmc_property_vlan_get_parent, NM_SETTING_VLAN_PARENT)
DEFINE_GETTER (nmc_property_vlan_get_id, NM_SETTING_VLAN_ID)
@@ -4829,13 +4815,6 @@ nmc_properties_init (void)
NULL);
/* Add editable properties for NM_SETTING_BOND_SETTING_NAME */
- nmc_add_prop_funcs (GLUE (BOND, INTERFACE_NAME),
- nmc_property_bond_get_interface_name,
- nmc_property_set_ifname,
- NULL,
- NULL,
- NULL,
- NULL);
nmc_add_prop_funcs (GLUE (BOND, OPTIONS),
nmc_property_bond_get_options,
nmc_property_bond_set_options,
@@ -4845,13 +4824,6 @@ nmc_properties_init (void)
NULL);
/* Add editable properties for NM_SETTING_BRIDGE_SETTING_NAME */
- nmc_add_prop_funcs (GLUE (BRIDGE, INTERFACE_NAME),
- nmc_property_bridge_get_interface_name,
- nmc_property_set_ifname,
- NULL,
- NULL,
- NULL,
- NULL);
nmc_add_prop_funcs (GLUE (BRIDGE, MAC_ADDRESS),
nmc_property_bridge_get_mac_address,
nmc_property_set_mac,
@@ -5641,13 +5613,6 @@ nmc_properties_init (void)
NULL);
/* Add editable properties for NM_SETTING_TEAM_SETTING_NAME */
- nmc_add_prop_funcs (GLUE (TEAM, INTERFACE_NAME),
- nmc_property_team_get_interface_name,
- nmc_property_set_ifname,
- NULL,
- NULL,
- NULL,
- NULL);
nmc_add_prop_funcs (GLUE (TEAM, CONFIG),
nmc_property_team_get_config,
nmc_property_team_set_config,
@@ -5666,13 +5631,6 @@ nmc_properties_init (void)
NULL);
/* Add editable properties for NM_SETTING_VLAN_SETTING_NAME */
- nmc_add_prop_funcs (GLUE (VLAN, INTERFACE_NAME),
- nmc_property_vlan_get_interface_name,
- nmc_property_set_ifname,
- NULL,
- NULL,
- NULL,
- NULL);
nmc_add_prop_funcs (GLUE (VLAN, PARENT),
nmc_property_vlan_get_parent,
nmc_property_set_string,
@@ -6957,8 +6915,7 @@ setting_bond_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
- set_val_str (arr, 1, nmc_property_bond_get_interface_name (setting));
- set_val_str (arr, 2, nmc_property_bond_get_options (setting));
+ set_val_str (arr, 1, nmc_property_bond_get_options (setting));
g_ptr_array_add (nmc->output_data, arr);
print_data (nmc); /* Print all data */
@@ -6984,12 +6941,11 @@ setting_vlan_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
- set_val_str (arr, 1, nmc_property_vlan_get_interface_name (setting));
- set_val_str (arr, 2, nmc_property_vlan_get_parent (setting));
- set_val_str (arr, 3, nmc_property_vlan_get_id (setting));
- set_val_str (arr, 4, nmc_property_vlan_get_flags (setting));
- set_val_str (arr, 5, nmc_property_vlan_get_ingress_priority_map (setting));
- set_val_str (arr, 6, nmc_property_vlan_get_egress_priority_map (setting));
+ set_val_str (arr, 1, nmc_property_vlan_get_parent (setting));
+ set_val_str (arr, 2, nmc_property_vlan_get_id (setting));
+ set_val_str (arr, 3, nmc_property_vlan_get_flags (setting));
+ set_val_str (arr, 4, nmc_property_vlan_get_ingress_priority_map (setting));
+ set_val_str (arr, 5, nmc_property_vlan_get_egress_priority_map (setting));
g_ptr_array_add (nmc->output_data, arr);
print_data (nmc); /* Print all data */
@@ -7047,14 +7003,13 @@ setting_bridge_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
- set_val_str (arr, 1, nmc_property_bridge_get_interface_name (setting));
- set_val_str (arr, 2, nmc_property_bridge_get_mac_address (setting));
- set_val_str (arr, 3, nmc_property_bridge_get_stp (setting));
- set_val_str (arr, 4, nmc_property_bridge_get_priority (setting));
- set_val_str (arr, 5, nmc_property_bridge_get_forward_delay (setting));
- set_val_str (arr, 6, nmc_property_bridge_get_hello_time (setting));
- set_val_str (arr, 7, nmc_property_bridge_get_max_age (setting));
- set_val_str (arr, 8, nmc_property_bridge_get_ageing_time (setting));
+ set_val_str (arr, 1, nmc_property_bridge_get_mac_address (setting));
+ set_val_str (arr, 2, nmc_property_bridge_get_stp (setting));
+ set_val_str (arr, 3, nmc_property_bridge_get_priority (setting));
+ set_val_str (arr, 4, nmc_property_bridge_get_forward_delay (setting));
+ set_val_str (arr, 5, nmc_property_bridge_get_hello_time (setting));
+ set_val_str (arr, 6, nmc_property_bridge_get_max_age (setting));
+ set_val_str (arr, 7, nmc_property_bridge_get_ageing_time (setting));
g_ptr_array_add (nmc->output_data, arr);
print_data (nmc); /* Print all data */
@@ -7108,8 +7063,7 @@ setting_team_details (NMSetting *setting, NmCli *nmc, const char *one_prop)
arr = nmc_dup_fields_array (tmpl, tmpl_len, NMC_OF_FLAG_SECTION_PREFIX);
set_val_str (arr, 0, g_strdup (nm_setting_get_name (setting)));
- set_val_str (arr, 1, nmc_property_team_get_interface_name (setting));
- set_val_str (arr, 2, nmc_property_team_get_config (setting));
+ set_val_str (arr, 1, nmc_property_team_get_config (setting));
g_ptr_array_add (nmc->output_data, arr);
print_data (nmc); /* Print all data */
diff --git a/clients/tui/nm-editor-bindings.c b/clients/tui/nm-editor-bindings.c
index 344274eb0b..0325c0a8b8 100644
--- a/clients/tui/nm-editor-bindings.c
+++ b/clients/tui/nm-editor-bindings.c
@@ -1543,6 +1543,7 @@ nm_editor_bind_wireless_security_wep_key (NMSettingWirelessSecurity *s_wsec,
typedef struct {
NMSettingVlan *s_vlan;
+ NMSettingConnection *s_con;
char *last_ifname_parent;
int last_ifname_id;
@@ -1595,7 +1596,7 @@ vlan_settings_changed (GObject *object,
if (binding->updating)
return;
- ifname = nm_setting_vlan_get_interface_name (binding->s_vlan);
+ ifname = nm_setting_connection_get_interface_name (binding->s_con);
parent = nm_setting_vlan_get_parent (binding->s_vlan);
id = nm_setting_vlan_get_id (binding->s_vlan);
@@ -1653,20 +1654,22 @@ vlan_target_destroyed (gpointer user_data,
* two properties automatically.
*/
void
-nm_editor_bind_vlan_name (NMSettingVlan *s_vlan)
+nm_editor_bind_vlan_name (NMSettingVlan *s_vlan,
+ NMSettingConnection *s_con)
{
NMEditorVlanWidgetBinding *binding;
const char *ifname;
binding = g_slice_new0 (NMEditorVlanWidgetBinding);
binding->s_vlan = s_vlan;
+ binding->s_con = s_con;
- g_signal_connect (s_vlan, "notify::" NM_SETTING_VLAN_INTERFACE_NAME,
+ g_signal_connect (s_con, "notify::" NM_SETTING_CONNECTION_INTERFACE_NAME,
G_CALLBACK (vlan_settings_changed), binding);
g_object_weak_ref (G_OBJECT (s_vlan), vlan_target_destroyed, binding);
- ifname = nm_setting_vlan_get_interface_name (s_vlan);
+ ifname = nm_setting_connection_get_interface_name (s_con);
if (!parse_interface_name (ifname, &binding->last_ifname_parent, &binding->last_ifname_id)) {
binding->last_ifname_parent = NULL;
binding->last_ifname_id = 0;
diff --git a/clients/tui/nm-editor-bindings.h b/clients/tui/nm-editor-bindings.h
index e1637f45d7..b595ef03c1 100644
--- a/clients/tui/nm-editor-bindings.h
+++ b/clients/tui/nm-editor-bindings.h
@@ -89,7 +89,8 @@ void nm_editor_bind_wireless_security_wep_key (NMSettingWirelessSecurity
const char *key_selector_property,
GBindingFlags flags);
-void nm_editor_bind_vlan_name (NMSettingVlan *s_vlan);
+void nm_editor_bind_vlan_name (NMSettingVlan *s_vlan,
+ NMSettingConnection *s_con);
G_END_DECLS
diff --git a/clients/tui/nmt-page-bond.c b/clients/tui/nmt-page-bond.c
index 55a6ffeebb..5ea12ffc3e 100644
--- a/clients/tui/nmt-page-bond.c
+++ b/clients/tui/nmt-page-bond.c
@@ -334,7 +334,6 @@ nmt_page_bond_constructed (GObject *object)
{
NmtPageBond *bond = NMT_PAGE_BOND (object);
NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond);
- NmtDeviceEntry *deventry;
NmtPageGrid *grid;
NMSettingBond *s_bond;
NmtNewtWidget *widget, *label;
@@ -348,11 +347,6 @@ nmt_page_bond_constructed (GObject *object)
}
priv->s_bond = s_bond;
- deventry = nmt_page_device_get_device_entry (NMT_PAGE_DEVICE (object));
- g_object_bind_property (s_bond, NM_SETTING_BOND_INTERFACE_NAME,
- deventry, "interface-name",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
grid = NMT_PAGE_GRID (bond);
widget = nmt_newt_separator_new ();
diff --git a/clients/tui/nmt-page-bridge.c b/clients/tui/nmt-page-bridge.c
index 713d83507e..3769383ae0 100644
--- a/clients/tui/nmt-page-bridge.c
+++ b/clients/tui/nmt-page-bridge.c
@@ -62,7 +62,6 @@ static void
nmt_page_bridge_constructed (GObject *object)
{
NmtPageBridge *bridge = NMT_PAGE_BRIDGE (object);
- NmtDeviceEntry *deventry;
NmtPageGrid *grid;
NMSettingBridge *s_bridge;
NmtNewtWidget *widget, *label, *stp;
@@ -75,11 +74,6 @@ nmt_page_bridge_constructed (GObject *object)
s_bridge = nm_connection_get_setting_bridge (conn);
}
- deventry = nmt_page_device_get_device_entry (NMT_PAGE_DEVICE (object));
- g_object_bind_property (s_bridge, NM_SETTING_BRIDGE_INTERFACE_NAME,
- deventry, "interface-name",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
grid = NMT_PAGE_GRID (bridge);
widget = nmt_newt_separator_new ();
diff --git a/clients/tui/nmt-page-team.c b/clients/tui/nmt-page-team.c
index 81db3d33f7..5f0a5a027b 100644
--- a/clients/tui/nmt-page-team.c
+++ b/clients/tui/nmt-page-team.c
@@ -132,7 +132,6 @@ nmt_page_team_constructed (GObject *object)
{
NmtPageTeam *team = NMT_PAGE_TEAM (object);
NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE (team);
- NmtDeviceEntry *deventry;
NmtNewtGrid *grid;
NMSettingTeam *s_team;
NmtNewtWidget *widget;
@@ -146,11 +145,6 @@ nmt_page_team_constructed (GObject *object)
}
priv->s_team = s_team;
- deventry = nmt_page_device_get_device_entry (NMT_PAGE_DEVICE (object));
- g_object_bind_property (s_team, NM_SETTING_TEAM_INTERFACE_NAME,
- deventry, "interface-name",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
widget = nmt_newt_grid_new ();
nmt_page_grid_append (NMT_PAGE_GRID (team), NULL, widget, NULL);
diff --git a/clients/tui/nmt-page-vlan.c b/clients/tui/nmt-page-vlan.c
index c3bc7076b1..af80b7387d 100644
--- a/clients/tui/nmt-page-vlan.c
+++ b/clients/tui/nmt-page-vlan.c
@@ -72,7 +72,6 @@ nmt_page_vlan_constructed (GObject *object)
{
NmtPageVlan *vlan = NMT_PAGE_VLAN (object);
NmtPageVlanPrivate *priv = NMT_PAGE_VLAN_GET_PRIVATE (vlan);
- NmtDeviceEntry *deventry;
NmtPageGrid *grid;
NMSettingWired *s_wired;
NMSettingVlan *s_vlan;
@@ -95,14 +94,9 @@ nmt_page_vlan_constructed (GObject *object)
}
priv->s_wired = g_object_ref_sink (s_wired);
- deventry = nmt_page_device_get_device_entry (NMT_PAGE_DEVICE (object));
- g_object_bind_property (s_vlan, NM_SETTING_VLAN_INTERFACE_NAME,
- deventry, "interface-name",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
-
grid = NMT_PAGE_GRID (vlan);
- nm_editor_bind_vlan_name (s_vlan);
+ nm_editor_bind_vlan_name (s_vlan, nm_connection_get_setting_connection (conn));
widget = parent = nmt_device_entry_new (_("Parent"), 40, G_TYPE_NONE);
nmt_device_entry_set_device_filter (NMT_DEVICE_ENTRY (widget),
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c
index 4a24256760..fc0ea78df2 100644
--- a/libnm-core/nm-setting.c
+++ b/libnm-core/nm-setting.c
@@ -1634,16 +1634,7 @@ _nm_setting_verify_deprecated_virtual_iface_name (const char *interface_name,
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
return NM_SETTING_VERIFY_ERROR;
}
- if (!interface_name) {
- /* Normalize by setting NMSettingConnection:interface_name. */
- g_set_error_literal (error,
- error_quark,
- e_missing_property,
- _("property is missing"));
- g_prefix_error (error, "%s.%s: ", setting_name, setting_property);
- return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
- }
- if (strcmp (con_name, interface_name) != 0) {
+ if (interface_name && strcmp (con_name, interface_name) != 0) {
/* con_name and interface_name are different. It can be normalized by setting interface_name
* to con_name. */
g_set_error_literal (error,
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index d789729ec6..c23bcd1743 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -2743,9 +2743,9 @@ test_connection_normalize_virtual_iface_name (void)
g_assert_cmpstr (nm_connection_get_interface_name (con), ==, IFACE_NAME);
g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, NULL);
- nmtst_assert_connection_verifies_after_normalization (con, NM_SETTING_VLAN_ERROR, NM_SETTING_VLAN_ERROR_MISSING_PROPERTY);
+ nmtst_assert_connection_verifies_without_normalization (con);
g_assert_cmpstr (nm_connection_get_interface_name (con), ==, IFACE_NAME);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, IFACE_NAME);
+ g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, NULL);
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, NULL, NULL);
diff --git a/libnm/nm-device-bond.c b/libnm/nm-device-bond.c
index 46f254380f..03eb4161ea 100644
--- a/libnm/nm-device-bond.c
+++ b/libnm/nm-device-bond.c
@@ -146,7 +146,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
}
dev_iface_name = nm_device_get_iface (device);
- bond_iface_name = nm_setting_bond_get_interface_name (s_bond);
+ bond_iface_name = nm_setting_connection_get_interface_name (s_con);
if (g_strcmp0 (dev_iface_name, bond_iface_name) != 0) {
g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
diff --git a/libnm/nm-device-bridge.c b/libnm/nm-device-bridge.c
index 545e2da06d..d25a30a960 100644
--- a/libnm/nm-device-bridge.c
+++ b/libnm/nm-device-bridge.c
@@ -146,7 +146,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
}
dev_iface_name = nm_device_get_iface (device);
- bridge_iface_name = nm_setting_bridge_get_interface_name (s_bridge);
+ bridge_iface_name = nm_setting_connection_get_interface_name (s_con);
if (g_strcmp0 (dev_iface_name, bridge_iface_name) != 0) {
g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
diff --git a/libnm/nm-device-team.c b/libnm/nm-device-team.c
index 892d551666..0a6fed379a 100644
--- a/libnm/nm-device-team.c
+++ b/libnm/nm-device-team.c
@@ -152,7 +152,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
}
dev_iface_name = nm_device_get_iface (device);
- team_iface_name = nm_setting_team_get_interface_name (s_team);
+ team_iface_name = nm_setting_connection_get_interface_name (s_con);
if (g_strcmp0 (dev_iface_name, team_iface_name) != 0) {
g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
diff --git a/libnm/nm-device-vlan.c b/libnm/nm-device-vlan.c
index 6a331fcd78..e94e580582 100644
--- a/libnm/nm-device-vlan.c
+++ b/libnm/nm-device-vlan.c
@@ -150,7 +150,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
}
dev_iface_name = nm_device_get_iface (device);
- vlan_iface_name = nm_setting_vlan_get_interface_name (s_vlan);
+ vlan_iface_name = nm_setting_connection_get_interface_name (s_con);
if (vlan_iface_name && g_strcmp0 (dev_iface_name, vlan_iface_name) != 0) {
g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_INTERFACE_MISMATCH,
"The interfaces of the device and the connection didn't match.");
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 029deb80d9..92a5911c8e 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -127,7 +127,8 @@ complete_connection (NMDevice *device,
const GSList *existing_connections,
GError **error)
{
- NMSettingBond *s_bond, *tmp;
+ NMSettingBond *s_bond;
+ NMSettingConnection *s_con;
guint32 i = 0;
char *name;
const GSList *iter;
@@ -145,11 +146,13 @@ complete_connection (NMDevice *device,
s_bond = (NMSettingBond *) nm_setting_bond_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bond));
}
+ s_con = nm_connection_get_setting_connection (connection);
+ g_return_val_if_fail (s_con != NULL, FALSE);
/* Grab the first name that doesn't exist in either our connections
* or a device on the system.
*/
- while (i < 500 && !nm_setting_bond_get_interface_name (s_bond)) {
+ while (i < 500 && !nm_setting_connection_get_interface_name (s_con)) {
name = g_strdup_printf ("bond%u", i);
/* check interface names */
if (!nm_platform_link_exists (name)) {
@@ -157,9 +160,8 @@ complete_connection (NMDevice *device,
for (iter = existing_connections, found = FALSE; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = iter->data;
- tmp = nm_connection_get_setting_bond (candidate);
- if (tmp && nm_connection_is_type (candidate, NM_SETTING_BOND_SETTING_NAME)) {
- if (g_strcmp0 (nm_setting_bond_get_interface_name (tmp), name) == 0) {
+ if (nm_connection_is_type (candidate, NM_SETTING_BOND_SETTING_NAME)) {
+ if (g_strcmp0 (nm_connection_get_interface_name (candidate), name) == 0) {
found = TRUE;
break;
}
@@ -167,7 +169,7 @@ complete_connection (NMDevice *device,
}
if (!found)
- g_object_set (G_OBJECT (s_bond), NM_SETTING_BOND_INTERFACE_NAME, name, NULL);
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, name, NULL);
}
g_free (name);
@@ -209,14 +211,12 @@ static void
update_connection (NMDevice *device, NMConnection *connection)
{
NMSettingBond *s_bond = nm_connection_get_setting_bond (connection);
- const char *ifname = nm_device_get_iface (device);
int ifindex = nm_device_get_ifindex (device);
const char **options;
if (!s_bond) {
s_bond = (NMSettingBond *) nm_setting_bond_new ();
nm_connection_add_setting (connection, (NMSetting *) s_bond);
- g_object_set (s_bond, NM_SETTING_BOND_INTERFACE_NAME, ifname, NULL);
}
/* Read bond options from sysfs and update the Bond setting to match */
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 68cb500631..47c5f7e0c0 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -135,7 +135,8 @@ complete_connection (NMDevice *device,
const GSList *existing_connections,
GError **error)
{
- NMSettingBridge *s_bridge, *tmp;
+ NMSettingBridge *s_bridge;
+ NMSettingConnection *s_con;
guint32 i = 0;
char *name;
const GSList *iter;
@@ -153,11 +154,13 @@ complete_connection (NMDevice *device,
s_bridge = (NMSettingBridge *) nm_setting_bridge_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bridge));
}
+ s_con = nm_connection_get_setting_connection (connection);
+ g_return_val_if_fail (s_con != NULL, FALSE);
/* Grab the first name that doesn't exist in either our connections
* or a device on the system.
*/
- while (i < 500 && !nm_setting_bridge_get_interface_name (s_bridge)) {
+ while (i < 500 && !nm_setting_connection_get_interface_name (s_con)) {
name = g_strdup_printf ("br%u", i);
/* check interface names */
if (!nm_platform_link_exists (name)) {
@@ -165,9 +168,8 @@ complete_connection (NMDevice *device,
for (iter = existing_connections, found = FALSE; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = iter->data;
- tmp = nm_connection_get_setting_bridge (candidate);
- if (tmp && nm_connection_is_type (candidate, NM_SETTING_BRIDGE_SETTING_NAME)) {
- if (g_strcmp0 (nm_setting_bridge_get_interface_name (tmp), name) == 0) {
+ if (nm_connection_is_type (candidate, NM_SETTING_BRIDGE_SETTING_NAME)) {
+ if (g_strcmp0 (nm_connection_get_interface_name (candidate), name) == 0) {
found = TRUE;
break;
}
@@ -175,7 +177,7 @@ complete_connection (NMDevice *device,
}
if (!found)
- g_object_set (G_OBJECT (s_bridge), NM_SETTING_BRIDGE_INTERFACE_NAME, name, NULL);
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, name, NULL);
}
g_free (name);
@@ -293,14 +295,12 @@ update_connection (NMDevice *device, NMConnection *connection)
{
NMDeviceBridge *self = NM_DEVICE_BRIDGE (device);
NMSettingBridge *s_bridge = nm_connection_get_setting_bridge (connection);
- const char *ifname = nm_device_get_iface (device);
int ifindex = nm_device_get_ifindex (device);
const Option *option;
if (!s_bridge) {
s_bridge = (NMSettingBridge *) nm_setting_bridge_new ();
nm_connection_add_setting (connection, (NMSetting *) s_bridge);
- g_object_set (s_bridge, NM_SETTING_BRIDGE_INTERFACE_NAME, ifname, NULL);
}
for (option = master_options; option->name; option++) {
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index b1fe7bc844..3316bd67bd 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -290,7 +290,6 @@ update_connection (NMDevice *device, NMConnection *connection)
if (!s_vlan) {
s_vlan = (NMSettingVlan *) nm_setting_vlan_new ();
nm_connection_add_setting (connection, (NMSetting *) s_vlan);
- g_object_set (s_vlan, NM_SETTING_VLAN_INTERFACE_NAME, nm_device_get_iface (device), NULL);
}
if (!nm_platform_vlan_get_info (ifindex, &parent_ifindex, &vlan_id)) {
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 0cdc44bbec..2f296aadf9 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -138,7 +138,8 @@ complete_connection (NMDevice *device,
const GSList *existing_connections,
GError **error)
{
- NMSettingTeam *s_team, *tmp;
+ NMSettingTeam *s_team;
+ NMSettingConnection *s_con;
guint32 i = 0;
char *name;
const GSList *iter;
@@ -156,11 +157,13 @@ complete_connection (NMDevice *device,
s_team = (NMSettingTeam *) nm_setting_team_new ();
nm_connection_add_setting (connection, NM_SETTING (s_team));
}
+ s_con = nm_connection_get_setting_connection (connection);
+ g_return_val_if_fail (s_con != NULL, FALSE);
/* Grab the first name that doesn't exist in either our connections
* or a device on the system.
*/
- while (i < 500 && !nm_setting_team_get_interface_name (s_team)) {
+ while (i < 500 && !nm_setting_connection_get_interface_name (s_con)) {
name = g_strdup_printf ("team%u", i);
/* check interface names */
if (!nm_platform_link_exists (name)) {
@@ -168,9 +171,8 @@ complete_connection (NMDevice *device,
for (iter = existing_connections, found = FALSE; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = iter->data;
- tmp = nm_connection_get_setting_team (candidate);
- if (tmp && nm_connection_is_type (candidate, NM_SETTING_TEAM_SETTING_NAME)) {
- if (g_strcmp0 (nm_setting_team_get_interface_name (tmp), name) == 0) {
+ if (nm_connection_is_type (candidate, NM_SETTING_TEAM_SETTING_NAME)) {
+ if (g_strcmp0 (nm_connection_get_interface_name (candidate), name) == 0) {
found = TRUE;
break;
}
@@ -178,7 +180,7 @@ complete_connection (NMDevice *device,
}
if (!found)
- g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_INTERFACE_NAME, name, NULL);
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, name, NULL);
}
g_free (name);
@@ -219,8 +221,6 @@ update_connection (NMDevice *device, NMConnection *connection)
if (!s_team) {
s_team = (NMSettingTeam *) nm_setting_team_new ();
nm_connection_add_setting (connection, (NMSetting *) s_team);
- g_object_set (G_OBJECT (s_team),
- NM_SETTING_TEAM_INTERFACE_NAME, nm_device_get_iface (device), NULL);
}
g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_CONFIG, NULL, NULL);
diff --git a/src/settings/plugins/ibft/tests/test-ibft.c b/src/settings/plugins/ibft/tests/test-ibft.c
index 45c8d1f697..185e0f690b 100644
--- a/src/settings/plugins/ibft/tests/test-ibft.c
+++ b/src/settings/plugins/ibft/tests/test-ibft.c
@@ -252,7 +252,6 @@ test_read_ibft_vlan (void)
g_assert (s_vlan);
g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 123);
g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, NULL);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, NULL);
/* ===== IPv4 SETTING ===== */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
index 27e2df9b7e..4a8a686733 100644
--- a/src/settings/plugins/ifcfg-rh/reader.c
+++ b/src/settings/plugins/ifcfg-rh/reader.c
@@ -3959,8 +3959,6 @@ make_bond_setting (shvarFile *ifcfg,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing");
goto error;
}
-
- g_object_set (s_bond, NM_SETTING_BOND_INTERFACE_NAME, value, NULL);
g_free (value);
value = svGetValue (ifcfg, "BONDING_OPTS", FALSE);
@@ -4081,8 +4079,6 @@ make_team_setting (shvarFile *ifcfg,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing");
goto error;
}
-
- g_object_set (s_team, NM_SETTING_TEAM_INTERFACE_NAME, value, NULL);
g_free (value);
value = read_team_config (ifcfg, "TEAM_CONFIG", &local_err);
@@ -4234,8 +4230,6 @@ make_bridge_setting (shvarFile *ifcfg,
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "mandatory DEVICE keyword missing");
goto error;
}
-
- g_object_set (s_bridge, NM_SETTING_BRIDGE_INTERFACE_NAME, value, NULL);
g_free (value);
if (read_mac_address (ifcfg, "MACADDR", ETH_ALEN, &array, error)) {
@@ -4504,8 +4498,6 @@ make_vlan_setting (shvarFile *ifcfg,
parent = svGetValue (ifcfg, "PHYSDEV", FALSE);
if (iface_name) {
- g_object_set (s_vlan, NM_SETTING_VLAN_INTERFACE_NAME, iface_name, NULL);
-
p = strchr (iface_name, '.');
if (p) {
/* eth0.43; PHYSDEV is assumed from it if unknown */
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index b2d0ad9bfb..467ac3b453 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -11470,11 +11470,12 @@ test_read_bridge_main (void)
g_assert (nm_connection_verify (connection, &error));
g_assert_no_error (error);
+ g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "br0");
+
/* ===== Bridging SETTING ===== */
s_bridge = nm_connection_get_setting_bridge (connection);
g_assert (s_bridge);
- g_assert_cmpstr (nm_setting_bridge_get_interface_name (s_bridge), ==, "br0");
g_assert_cmpuint (nm_setting_bridge_get_forward_delay (s_bridge), ==, 0);
g_assert (nm_setting_bridge_get_stp (s_bridge));
g_assert_cmpuint (nm_setting_bridge_get_priority (s_bridge), ==, 32744);
@@ -11532,6 +11533,7 @@ test_write_bridge_main (void)
NM_SETTING_CONNECTION_ID, "Test Write Bridge Main",
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, "br0",
NM_SETTING_CONNECTION_TYPE, NM_SETTING_BRIDGE_SETTING_NAME,
NULL);
g_free (uuid);
@@ -11544,7 +11546,6 @@ test_write_bridge_main (void)
mac_array = g_byte_array_sized_new (sizeof (bridge_mac));
g_byte_array_append (mac_array, bridge_mac, sizeof (bridge_mac));
g_object_set (s_bridge,
- NM_SETTING_BRIDGE_INTERFACE_NAME, "br0",
NM_SETTING_BRIDGE_MAC_ADDRESS, mac_array,
NULL);
g_byte_array_free (mac_array, TRUE);
@@ -11575,7 +11576,7 @@ test_write_bridge_main (void)
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
NULL);
- nmtst_assert_connection_verifies_after_normalization (connection, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY);
+ nmtst_assert_connection_verifies_without_normalization (connection);
/* Save the ifcfg */
success = writer_new_connection (connection,
@@ -11797,11 +11798,12 @@ test_read_bridge_missing_stp (void)
g_assert (nm_connection_verify (connection, &error));
g_assert_no_error (error);
+ g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "br0");
+
/* ===== Bridging SETTING ===== */
s_bridge = nm_connection_get_setting_bridge (connection);
g_assert (s_bridge);
- g_assert_cmpstr (nm_setting_bridge_get_interface_name (s_bridge), ==, "br0");
g_assert (nm_setting_bridge_get_stp (s_bridge) == FALSE);
g_free (unmanaged);
@@ -11843,10 +11845,11 @@ test_read_vlan_interface (void)
g_free (routefile);
g_free (route6file);
+ g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "vlan43");
+
s_vlan = nm_connection_get_setting_vlan (connection);
g_assert (s_vlan);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, "vlan43");
g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9");
g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 43);
g_assert_cmpint (nm_setting_vlan_get_flags (s_vlan), ==,
@@ -11912,10 +11915,11 @@ test_read_vlan_only_vlan_id (void)
g_free (routefile);
g_free (route6file);
+ g_assert (nm_connection_get_interface_name (connection) == NULL);
+
s_vlan = nm_connection_get_setting_vlan (connection);
g_assert (s_vlan);
- g_assert (nm_setting_vlan_get_interface_name (s_vlan) == NULL);
g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth9");
g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 43);
@@ -11953,10 +11957,11 @@ test_read_vlan_only_device (void)
g_free (routefile);
g_free (route6file);
+ g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "eth0.9");
+
s_vlan = nm_connection_get_setting_vlan (connection);
g_assert (s_vlan);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, "eth0.9");
g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth0");
g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 9);
@@ -11977,10 +11982,11 @@ test_read_vlan_physdev (void)
g_assert (connection);
g_assert (nm_connection_verify (connection, &error));
+ g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "vlan0.3");
+
s_vlan = nm_connection_get_setting_vlan (connection);
g_assert (s_vlan);
- g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, "vlan0.3");
g_assert_cmpstr (nm_setting_vlan_get_parent (s_vlan), ==, "eth0");
g_assert_cmpint (nm_setting_vlan_get_id (s_vlan), ==, 3);
@@ -12262,6 +12268,10 @@ test_read_bond_main (void)
ASSERT (nm_connection_verify (connection, &error),
"bond-main-read", "failed to verify %s: %s", TEST_IFCFG_BOND_MAIN, error->message);
+ ASSERT (g_strcmp0 (nm_connection_get_interface_name (connection), "bond0") == 0,
+ "bond-main", "failed to verify %s: DEVICE=%s does not match bond0",
+ TEST_IFCFG_BOND_MAIN, nm_connection_get_interface_name (connection));
+
/* ===== Bonding SETTING ===== */
s_bond = nm_connection_get_setting_bond (connection);
@@ -12270,10 +12280,6 @@ test_read_bond_main (void)
TEST_IFCFG_BOND_MAIN,
NM_SETTING_BOND_SETTING_NAME);
- ASSERT (g_strcmp0 (nm_setting_bond_get_interface_name (s_bond), "bond0") == 0,
- "bond-main", "failed to verify %s: DEVICE=%s does not match bond0",
- TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_interface_name (s_bond));
-
ASSERT (g_strcmp0 (nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON), "100") == 0,
"bond-main", "failed to verify %s: miimon=%s does not match 100",
TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON));
@@ -12320,6 +12326,7 @@ test_write_bond_main (void)
NM_SETTING_CONNECTION_ID, "Test Write Bond Main",
NM_SETTING_CONNECTION_UUID, uuid,
NM_SETTING_CONNECTION_AUTOCONNECT, TRUE,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, "bond0",
NM_SETTING_CONNECTION_TYPE, NM_SETTING_BOND_SETTING_NAME,
NULL);
g_free (uuid);
@@ -12332,10 +12339,6 @@ test_write_bond_main (void)
s_bond = (NMSettingBond *) nm_setting_bond_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bond));
- g_object_set (s_bond,
- NM_SETTING_BOND_INTERFACE_NAME, "bond0",
- NULL);
-
/* IP4 setting */
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
@@ -12360,7 +12363,7 @@ test_write_bond_main (void)
NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
NULL);
- nmtst_assert_connection_verifies_after_normalization (connection, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY);
+ nmtst_assert_connection_verifies_without_normalization (connection);
/* Save the ifcfg */
success = writer_new_connection (connection,
@@ -13383,13 +13386,14 @@ test_read_team_master (void)
g_assert_no_error (error);
g_assert (success);
+ g_assert_cmpstr (nm_connection_get_interface_name (connection), ==, "team0");
+
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
g_assert_cmpstr (nm_setting_connection_get_connection_type (s_con), ==, NM_SETTING_TEAM_SETTING_NAME);
s_team = nm_connection_get_setting_team (connection);
g_assert (s_team);
- g_assert_cmpstr (nm_setting_team_get_interface_name (s_team), ==, "team0");
g_assert_cmpstr (nm_setting_team_get_config (s_team), ==, expected_config);
g_object_unref (connection);
@@ -13402,6 +13406,8 @@ test_write_team_master (void)
NMSettingConnection *s_con;
NMSettingTeam *s_team;
NMSettingWired *s_wired;
+ NMSettingIP4Config *s_ip4;
+ NMSettingIP6Config *s_ip6;
char *uuid, *testfile = NULL, *val;
gboolean success;
GError *error = NULL;
@@ -13419,6 +13425,7 @@ test_write_team_master (void)
g_object_set (s_con,
NM_SETTING_CONNECTION_ID, "Test Write Team Master",
NM_SETTING_CONNECTION_UUID, uuid,
+ NM_SETTING_CONNECTION_INTERFACE_NAME, "team0",
NM_SETTING_CONNECTION_TYPE, NM_SETTING_TEAM_SETTING_NAME,
NULL);
g_free (uuid);
@@ -13428,7 +13435,6 @@ test_write_team_master (void)
nm_connection_add_setting (connection, NM_SETTING (s_team));
g_object_set (s_team,
- NM_SETTING_TEAM_INTERFACE_NAME, "team0",
NM_SETTING_TEAM_CONFIG, expected_config,
NULL);
@@ -13436,7 +13442,25 @@ test_write_team_master (void)
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wired));
- nmtst_assert_connection_verifies_after_normalization (connection, NM_SETTING_CONNECTION_ERROR, NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY);
+ /* IP4 setting */
+ s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
+ g_assert (s_ip4);
+ nm_connection_add_setting (connection, NM_SETTING (s_ip4));
+
+ g_object_set (s_ip4,
+ NM_SETTING_IP4_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
+ NULL);
+
+ /* IP6 setting */
+ s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
+ g_assert (s_ip6);
+ nm_connection_add_setting (connection, NM_SETTING (s_ip6));
+
+ g_object_set (s_ip6,
+ NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
+ NULL);
+
+ nmtst_assert_connection_verifies_without_normalization (connection);
/* Save the ifcfg */
success = writer_new_connection (connection,
diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c
index e1c8f3678e..c0a93909fc 100644
--- a/src/settings/plugins/ifcfg-rh/writer.c
+++ b/src/settings/plugins/ifcfg-rh/writer.c
@@ -1206,7 +1206,7 @@ write_vlan_setting (NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
svSetValue (ifcfg, "VLAN", "yes", FALSE);
svSetValue (ifcfg, "TYPE", TYPE_VLAN, FALSE);
- svSetValue (ifcfg, "DEVICE", nm_setting_vlan_get_interface_name (s_vlan), FALSE);
+ svSetValue (ifcfg, "DEVICE", nm_setting_connection_get_interface_name (s_con), FALSE);
svSetValue (ifcfg, "PHYSDEV", nm_setting_vlan_get_parent (s_vlan), FALSE);
svSetValue (ifcfg, "MASTER", nm_setting_connection_get_master (s_con), FALSE);
@@ -1289,7 +1289,7 @@ write_bonding_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro
return FALSE;
}
- iface = nm_setting_bond_get_interface_name (s_bond);
+ iface = nm_connection_get_interface_name (connection);
if (!iface) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name");
return FALSE;
@@ -1340,7 +1340,7 @@ write_team_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
return FALSE;
}
- iface = nm_setting_team_get_interface_name (s_team);
+ iface = nm_connection_get_interface_name (connection);
if (!iface) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name");
return FALSE;
@@ -1388,7 +1388,7 @@ write_bridge_setting (NMConnection *connection, shvarFile *ifcfg, GError **error
return FALSE;
}
- iface = nm_setting_bridge_get_interface_name (s_bridge);
+ iface = nm_connection_get_interface_name (connection);
if (!iface) {
g_set_error (error, IFCFG_PLUGIN_ERROR, 0, "Missing interface name");
return FALSE;
diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
index 4667f0c422..098d7706d3 100644
--- a/src/settings/plugins/keyfile/reader.c
+++ b/src/settings/plugins/keyfile/reader.c
@@ -629,7 +629,7 @@ read_hash_of_string (GKeyFile *file, NMSetting *setting, const char *key)
nm_setting_vpn_add_data_item (NM_SETTING_VPN (setting), *iter, value);
}
if (NM_IS_SETTING_BOND (setting)) {
- if (strcmp (*iter, NM_SETTING_BOND_INTERFACE_NAME))
+ if (strcmp (*iter, "interface-name"))
nm_setting_bond_add_option (NM_SETTING_BOND (setting), *iter, value);
}
g_free (value);
@@ -1272,6 +1272,23 @@ nm_keyfile_plugin_connection_from_file (const char *filename, GError **error)
g_free (hashed_uuid);
}
+ /* Make sure that we have 'interface-name' even if it was specified in the
+ * "wrong" (ie, deprecated) group.
+ */
+ if ( !nm_setting_connection_get_interface_name (s_con)
+ && nm_setting_connection_get_connection_type (s_con)) {
+ char *interface_name;
+
+ interface_name = g_key_file_get_string (key_file,
+ nm_setting_connection_get_connection_type (s_con),
+ "interface-name",
+ NULL);
+ if (interface_name) {
+ g_object_set (s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, interface_name, NULL);
+ g_free (interface_name);
+ }
+ }
+
/* Handle vpn secrets after the 'vpn' setting was read */
if (vpn_secrets) {
NMSettingVpn *s_vpn;
diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c
index 97ff781c04..24a09ec44b 100644
--- a/src/settings/plugins/keyfile/tests/test-keyfile.c
+++ b/src/settings/plugins/keyfile/tests/test-keyfile.c
@@ -2921,6 +2921,7 @@ test_read_bridge_main (void)
g_assert (s_con);
g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, expected_id);
g_assert_cmpstr (nm_setting_connection_get_uuid (s_con), ==, expected_uuid);
+ g_assert_cmpstr (nm_setting_connection_get_interface_name (s_con), ==, "br0");
/* IPv4 setting */
s_ip4 = nm_connection_get_setting_ip4_config (connection);
@@ -2930,7 +2931,6 @@ test_read_bridge_main (void)
/* Bridge setting */
s_bridge = nm_connection_get_setting_bridge (connection);
g_assert (s_bridge);
- g_assert_cmpstr (nm_setting_bridge_get_interface_name (s_bridge), ==, "br0");
g_assert_cmpuint (nm_setting_bridge_get_forward_delay (s_bridge), ==, 0);
g_assert_cmpuint (nm_setting_bridge_get_stp (s_bridge), ==, TRUE);
g_assert_cmpuint (nm_setting_bridge_get_priority (s_bridge), ==, 32744);