aboutsummaryrefslogtreecommitdiff
path: root/lib/dpif.c
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2011-11-17 18:06:55 -0800
committerEthan Jackson <ethan@nicira.com>2011-11-18 13:48:57 -0800
commit579a77e024b93ba5dfb840468c2fcd804e576d7b (patch)
tree971171ac8ffd2432c8b748ba6e1fbeb2822b833a /lib/dpif.c
parent9d7c56431990fc56a1b26dd32c1e7a8d9258345f (diff)
tests: Allow unit tests to run as root.
The unit tests did not allow users to run them as root because ovs-vswitchd would destroy all of the existing 'system' datapaths. This patch prevents ovs-vswitchd from registering 'system' datapaths when running unit tests preventing the issue.
Diffstat (limited to 'lib/dpif.c')
-rw-r--r--lib/dpif.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/dpif.c b/lib/dpif.c
index cc6e805f..5f5417b7 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -68,6 +68,7 @@ struct registered_dpif_class {
int refcount;
};
static struct shash dpif_classes = SHASH_INITIALIZER(&dpif_classes);
+static struct sset dpif_blacklist = SSET_INITIALIZER(&dpif_blacklist);
/* Rate limit for individual messages going to or from the datapath, output at
* DBG level. This is very high because, if these are enabled, it is because
@@ -108,6 +109,12 @@ dp_register_provider(const struct dpif_class *new_class)
{
struct registered_dpif_class *registered_class;
+ if (sset_contains(&dpif_blacklist, new_class->type)) {
+ VLOG_DBG("attempted to register blacklisted provider: %s",
+ new_class->type);
+ return EINVAL;
+ }
+
if (shash_find(&dpif_classes, new_class->type)) {
VLOG_WARN("attempted to register duplicate datapath provider: %s",
new_class->type);
@@ -151,6 +158,14 @@ dp_unregister_provider(const char *type)
return 0;
}
+/* Blacklists a provider. Causes future calls of dp_register_provider() with
+ * a dpif_class which implements 'type' to fail. */
+void
+dp_blacklist_provider(const char *type)
+{
+ sset_add(&dpif_blacklist, type);
+}
+
/* Clears 'types' and enumerates the types of all currently registered datapath
* providers into it. The caller must first initialize the sset. */
void