diff options
| author | Michael Biebl <biebl@debian.org> | 2011-03-18 20:17:47 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2011-03-18 20:17:47 +0100 |
| commit | e22c6e05e9ebc6cce941762020c5710b8014677b (patch) | |
| tree | 7e9fd7f8ae24a94b03f683e0cef9a346968e1e8b /system-settings/plugins/ifupdown | |
| parent | a6b89d35fabd9f5934b84d7cde22e9268f92c3d3 (diff) | |
Imported Upstream version 0.8.3.998 upstream/0.8.3.998
Diffstat (limited to 'system-settings/plugins/ifupdown')
| -rw-r--r-- | system-settings/plugins/ifupdown/Makefile.in | 5 | ||||
| -rw-r--r-- | system-settings/plugins/ifupdown/interface_parser.c | 6 | ||||
| -rw-r--r-- | system-settings/plugins/ifupdown/plugin.c | 51 | ||||
| -rw-r--r-- | system-settings/plugins/ifupdown/tests/Makefile.in | 5 |
4 files changed, 65 insertions, 2 deletions
diff --git a/system-settings/plugins/ifupdown/Makefile.in b/system-settings/plugins/ifupdown/Makefile.in index de327e6e..590d62a3 100644 --- a/system-settings/plugins/ifupdown/Makefile.in +++ b/system-settings/plugins/ifupdown/Makefile.in @@ -258,6 +258,10 @@ MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ +NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ +NM_MICRO_VERSION = @NM_MICRO_VERSION@ +NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_VERSION = @NM_VERSION@ NSS_CFLAGS = @NSS_CFLAGS@ NSS_LIBS = @NSS_LIBS@ OBJDUMP = @OBJDUMP@ @@ -272,6 +276,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_PATH = @PKGCONFIG_PATH@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ diff --git a/system-settings/plugins/ifupdown/interface_parser.c b/system-settings/plugins/ifupdown/interface_parser.c index 4635db2c..9be853a4 100644 --- a/system-settings/plugins/ifupdown/interface_parser.c +++ b/system-settings/plugins/ifupdown/interface_parser.c @@ -51,6 +51,7 @@ void add_block(const char *type, const char* name) void add_data(const char *key,const char *data) { if_data *ret; + char *idx; // Check if there is a block where we can attach our data if (first == NULL) @@ -58,6 +59,11 @@ void add_data(const char *key,const char *data) ret = (if_data*) calloc(1,sizeof(struct _if_data)); ret->key = g_strdup(key); + // Normalize keys. Convert '_' to '-', as ifupdown accepts both variants. + // When querying keys via ifparser_getkey(), use '-'. + while ((idx = strrchr(ret->key, '_'))) { + *idx = '-'; + } ret->data = g_strdup(data); if (last->info == NULL) 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; } diff --git a/system-settings/plugins/ifupdown/tests/Makefile.in b/system-settings/plugins/ifupdown/tests/Makefile.in index cb08914e..b6db0bdc 100644 --- a/system-settings/plugins/ifupdown/tests/Makefile.in +++ b/system-settings/plugins/ifupdown/tests/Makefile.in @@ -184,6 +184,10 @@ MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ +NM_MAJOR_VERSION = @NM_MAJOR_VERSION@ +NM_MICRO_VERSION = @NM_MICRO_VERSION@ +NM_MINOR_VERSION = @NM_MINOR_VERSION@ +NM_VERSION = @NM_VERSION@ NSS_CFLAGS = @NSS_CFLAGS@ NSS_LIBS = @NSS_LIBS@ OBJDUMP = @OBJDUMP@ @@ -198,6 +202,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_PATH = @PKGCONFIG_PATH@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ |