summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2013-05-08 20:29:36 +0200
committerMichael Biebl <biebl@debian.org>2013-05-08 20:29:40 +0200
commit856d8681bc56bc4e08bf5f9d91b7d6fb2716ac04 (patch)
treebd4a685549020b1ccc316af7905e4b0ba0370461
parenta31bbc6cf90b0f32bfd43bdc2e685b6874c3bda1 (diff)
Fix ifupdown plugin to recalculate unmanaged specs on interface changes
Patches cherry-picked from upstream Git. (Closes: #707070)
-rw-r--r--debian/changelog2
-rw-r--r--debian/patches/08-ifupdown-clarify-name-of-connections-hash.patch130
-rw-r--r--debian/patches/09-ifupdown-fix-naming-confusion-in-plugin-hash-tables.patch134
-rw-r--r--debian/patches/10-ifupdown-recalculate-unmanaged-specs-on-interface-ch.patch58
-rw-r--r--debian/patches/series4
5 files changed, 327 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index 5a914ffd..5041363a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ network-manager (0.9.8.0-5) UNRELEASED; urgency=low
   * Remove old code for upgrading from pre-squeeze versions.
   * Look harder for machine-id, and generate random DUID if it doesn't exist.
     Patch cherry-picked from upstream Git. (Closes: #707204) (bgo: #696109)
+  * Fix ifupdown plugin to recalculate unmanaged specs on interface changes.
+    Patches cherry-picked from upstream Git. (Closes: #707070)
 
  -- Michael Biebl <biebl@debian.org>  Tue, 07 May 2013 06:41:41 +0200
 
diff --git a/debian/patches/08-ifupdown-clarify-name-of-connections-hash.patch b/debian/patches/08-ifupdown-clarify-name-of-connections-hash.patch
new file mode 100644
index 00000000..3d1f81c7
--- /dev/null
+++ b/debian/patches/08-ifupdown-clarify-name-of-connections-hash.patch
@@ -0,0 +1,130 @@
+From 8128a3ada73a9572fa00ea02bd6a8a431157d312 Mon Sep 17 00:00:00 2001
+From: Dan Williams <dcbw@redhat.com>
+Date: Tue, 7 May 2013 15:08:00 -0500
+Subject: [PATCH 1/3] ifupdown: clarify name of connections hash
+
+'iface_connections' is really the list of all NMIfupdownConnections
+known to the plugin, read from /e/n/i and hashed by block name.  Since
+ifupdown doesn't store anything *except* connections from /e/n/i,
+just rename it to 'connections' to reduce confusion with the
+well_known_interfaces and well_known_ifaces hashes.
+---
+ src/settings/plugins/ifupdown/plugin.c |   46 +++++++++++++++-----------------
+ 1 file changed, 21 insertions(+), 25 deletions(-)
+
+diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c
+index 4dbb0aa..41eec9c 100644
+--- a/src/settings/plugins/ifupdown/plugin.c
++++ b/src/settings/plugins/ifupdown/plugin.c
+@@ -73,7 +73,7 @@
+ typedef struct {
+ 	GUdevClient *client;
+ 
+-	GHashTable *iface_connections;
++	GHashTable *connections;  /* /e/n/i block name :: NMIfupdownConnection */
+ 	gchar* hostname;
+ 
+ 	GHashTable *well_known_interfaces;
+@@ -243,7 +243,7 @@ udev_device_added (SCPluginIfupdown *self, GUdevDevice *device)
+ 	/* if we have a configured connection for this particular iface
+ 	 * we want to either unmanage the device or lock it
+ 	 */
+-	exported = (NMIfupdownConnection *) g_hash_table_lookup (priv->iface_connections, iface);
++	exported = g_hash_table_lookup (priv->connections, iface);
+ 	if (!exported && !g_hash_table_lookup (priv->well_known_interfaces, iface)) {
+ 		PLUGIN_PRINT("SCPlugin-Ifupdown",
+ 			"device added (path: %s, iface: %s): no ifupdown configuration found.", path, iface);
+@@ -313,12 +313,15 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
+ 	GKeyFile* keyfile;
+ 	GError *error = NULL;
+ 	GList *keys, *iter;
++	GHashTableIter con_iter;
++	const char *block_name;
++	NMIfupdownConnection *connection;
+ 	const char *subsys[2] = { "net", NULL };
+ 
+ 	auto_ifaces = g_hash_table_new (g_str_hash, g_str_equal);
+ 
+-	if(!priv->iface_connections)
+-		priv->iface_connections = g_hash_table_new (g_str_hash, g_str_equal);
++	if(!priv->connections)
++		priv->connections = g_hash_table_new (g_str_hash, g_str_equal);
+ 
+ 	if(!priv->well_known_ifaces)
+ 		priv->well_known_ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+@@ -399,18 +402,18 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
+ 			}
+ 
+ 			/* Remove any connection for this block that was previously found */
+-			exported = g_hash_table_lookup (priv->iface_connections, block->name);
++			exported = g_hash_table_lookup (priv->connections, block->name);
+ 			if (exported) {
+-				PLUGIN_PRINT("SCPlugin-Ifupdown", "deleting %s from iface_connections", block->name);
++				PLUGIN_PRINT("SCPlugin-Ifupdown", "deleting %s from connections", block->name);
+ 				nm_settings_connection_delete (NM_SETTINGS_CONNECTION (exported), ignore_cb, NULL);
+-				g_hash_table_remove (priv->iface_connections, block->name);
++				g_hash_table_remove (priv->connections, block->name);
+ 			}
+ 
+ 			/* add the new connection */
+ 			exported = nm_ifupdown_connection_new (block);
+ 			if (exported) {
+-				PLUGIN_PRINT("SCPlugin-Ifupdown", "adding %s to iface_connections", block->name);
+-				g_hash_table_insert (priv->iface_connections, block->name, exported);
++				PLUGIN_PRINT("SCPlugin-Ifupdown", "adding %s to connections", block->name);
++				g_hash_table_insert (priv->connections, block->name, exported);
+ 			}
+ 			PLUGIN_PRINT("SCPlugin-Ifupdown", "adding iface %s to well_known_interfaces", block->name);
+ 			g_hash_table_insert (priv->well_known_interfaces, block->name, "known");
+@@ -423,23 +426,16 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
+ 	}
+ 
+ 	/* Make 'auto' interfaces autoconnect=TRUE */
+-	keys = g_hash_table_get_keys (priv->iface_connections);
+-	for (iter = keys; iter; iter = g_list_next (iter)) {
+-		NMIfupdownConnection *exported;
++	g_hash_table_iter_init (&con_iter, priv->connections);
++	while (g_hash_table_iter_next (&con_iter, (gpointer) &block_name, (gpointer) &connection)) {
+ 		NMSettingConnection *setting;
+ 
+-		if (!g_hash_table_lookup (auto_ifaces, iter->data))
+-			continue;
+-
+-		exported = g_hash_table_lookup (priv->iface_connections, iter->data);
+-		setting = nm_connection_get_setting_connection (NM_CONNECTION (exported));
+-		g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
+-
+-		nm_settings_connection_commit_changes (NM_SETTINGS_CONNECTION (exported), ignore_cb, NULL);
+-
+-		PLUGIN_PRINT("SCPlugin-Ifupdown", "autoconnect");
++		if (g_hash_table_lookup (auto_ifaces, block_name)) {
++			setting = nm_connection_get_setting_connection (NM_CONNECTION (connection));
++			g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
++			PLUGIN_PRINT("SCPlugin-Ifupdown", "autoconnect");
++		}
+ 	}
+-	g_list_free (keys);
+ 	g_hash_table_destroy (auto_ifaces);
+ 
+ 	/* Read the config file to find out whether to manage interfaces */
+@@ -483,7 +479,7 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
+ 
+ 	/* Now if we're running in managed mode, let NM know there are new connections */
+ 	if (!priv->unmanage_well_known) {
+-		GList *con_list = g_hash_table_get_values (priv->iface_connections);
++		GList *con_list = g_hash_table_get_values (priv->connections);
+ 		GList *cl_iter;
+ 
+ 		for (cl_iter = con_list; cl_iter; cl_iter = g_list_next (cl_iter)) {
+@@ -516,7 +512,7 @@ SCPluginIfupdown_get_connections (NMSystemConfigInterface *config)
+ 		return NULL;
+ 	}
+ 
+-	g_hash_table_iter_init (&iter, priv->iface_connections);
++	g_hash_table_iter_init (&iter, priv->connections);
+ 	while (g_hash_table_iter_next (&iter, NULL, &value))
+ 		connections = g_slist_prepend (connections, value);
+ 
+-- 
+1.7.10.4
+
diff --git a/debian/patches/09-ifupdown-fix-naming-confusion-in-plugin-hash-tables.patch b/debian/patches/09-ifupdown-fix-naming-confusion-in-plugin-hash-tables.patch
new file mode 100644
index 00000000..b0576f6f
--- /dev/null
+++ b/debian/patches/09-ifupdown-fix-naming-confusion-in-plugin-hash-tables.patch
@@ -0,0 +1,134 @@
+From 3dab0094b2296e07d8ccc3e80025b88a2f493f95 Mon Sep 17 00:00:00 2001
+From: Dan Williams <dcbw@redhat.com>
+Date: Tue, 7 May 2013 15:22:55 -0500
+Subject: [PATCH 2/3] ifupdown: fix naming confusion in plugin hash tables
+
+well_known_interfaces -> eni_ifaces, since it's a hash of any
+interfaces read from /etc/network/interfaces.
+
+well_known_ifaces -> kernel_ifaces, since it's a hash of any
+network subsystem interface the kernel knows about
+---
+ src/settings/plugins/ifupdown/plugin.c |   48 ++++++++++++++++++--------------
+ 1 file changed, 27 insertions(+), 21 deletions(-)
+
+diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c
+index 41eec9c..8c24b2c 100644
+--- a/src/settings/plugins/ifupdown/plugin.c
++++ b/src/settings/plugins/ifupdown/plugin.c
+@@ -76,8 +76,14 @@ typedef struct {
+ 	GHashTable *connections;  /* /e/n/i block name :: NMIfupdownConnection */
+ 	gchar* hostname;
+ 
+-	GHashTable *well_known_interfaces;
+-	GHashTable *well_known_ifaces;
++	/* Stores all blocks/interfaces read from /e/n/i regardless of whether
++	 * there is an NMIfupdownConnection for block.
++	 */
++	GHashTable *eni_ifaces;
++
++	/* Stores any network interfaces the kernel knows about */
++	GHashTable *kernel_ifaces;
++
+ 	gboolean unmanage_well_known;
+ 	char *conf_file;
+ 
+@@ -244,13 +250,13 @@ udev_device_added (SCPluginIfupdown *self, GUdevDevice *device)
+ 	 * we want to either unmanage the device or lock it
+ 	 */
+ 	exported = g_hash_table_lookup (priv->connections, iface);
+-	if (!exported && !g_hash_table_lookup (priv->well_known_interfaces, iface)) {
++	if (!exported && !g_hash_table_lookup (priv->eni_ifaces, iface)) {
+ 		PLUGIN_PRINT("SCPlugin-Ifupdown",
+ 			"device added (path: %s, iface: %s): no ifupdown configuration found.", path, iface);
+ 		return;
+ 	}
+ 
+-	g_hash_table_insert (priv->well_known_ifaces, g_strdup (iface), g_object_ref (device));
++	g_hash_table_insert (priv->kernel_ifaces, g_strdup (iface), g_object_ref (device));
+ 
+ 	if (exported)
+ 		bind_device_to_connection (self, device, exported);
+@@ -273,7 +279,7 @@ udev_device_removed (SCPluginIfupdown *self, GUdevDevice *device)
+ 	PLUGIN_PRINT("SCPlugin-Ifupdown",
+ 	             "devices removed (path: %s, iface: %s)", path, iface);
+ 
+-	if (!g_hash_table_remove (priv->well_known_ifaces, iface))
++	if (!g_hash_table_remove (priv->kernel_ifaces, iface))
+ 		return;
+ 
+ 	if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
+@@ -323,11 +329,11 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
+ 	if(!priv->connections)
+ 		priv->connections = g_hash_table_new (g_str_hash, g_str_equal);
+ 
+-	if(!priv->well_known_ifaces)
+-		priv->well_known_ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
++	if(!priv->kernel_ifaces)
++		priv->kernel_ifaces = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+ 
+-	if(!priv->well_known_interfaces)
+-		priv->well_known_interfaces = g_hash_table_new (g_str_hash, g_str_equal);
++	if(!priv->eni_ifaces)
++		priv->eni_ifaces = g_hash_table_new (g_str_hash, g_str_equal);
+ 
+ 	PLUGIN_PRINT("SCPlugin-Ifupdown", "init!");
+ 
+@@ -387,8 +393,8 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
+ 							continue;
+ 						}
+ 						if (state == 0 && strlen (token) > 0) {
+-							PLUGIN_PRINT("SCPlugin-Ifupdown", "adding bridge port %s to well_known_interfaces", token);
+-							g_hash_table_insert (priv->well_known_interfaces, g_strdup (token), "known");
++							PLUGIN_PRINT("SCPlugin-Ifupdown", "adding bridge port %s to eni_ifaces", token);
++							g_hash_table_insert (priv->eni_ifaces, g_strdup (token), "known");
+ 						}
+ 					}
+ 					g_strfreev (port_ifaces);
+@@ -415,11 +421,11 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
+ 				PLUGIN_PRINT("SCPlugin-Ifupdown", "adding %s to connections", block->name);
+ 				g_hash_table_insert (priv->connections, block->name, exported);
+ 			}
+-			PLUGIN_PRINT("SCPlugin-Ifupdown", "adding iface %s to well_known_interfaces", block->name);
+-			g_hash_table_insert (priv->well_known_interfaces, block->name, "known");
++			PLUGIN_PRINT("SCPlugin-Ifupdown", "adding iface %s to eni_ifaces", block->name);
++			g_hash_table_insert (priv->eni_ifaces, block->name, "known");
+ 		} else if (!strcmp ("mapping", block->type)) {
+-			g_hash_table_insert (priv->well_known_interfaces, block->name, "known");
+-			PLUGIN_PRINT("SCPlugin-Ifupdown", "adding mapping %s to well_known_interfaces", block->name);
++			g_hash_table_insert (priv->eni_ifaces, block->name, "known");
++			PLUGIN_PRINT("SCPlugin-Ifupdown", "adding mapping %s to eni_ifaces", block->name);
+ 		}
+ 	next:
+ 		block = block->next;
+@@ -537,9 +543,9 @@ SCPluginIfupdown_get_unmanaged_specs (NMSystemConfigInterface *config)
+ 		return NULL;
+ 
+ 	PLUGIN_PRINT("Ifupdown", "get unmanaged devices count: %d",
+-	             g_hash_table_size (priv->well_known_ifaces));
++	             g_hash_table_size (priv->kernel_ifaces));
+ 
+-	g_hash_table_iter_init (&iter, priv->well_known_ifaces);
++	g_hash_table_iter_init (&iter, priv->kernel_ifaces);
+ 	while (g_hash_table_iter_next (&iter, NULL, &value)) {
+ 		GUdevDevice *device = G_UDEV_DEVICE (value);
+ 		const char *address;
+@@ -685,11 +691,11 @@ GObject__dispose (GObject *object)
+ 	if (priv->inotify_system_hostname_wd >= 0)
+ 		nm_inotify_helper_remove_watch (inotify_helper, priv->inotify_system_hostname_wd);
+ 
+-	if (priv->well_known_ifaces)
+-		g_hash_table_destroy(priv->well_known_ifaces);
++	if (priv->kernel_ifaces)
++		g_hash_table_destroy(priv->kernel_ifaces);
+ 
+-	if (priv->well_known_interfaces)
+-		g_hash_table_destroy(priv->well_known_interfaces);
++	if (priv->eni_ifaces)
++		g_hash_table_destroy(priv->eni_ifaces);
+ 
+ 	g_free (priv->conf_file);
+ 
+-- 
+1.7.10.4
+
diff --git a/debian/patches/10-ifupdown-recalculate-unmanaged-specs-on-interface-ch.patch b/debian/patches/10-ifupdown-recalculate-unmanaged-specs-on-interface-ch.patch
new file mode 100644
index 00000000..4c2b2fc8
--- /dev/null
+++ b/debian/patches/10-ifupdown-recalculate-unmanaged-specs-on-interface-ch.patch
@@ -0,0 +1,58 @@
+From e2941724ba71096d11897d2e191efc4c415eacb3 Mon Sep 17 00:00:00 2001
+From: Dan Williams <dcbw@redhat.com>
+Date: Tue, 7 May 2013 15:33:59 -0500
+Subject: [PATCH 3/3] ifupdown: recalculate unmanaged specs on interface
+ change (debian #707070)
+
+If a kernel interface changes its MAC address, and NM is not
+supposed to manage that interface, ifupdown needs to notice
+that MAC address change and tell NM that the unmanaged devices
+have changed, so that NM continues to not touch the device
+after the MAC has changed.
+---
+ src/settings/plugins/ifupdown/plugin.c |   22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/settings/plugins/ifupdown/plugin.c b/src/settings/plugins/ifupdown/plugin.c
+index 8c24b2c..a46ea2e 100644
+--- a/src/settings/plugins/ifupdown/plugin.c
++++ b/src/settings/plugins/ifupdown/plugin.c
+@@ -287,6 +287,26 @@ udev_device_removed (SCPluginIfupdown *self, GUdevDevice *device)
+ }
+ 
+ static void
++udev_device_changed (SCPluginIfupdown *self, GUdevDevice *device)
++{
++	SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (self);
++	const char *iface, *path;
++
++	iface = g_udev_device_get_name (device);
++	path = g_udev_device_get_sysfs_path (device);
++	if (!iface || !path)
++		return;
++
++	PLUGIN_PRINT("SCPlugin-Ifupdown", "device changed (path: %s, iface: %s)", path, iface);
++
++	if (!g_hash_table_lookup (priv->kernel_ifaces, iface))
++		return;
++
++	if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
++		g_signal_emit_by_name (G_OBJECT (self), NM_SYSTEM_CONFIG_INTERFACE_UNMANAGED_SPECS_CHANGED);
++}
++
++static void
+ handle_uevent (GUdevClient *client,
+                const char *action,
+                GUdevDevice *device,
+@@ -306,6 +326,8 @@ handle_uevent (GUdevClient *client,
+ 		udev_device_added (self, device);
+ 	else if (!strcmp (action, "remove"))
+ 		udev_device_removed (self, device);
++	else if (!strcmp (action, "change"))
++		udev_device_changed (self, device);
+ }
+ 
+ static void
+-- 
+1.7.10.4
+
diff --git a/debian/patches/series b/debian/patches/series
index 4e6c3cb5..e4ca5cb5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,6 +1,8 @@
-# Debian patches for network-manager
 02-dbus_access_network_manager.patch
 03-systemd.patch
 05-force-online-with-unmanaged-devices.patch
 06-tear-down-connections-for-unavailable-devices.patch
 07-duid-fallback.patch
+08-ifupdown-clarify-name-of-connections-hash.patch
+09-ifupdown-fix-naming-confusion-in-plugin-hash-tables.patch
+10-ifupdown-recalculate-unmanaged-specs-on-interface-ch.patch