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 */
......
This diff is collapsed.
......@@ -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);
/* 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 */
......
......@@ -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++) {
......
......@@ -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)) {
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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);