possibly ifcfg-rh: fix missing connections if unmanaged interface was present



Below is patch for ifcfg-mdv (Mandriva plugin that is currently
in development). Plugin was forked off ifcfg-rh and this part
is mostly unchanged. From code review the same problem should
be present in ifcfg-rh as well.

To reproduce - take the first ifcfg file in directory scan order
and set it as unmanaged. In my case it results in no system
connections being displayed by NM.

---

NM starts plugin initialization by requesting list of
unmanaged interfaces. ifcfg-mdv reads in interface list on
demand either in get_connections() or in get_unmanaged_specs().
What now happens is:

get_unmanaged_specs() -> read_connections() -> read_one_connection()
-> signal("unmanaged-specs-changed") -> unmanaged_specs_changed()
-> nm_sysconfig_settings_get_unmanaged_specs() -> load_connections()
-> get_connections()

Now ifcfg-mdv get_connections() will see non-empty connection
hash table and return whatever is available. load_connections()
will mark connections as loaded and never re-request it. And
read_one_connection() never signals that connection was added so
NM will never notice existence of connections added *after* the
first unmanaged interface was found.

There are two places where read_one_connection() is called:
read_connections() and handle_connection_remove_or_new(). The
former is called exactly once on initialization and does not
need any signals - we want to read full list before interacting
with NM. Move signal("unmanaged-specs-changed") to the latter
from read_one_connection().

Signed-off-by: Andrey Borzenkov <arvidjaar gmail com>

---

 system-settings/plugins/ifcfg-mdv/plugin.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/system-settings/plugins/ifcfg-mdv/plugin.c b/system-settings/plugins/ifcfg-mdv/plugin.c
index 4b4667b..68a2c72 100644
--- a/system-settings/plugins/ifcfg-mdv/plugin.c
+++ b/system-settings/plugins/ifcfg-mdv/plugin.c
@@ -135,7 +135,6 @@ read_one_connection (SCPluginIfcfg *plugin, const char *filename)
 		if (nm_ifcfg_connection_get_unmanaged_spec (connection)) {
 			PLUGIN_PRINT (IFCFG_PLUGIN_NAME, "Ignoring connection '%s' and its "
 			              "device due to NM_CONTROLLED/ONBOOT/BRIDGE/VLAN.", cid);
-			g_signal_emit_by_name (plugin, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
 		} else {
 			/* Wait for the connection to become unmanaged once it knows the
 			 * UDI of it's device, if/when the device gets plugged in.
@@ -298,7 +297,9 @@ handle_connection_remove_or_new (SCPluginIfcfg *plugin,
 	if (do_new) {
 		connection = read_one_connection (plugin, path);
 		if (connection) {
-			if (!nm_ifcfg_connection_get_unmanaged_spec (connection))
+			if (nm_ifcfg_connection_get_unmanaged_spec (connection))
+				g_signal_emit_by_name (plugin, NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
+			else
 				g_signal_emit_by_name (plugin, NM_SYSTEM_CONFIG_INTERFACE_CONNECTION_ADDED, connection);
 		}
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]