From: Ben Pfaff Date: Wed, 11 Mar 2009 20:43:47 +0000 (-0700) Subject: vswitch: Disallow bridges named "dpN" or "nl:N". X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4b96c92c;p=openvswitch vswitch: Disallow bridges named "dpN" or "nl:N". Natasha discovered that naming a datapath numerically, e.g. "bridge.dp0.port = ", provokes an error. The easiest fix is to just disallow this. Fixes bug #1030. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index b3d552d2..e37e6856 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -307,17 +308,31 @@ bridge_configure_ssl(void) void bridge_reconfigure(void) { - struct svec old_br, new_br; + struct svec old_br, new_br, raw_new_br; struct bridge *br, *next; size_t i, j; - /* Collect old and new bridges. */ + /* Collect old bridges. */ svec_init(&old_br); - svec_init(&new_br); LIST_FOR_EACH (br, struct bridge, node, &all_bridges) { svec_add(&old_br, br->name); } - cfg_get_subsections(&new_br, "bridge"); + + /* Collect new bridges. */ + svec_init(&raw_new_br); + cfg_get_subsections(&raw_new_br, "bridge"); + svec_init(&new_br); + for (i = 0; i < raw_new_br.n; i++) { + const char *name = raw_new_br.names[i]; + if ((!strncmp(name, "dp", 2) && isdigit(name[2])) || + (!strncmp(name, "nl:", 3) && isdigit(name[3]))) { + VLOG_ERR("%s is not a valid bridge name (bridges may not be " + "named \"dp\" or \"nl:\" followed by a digit)", name); + } else { + svec_add(&new_br, name); + } + } + svec_destroy(&raw_new_br); /* Get rid of deleted bridges and add new bridges. */ svec_sort(&old_br); diff --git a/vswitchd/vswitchd.conf.5 b/vswitchd/vswitchd.conf.5 index 6792a43b..00c5c378 100644 --- a/vswitchd/vswitchd.conf.5 +++ b/vswitchd/vswitchd.conf.5 @@ -61,7 +61,8 @@ configure \fBswitchd\fR. .SS "Bridge Configuration" A bridge (switch) with a given \fIname\fR is configured by specifying the names of its network devices as values for key -\fBbridge.\fIname\fB.port\fR. +\fBbridge.\fIname\fB.port\fR. (The specified \fIname\fR may not begin +with \fBdp\fR or \fBnl:\fR followed by a digit.) .PP A bridge with a given \fIname\fR always has an associated network device with the same \fIname\fR. This network device may be included