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) ...@@ -2685,34 +2685,24 @@ add_ip6_address_to_connection (NMIP6Address *ip6addr, NMConnection *connection)
static char * static char *
unique_master_iface_ifname (GSList *list, unique_master_iface_ifname (GSList *list,
const char *type,
const char *ifname_property,
const char *try_name) const char *try_name)
{ {
NMConnection *connection; NMConnection *connection;
NMSetting *setting;
char *new_name; char *new_name;
unsigned int num = 1; unsigned int num = 1;
GSList *iterator = list; GSList *iterator = list;
char *ifname_val = NULL; const char *ifname = NULL;
new_name = g_strdup (try_name); new_name = g_strdup (try_name);
while (iterator) { while (iterator) {
connection = NM_CONNECTION (iterator->data); connection = NM_CONNECTION (iterator->data);
setting = nm_connection_get_setting_by_name (connection, type); ifname = nm_connection_get_interface_name (connection);
if (!setting) { if (g_strcmp0 (new_name, ifname) == 0) {
iterator = g_slist_next (iterator);
continue;
}
g_object_get (setting, ifname_property, &ifname_val, NULL);
if (g_strcmp0 (new_name, ifname_val) == 0) {
g_free (new_name); g_free (new_name);
new_name = g_strdup_printf ("%s%d", try_name, num++); new_name = g_strdup_printf ("%s%d", try_name, num++);
iterator = list; iterator = list;
} else } else
iterator = g_slist_next (iterator); iterator = g_slist_next (iterator);
g_free (ifname_val);
} }
return new_name; return new_name;
} }
...@@ -4144,7 +4134,6 @@ cleanup_bt: ...@@ -4144,7 +4134,6 @@ cleanup_bt:
} else if (!strcmp (con_type, NM_SETTING_VLAN_SETTING_NAME)) { } else if (!strcmp (con_type, NM_SETTING_VLAN_SETTING_NAME)) {
/* Build up the settings required for 'vlan' */ /* Build up the settings required for 'vlan' */
gboolean success = FALSE; gboolean success = FALSE;
const char *ifname = NULL;
const char *parent = NULL; const char *parent = NULL;
char *parent_ask = NULL; char *parent_ask = NULL;
const char *vlan_id = NULL; const char *vlan_id = NULL;
...@@ -4211,9 +4200,6 @@ cleanup_bt: ...@@ -4211,9 +4200,6 @@ cleanup_bt:
if (ask) if (ask)
do_questionnaire_vlan (&mtu, &flags, &ingress, &egress); 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)) if (!check_and_convert_mtu (mtu, &mtu_int, error))
goto cleanup_vlan; goto cleanup_vlan;
if (!check_and_convert_vlan_flags (flags, &flags_int, error)) if (!check_and_convert_vlan_flags (flags, &flags_int, error))
...@@ -4242,8 +4228,6 @@ cleanup_bt: ...@@ -4242,8 +4228,6 @@ cleanup_bt:
if (!addr_array) if (!addr_array)
g_object_set (s_vlan, NM_SETTING_VLAN_PARENT, parent, NULL); 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); g_object_set (s_vlan, NM_SETTING_VLAN_ID, id, NULL);
if (flags) if (flags)
...@@ -4271,7 +4255,6 @@ cleanup_vlan: ...@@ -4271,7 +4255,6 @@ cleanup_vlan:
} else if (!strcmp (con_type, NM_SETTING_BOND_SETTING_NAME)) { } else if (!strcmp (con_type, NM_SETTING_BOND_SETTING_NAME)) {
/* Build up the settings required for 'bond' */ /* Build up the settings required for 'bond' */
gboolean success = FALSE; gboolean success = FALSE;
char *bond_ifname = NULL;
const char *ifname = NULL; const char *ifname = NULL;
const char *bond_mode_c = NULL; const char *bond_mode_c = NULL;
char *bond_mode = NULL; char *bond_mode = NULL;
...@@ -4312,22 +4295,22 @@ cleanup_vlan: ...@@ -4312,22 +4295,22 @@ cleanup_vlan:
&bond_downdelay, &bond_updelay, &bond_downdelay, &bond_updelay,
&bond_arpinterval, &bond_arpiptarget); &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); ifname = nm_setting_connection_get_interface_name (s_con);
if (!ifname) if (!ifname) {
bond_ifname = unique_master_iface_ifname (all_connections, char *bond_ifname = unique_master_iface_ifname (all_connections, "nm-bond");
NM_SETTING_BOND_SETTING_NAME,
NM_SETTING_BOND_INTERFACE_NAME, g_object_set (s_con,
"nm-bond"); NM_SETTING_CONNECTION_INTERFACE_NAME, bond_ifname,
else NULL);
bond_ifname = g_strdup (ifname); g_free (bond_ifname);
}
/* Add 'bond' setting */ /* Add 'bond' setting */
s_bond = (NMSettingBond *) nm_setting_bond_new (); s_bond = (NMSettingBond *) nm_setting_bond_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bond)); nm_connection_add_setting (connection, NM_SETTING (s_bond));
/* Set bond options */ /* Set bond options */
g_object_set (s_bond, NM_SETTING_BOND_INTERFACE_NAME, bond_ifname, NULL);
if (bond_mode) { if (bond_mode) {
GError *err = NULL; GError *err = NULL;
const char *bm; const char *bm;
...@@ -4361,7 +4344,6 @@ cleanup_vlan: ...@@ -4361,7 +4344,6 @@ cleanup_vlan:
success = TRUE; success = TRUE;
cleanup_bond: cleanup_bond:
g_free (bond_ifname);
g_free (bond_mode); g_free (bond_mode);
g_free (bond_primary); g_free (bond_primary);
g_free (bond_miimon); g_free (bond_miimon);
...@@ -4420,7 +4402,6 @@ cleanup_bond: ...@@ -4420,7 +4402,6 @@ cleanup_bond:
} else if (!strcmp (con_type, NM_SETTING_TEAM_SETTING_NAME)) { } else if (!strcmp (con_type, NM_SETTING_TEAM_SETTING_NAME)) {
/* Build up the settings required for 'team' */ /* Build up the settings required for 'team' */
gboolean success = FALSE; gboolean success = FALSE;
char *team_ifname = NULL;
const char *ifname = NULL; const char *ifname = NULL;
const char *config_c = NULL; const char *config_c = NULL;
char *config = NULL; char *config = NULL;
...@@ -4436,15 +4417,16 @@ cleanup_bond: ...@@ -4436,15 +4417,16 @@ cleanup_bond:
if (ask) if (ask)
do_questionnaire_team (&config); 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); ifname = nm_setting_connection_get_interface_name (s_con);
if (!ifname) if (!ifname) {
team_ifname = unique_master_iface_ifname (all_connections, char *team_ifname = unique_master_iface_ifname (all_connections, "nm-team");
NM_SETTING_TEAM_SETTING_NAME,
NM_SETTING_TEAM_INTERFACE_NAME, g_object_set (s_con,
"nm-team"); NM_SETTING_CONNECTION_INTERFACE_NAME, team_ifname,
else NULL);
team_ifname = g_strdup (ifname); g_free (team_ifname);
}
/* Add 'team' setting */ /* Add 'team' setting */
s_team = (NMSettingTeam *) nm_setting_team_new (); s_team = (NMSettingTeam *) nm_setting_team_new ();
...@@ -4456,12 +4438,10 @@ cleanup_bond: ...@@ -4456,12 +4438,10 @@ cleanup_bond:
} }
/* Set team options */ /* 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); g_object_set (s_team, NM_SETTING_TEAM_CONFIG, json, NULL);
success = TRUE; success = TRUE;
cleanup_team: cleanup_team:
g_free (team_ifname);
g_free (config); g_free (config);
g_free (json); g_free (json);
if (!success) if (!success)
...@@ -4543,7 +4523,6 @@ cleanup_team_slave: ...@@ -4543,7 +4523,6 @@ cleanup_team_slave:
} else if (!strcmp (con_type, NM_SETTING_BRIDGE_SETTING_NAME)) { } else if (!strcmp (con_type, NM_SETTING_BRIDGE_SETTING_NAME)) {
/* Build up the settings required for 'bridge' */ /* Build up the settings required for 'bridge' */
gboolean success = FALSE; gboolean success = FALSE;
char *bridge_ifname = NULL;
const char *ifname = NULL; const char *ifname = NULL;
const char *stp_c = NULL; const char *stp_c = NULL;
char *stp = NULL; char *stp = NULL;
...@@ -4587,15 +4566,16 @@ cleanup_team_slave: ...@@ -4587,15 +4566,16 @@ cleanup_team_slave:
do_questionnaire_bridge (&stp, &priority, &fwd_delay, &hello_time, do_questionnaire_bridge (&stp, &priority, &fwd_delay, &hello_time,
&max_age, &ageing_time, &mac); &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); ifname = nm_setting_connection_get_interface_name (s_con);
if (!ifname) if (!ifname) {
bridge_ifname = unique_master_iface_ifname (all_connections, char *bridge_ifname = unique_master_iface_ifname (all_connections, "nm-bridge");
NM_SETTING_BRIDGE_SETTING_NAME,
NM_SETTING_BRIDGE_INTERFACE_NAME, g_object_set (s_con,
"nm-bridge"); NM_SETTING_CONNECTION_INTERFACE_NAME, bridge_ifname,
else NULL);
bridge_ifname = g_strdup (ifname); g_free (bridge_ifname);
}
if (stp) { if (stp) {
GError *tmp_err = NULL; GError *tmp_err = NULL;
...@@ -4636,7 +4616,6 @@ cleanup_team_slave: ...@@ -4636,7 +4616,6 @@ cleanup_team_slave:
goto cleanup_bridge; goto cleanup_bridge;
/* Set bridge options */ /* Set bridge options */
g_object_set (s_bridge, NM_SETTING_BRIDGE_INTERFACE_NAME, bridge_ifname, NULL);
if (stp) if (stp)
g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, stp_bool, NULL); g_object_set (s_bridge, NM_SETTING_BRIDGE_STP, stp_bool, NULL);
if (priority) if (priority)
...@@ -4654,7 +4633,6 @@ cleanup_team_slave: ...@@ -4654,7 +4633,6 @@ cleanup_team_slave:
success = TRUE; success = TRUE;
cleanup_bridge: cleanup_bridge:
g_free (bridge_ifname);
g_free (stp); g_free (stp);
g_free (priority); g_free (priority);
g_free (fwd_delay); g_free (fwd_delay);
...@@ -7745,16 +7723,16 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection) ...@@ -7745,16 +7723,16 @@ editor_init_new_connection (NmCli *nmc, NMConnection *connection)
/* Set a sensible bond/team/bridge interface name by default */ /* Set a sensible bond/team/bridge interface name by default */
if (g_strcmp0 (con_type, NM_SETTING_BOND_SETTING_NAME) == 0) if (g_strcmp0 (con_type, NM_SETTING_BOND_SETTING_NAME) == 0)
g_object_set (NM_SETTING_BOND (base_setting), g_object_set (s_con,
NM_SETTING_BOND_INTERFACE_NAME, "nm-bond", NM_SETTING_CONNECTION_INTERFACE_NAME, "nm-bond",
NULL); NULL);
if (g_strcmp0 (con_type, NM_SETTING_TEAM_SETTING_NAME) == 0) if (g_strcmp0 (con_type, NM_SETTING_TEAM_SETTING_NAME) == 0)
g_object_set (NM_SETTING_TEAM (base_setting), g_object_set (s_con,
NM_SETTING_TEAM_INTERFACE_NAME, "nm-team", NM_SETTING_CONNECTION_INTERFACE_NAME, "nm-team",
NULL); NULL);
if (g_strcmp0 (con_type, NM_SETTING_BRIDGE_SETTING_NAME) == 0) if (g_strcmp0 (con_type, NM_SETTING_BRIDGE_SETTING_NAME) == 0)
g_object_set (NM_SETTING_BRIDGE (base_setting), g_object_set (s_con,
NM_SETTING_BRIDGE_INTERFACE_NAME, "nm-bridge", NM_SETTING_CONNECTION_INTERFACE_NAME, "nm-bridge",
NULL); NULL);
/* Set sensible initial VLAN values */ /* Set sensible initial VLAN values */
......
This diff is collapsed.
...@@ -1543,6 +1543,7 @@ nm_editor_bind_wireless_security_wep_key (NMSettingWirelessSecurity *s_wsec, ...@@ -1543,6 +1543,7 @@ nm_editor_bind_wireless_security_wep_key (NMSettingWirelessSecurity *s_wsec,
typedef struct { typedef struct {
NMSettingVlan *s_vlan; NMSettingVlan *s_vlan;
NMSettingConnection *s_con;
char *last_ifname_parent; char *last_ifname_parent;
int last_ifname_id; int last_ifname_id;
...@@ -1595,7 +1596,7 @@ vlan_settings_changed (GObject *object, ...@@ -1595,7 +1596,7 @@ vlan_settings_changed (GObject *object,
if (binding->updating) if (binding->updating)
return; 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); parent = nm_setting_vlan_get_parent (binding->s_vlan);
id = nm_setting_vlan_get_id (binding->s_vlan); id = nm_setting_vlan_get_id (binding->s_vlan);
...@@ -1653,20 +1654,22 @@ vlan_target_destroyed (gpointer user_data, ...@@ -1653,20 +1654,22 @@ vlan_target_destroyed (gpointer user_data,
* two properties automatically. * two properties automatically.
*/ */
void void
nm_editor_bind_vlan_name (NMSettingVlan *s_vlan) nm_editor_bind_vlan_name (NMSettingVlan *s_vlan,
NMSettingConnection *s_con)
{ {
NMEditorVlanWidgetBinding *binding; NMEditorVlanWidgetBinding *binding;
const char *ifname; const char *ifname;
binding = g_slice_new0 (NMEditorVlanWidgetBinding); binding = g_slice_new0 (NMEditorVlanWidgetBinding);
binding->s_vlan = s_vlan; 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_CALLBACK (vlan_settings_changed), binding);
g_object_weak_ref (G_OBJECT (s_vlan), vlan_target_destroyed, 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)) { if (!parse_interface_name (ifname, &binding->last_ifname_parent, &binding->last_ifname_id)) {
binding->last_ifname_parent = NULL; binding->last_ifname_parent = NULL;
binding->last_ifname_id = 0; binding->last_ifname_id = 0;
......
...@@ -89,7 +89,8 @@ void nm_editor_bind_wireless_security_wep_key (NMSettingWirelessSecurity ...@@ -89,7 +89,8 @@ void nm_editor_bind_wireless_security_wep_key (NMSettingWirelessSecurity
const char *key_selector_property, const char *key_selector_property,
GBindingFlags flags); 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 G_END_DECLS
......
...@@ -334,7 +334,6 @@ nmt_page_bond_constructed (GObject *object) ...@@ -334,7 +334,6 @@ nmt_page_bond_constructed (GObject *object)
{ {
NmtPageBond *bond = NMT_PAGE_BOND (object); NmtPageBond *bond = NMT_PAGE_BOND (object);
NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond); NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond);
NmtDeviceEntry *deventry;
NmtPageGrid *grid; NmtPageGrid *grid;
NMSettingBond *s_bond; NMSettingBond *s_bond;
NmtNewtWidget *widget, *label; NmtNewtWidget *widget, *label;
...@@ -348,11 +347,6 @@ nmt_page_bond_constructed (GObject *object) ...@@ -348,11 +347,6 @@ nmt_page_bond_constructed (GObject *object)
} }
priv->s_bond = s_bond; 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); grid = NMT_PAGE_GRID (bond);
widget = nmt_newt_separator_new (); widget = nmt_newt_separator_new ();
......
...@@ -62,7 +62,6 @@ static void ...@@ -62,7 +62,6 @@ static void
nmt_page_bridge_constructed (GObject *object) nmt_page_bridge_constructed (GObject *object)
{ {
NmtPageBridge *bridge = NMT_PAGE_BRIDGE (object); NmtPageBridge *bridge = NMT_PAGE_BRIDGE (object);
NmtDeviceEntry *deventry;
NmtPageGrid *grid; NmtPageGrid *grid;
NMSettingBridge *s_bridge; NMSettingBridge *s_bridge;
NmtNewtWidget *widget, *label, *stp; NmtNewtWidget *widget, *label, *stp;
...@@ -75,11 +74,6 @@ nmt_page_bridge_constructed (GObject *object) ...@@ -75,11 +74,6 @@ nmt_page_bridge_constructed (GObject *object)
s_bridge = nm_connection_get_setting_bridge (conn); 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); grid = NMT_PAGE_GRID (bridge);
widget = nmt_newt_separator_new (); widget = nmt_newt_separator_new ();
......
...@@ -132,7 +132,6 @@ nmt_page_team_constructed (GObject *object) ...@@ -132,7 +132,6 @@ nmt_page_team_constructed (GObject *object)
{ {
NmtPageTeam *team = NMT_PAGE_TEAM (object); NmtPageTeam *team = NMT_PAGE_TEAM (object);
NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE (team); NmtPageTeamPrivate *priv = NMT_PAGE_TEAM_GET_PRIVATE (team);
NmtDeviceEntry *deventry;
NmtNewtGrid *grid; NmtNewtGrid *grid;
NMSettingTeam *s_team; NMSettingTeam *s_team;
NmtNewtWidget *widget; NmtNewtWidget *widget;
...@@ -146,11 +145,6 @@ nmt_page_team_constructed (GObject *object) ...@@ -146,11 +145,6 @@ nmt_page_team_constructed (GObject *object)
} }
priv->s_team = s_team; 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 (); widget = nmt_newt_grid_new ();
nmt_page_grid_append (NMT_PAGE_GRID (team), NULL, widget, NULL); nmt_page_grid_append (NMT_PAGE_GRID (team), NULL, widget, NULL);
......
...@@ -72,7 +72,6 @@ nmt_page_vlan_constructed (GObject *object) ...@@ -72,7 +72,6 @@ nmt_page_vlan_constructed (GObject *object)
{ {
NmtPageVlan *vlan = NMT_PAGE_VLAN (object); NmtPageVlan *vlan = NMT_PAGE_VLAN (object);
NmtPageVlanPrivate *priv = NMT_PAGE_VLAN_GET_PRIVATE (vlan); NmtPageVlanPrivate *priv = NMT_PAGE_VLAN_GET_PRIVATE (vlan);
NmtDeviceEntry *deventry;
NmtPageGrid *grid; NmtPageGrid *grid;
NMSettingWired *s_wired; NMSettingWired *s_wired;
NMSettingVlan *s_vlan; NMSettingVlan *s_vlan;
...@@ -95,14 +94,9 @@ nmt_page_vlan_constructed (GObject *object) ...@@ -95,14 +94,9 @@ nmt_page_vlan_constructed (GObject *object)
} }
priv->s_wired = g_object_ref_sink (s_wired); 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); 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); widget = parent = nmt_device_entry_new (_("Parent"), 40, G_TYPE_NONE);
nmt_device_entry_set_device_filter (NMT_DEVICE_ENTRY (widget), 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, ...@@ -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); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_INTERFACE_NAME);
return NM_SETTING_VERIFY_ERROR; return NM_SETTING_VERIFY_ERROR;
} }
if (!interface_name) { if (interface_name && strcmp (con_name, interface_name) != 0) {
/* 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) {
/* con_name and interface_name are different. It can be normalized by setting interface_name /* con_name and interface_name are different. It can be normalized by setting interface_name
* to con_name. */ * to con_name. */
g_set_error_literal (error, g_set_error_literal (error,
......
...@@ -2743,9 +2743,9 @@ test_connection_normalize_virtual_iface_name (void) ...@@ -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_connection_get_interface_name (con), ==, IFACE_NAME);
g_assert_cmpstr (nm_setting_vlan_get_interface_name (s_vlan), ==, NULL); 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_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); 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 ...@@ -146,7 +146,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
} }
dev_iface_name = nm_device_get_iface (device); 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) { if (g_strcmp0 (dev_iface_name, bond_iface_name) != 0) {
g_set_error (error, NM_DEVICE_BOND_ERROR, NM_DEVICE_BOND_ERROR_INTERFACE_MISMATCH, 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."); "The interfaces of the device and the connection didn't match.");
......
...@@ -146,7 +146,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro ...@@ -146,7 +146,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
} }
dev_iface_name = nm_device_get_iface (device); 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) { if (g_strcmp0 (dev_iface_name, bridge_iface_name) != 0) {
g_set_error (error, NM_DEVICE_BRIDGE_ERROR, NM_DEVICE_BRIDGE_ERROR_INTERFACE_MISMATCH, 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."); "The interfaces of the device and the connection didn't match.");
......
...@@ -152,7 +152,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro ...@@ -152,7 +152,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
} }
dev_iface_name = nm_device_get_iface (device); 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) { if (g_strcmp0 (dev_iface_name, team_iface_name) != 0) {
g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH, 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."); "The interfaces of the device and the connection didn't match.");
......
...@@ -150,7 +150,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro ...@@ -150,7 +150,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
} }
dev_iface_name = nm_device_get_iface (device); 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) { 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, 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."); "The interfaces of the device and the connection didn't match.");
......
...@@ -127,7 +127,8 @@ complete_connection (NMDevice *device, ...@@ -127,7 +127,8 @@ complete_connection (NMDevice *device,
const GSList *existing_connections, const GSList *existing_connections,
GError **error) GError **error)
{ {
NMSettingBond *s_bond, *tmp; NMSettingBond *s_bond;
NMSettingConnection *s_con;
guint32 i = 0; guint32 i = 0;
char *name; char *name;
const GSList *iter; const GSList *iter;
...@@ -145,11 +146,13 @@ complete_connection (NMDevice *device, ...@@ -145,11 +146,13 @@ complete_connection (NMDevice *device,
s_bond = (NMSettingBond *) nm_setting_bond_new (); s_bond = (NMSettingBond *) nm_setting_bond_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bond)); 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 /* Grab the first name that doesn't exist in either our connections
* or a device on the system. * 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); name = g_strdup_printf ("bond%u", i);
/* check interface names */ /* check interface names */
if (!nm_platform_link_exists (name)) { if (!nm_platform_link_exists (name)) {
...@@ -157,9 +160,8 @@ complete_connection (NMDevice *device, ...@@ -157,9 +160,8 @@ complete_connection (NMDevice *device,
for (iter = existing_connections, found = FALSE; iter; iter = g_slist_next (iter)) { for (iter = existing_connections, found = FALSE; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = iter->data; NMConnection *candidate = iter->data;
tmp = nm_connection_get_setting_bond (candidate); if (nm_connection_is_type (candidate, NM_SETTING_BOND_SETTING_NAME)) {
if (tmp && nm_connection_is_type (candidate, NM_SETTING_BOND_SETTING_NAME)) {