core: allow connection assumption on pre-configured software devices

In the specific case that triggered this bug, both eth0 and eth0.123
existed and were configured before NM started, and a valid saved connection
existed for eth0.123.  eth0 was ordered before eth0.123 in the Platform's
link list.  When the end of add_devices() was reached for eth0 and
system_create_virtual_devices() was called, NM created an NMDevice for
the pre-existing eth0.123 link due to the saved connection, and
ignored the existing configuration because system_create_virtual_device()
re-calls add_device() with generate_con = FALSE.

Instead, we should allow system_create_virtual_device() to call add_device()
with generate_con = TRUE if the interface existed before NM created it. We
only want to skip connection assumption if the device was actually just
created by NM, in which case it cannot have any configuration to assume.
This commit is contained in:
Dan Williams 2014-08-19 14:23:47 -05:00
parent af13376e2b
commit a175ff090c

View file

@ -1078,6 +1078,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
GSList *iter;
char *iface = NULL;
NMDevice *device = NULL, *parent = NULL;
gboolean nm_owned = FALSE;
iface = get_virtual_iface_name (self, connection, &parent);
if (!iface) {
@ -1101,6 +1102,8 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
*/
priv->ignore_link_added_cb++;
nm_owned = !nm_platform_link_exists (iface);
if (nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)) {
device = nm_device_bond_new_for_connection (connection);
} else if (nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME)) {
@ -1127,8 +1130,14 @@ system_create_virtual_device (NMManager *self, NMConnection *connection)
}
if (device) {
nm_device_set_nm_owned (device);
add_device (self, device, FALSE);
if (nm_owned)
nm_device_set_nm_owned (device);
/* If it was created by NM there's no connection to assume, but if it
* previously existed there might be one.
*/
add_device (self, device, !nm_owned);
g_object_unref (device);
}