summary refs log tree commit diff
path: root/system-settings/plugins/ifupdown/plugin.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2011-03-18 20:17:47 +0100
committerMichael Biebl <biebl@debian.org>2011-03-18 20:17:47 +0100
commite22c6e05e9ebc6cce941762020c5710b8014677b (patch)
tree7e9fd7f8ae24a94b03f683e0cef9a346968e1e8b /system-settings/plugins/ifupdown/plugin.c
parenta6b89d35fabd9f5934b84d7cde22e9268f92c3d3 (diff)
Imported Upstream version 0.8.3.998 upstream/0.8.3.998
Diffstat (limited to 'system-settings/plugins/ifupdown/plugin.c')
-rw-r--r--system-settings/plugins/ifupdown/plugin.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/system-settings/plugins/ifupdown/plugin.c b/system-settings/plugins/ifupdown/plugin.c
index 33c058e5..2446548c 100644
--- a/system-settings/plugins/ifupdown/plugin.c
+++ b/system-settings/plugins/ifupdown/plugin.c
@@ -362,12 +362,55 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
 	while (block) {
 		if(!strcmp ("auto", block->type) || !strcmp ("allow-hotplug", block->type))
 			g_hash_table_insert (auto_ifaces, block->name, GUINT_TO_POINTER (1));
-		else if (!strcmp ("iface", block->type) && strcmp ("lo", block->name)) {
+		else if (!strcmp ("iface", block->type)) {
 			NMIfupdownConnection *exported;
 
+			/* Bridge configuration */
+			if(!strncmp ("br", block->name, 2)) {
+				/* Try to find bridge ports */
+				const char *ports = ifparser_getkey (block, "bridge-ports");
+				if (ports) {
+					int i;
+					int state = 0;
+					char **port_ifaces;
+
+					PLUGIN_PRINT("SCPlugin-Ifupdown", "found bridge ports %s for %s", ports, block->name);
+
+					port_ifaces = g_strsplit_set (ports, " \t", -1);
+					for (i = 0; i < g_strv_length (port_ifaces); i++) {
+						char *token = port_ifaces[i];
+						/* Skip crazy stuff like regex or all */
+						if (!strcmp ("all", token)) {
+							continue;
+						}
+						/* Small SM to skip everything inside regex */
+						if (!strcmp ("regex", token)) {
+							state++;
+							continue;
+						}
+						if (!strcmp ("noregex", token)) {
+							state--;
+							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");
+						}
+					}
+					g_strfreev (port_ifaces);
+				}
+				goto next;
+			}
+
+			/* Skip loopback configuration */
+			if(!strcmp ("lo", block->name)) {
+				goto next;
+			}
+
 			/* Remove any connection for this block that was previously found */
 			exported = g_hash_table_lookup (priv->iface_connections, block->name);
 			if (exported) {
+				PLUGIN_PRINT("SCPlugin-Ifupdown", "deleting %s from iface_connections", block->name);
 				nm_settings_connection_interface_delete (NM_SETTINGS_CONNECTION_INTERFACE (exported),
 				                                         ignore_cb,
 				                                         NULL);
@@ -377,12 +420,16 @@ SCPluginIfupdown_init (NMSystemConfigInterface *config)
 			/* 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);
-				g_hash_table_insert (priv->well_known_interfaces, block->name, "known");
 			}
+			PLUGIN_PRINT("SCPlugin-Ifupdown", "adding iface %s to well_known_interfaces", block->name);
+			g_hash_table_insert (priv->well_known_interfaces, 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);
 		}
+	next:
 		block = block->next;
 	}