Commit ab26964c authored by Dan Winship's avatar Dan Winship

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().
parent 7314256b
......@@ -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 */
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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
......
......@@ -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 ();
......
......@@ -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 ();
......
......@@ -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);
......
......@@ -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),
......
......@@ -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,
......
......@@ -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);
......
......@@ -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.");
......
......@@ -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.");
......
......@@ -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.");
......
......@@ -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.");
......
......@@ -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);