From a175ff090cac3172f9e194335fac38056e046504 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 19 Aug 2014 14:23:47 -0500 Subject: [PATCH] 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. --- src/nm-manager.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 842fba998c..6b8ed909ac 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -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); }