/*
- * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return SSET_NODE_FROM_HMAP_NODE(hmap_node);
}
-static int
-compare_string_pointers(const void *a_, const void *b_)
-{
- const char *const *a = a_;
- const char *const *b = b_;
-
- return strcmp(*a, *b);
-}
-
-/* Returns a null-terminated array of pointers to the strings in 'set', sorted
- * alphabetically. The caller must free the returned array when it is no
+/* Returns a null-terminated array of pointers to the strings in 'set', in no
+ * particular order. The caller must free the returned array when it is no
* longer needed, but the strings in the array belong to 'set' and thus must
* not be modified or freed. */
const char **
-sset_sort(const struct sset *set)
+sset_array(const struct sset *set)
{
size_t n = sset_count(set);
const char **array;
ovs_assert(i == n);
array[n] = NULL;
- qsort(array, n, sizeof *array, compare_string_pointers);
+ return array;
+}
+
+static int
+compare_string_pointers(const void *a_, const void *b_)
+{
+ const char *const *a = a_;
+ const char *const *b = b_;
+
+ return strcmp(*a, *b);
+}
+/* Returns a null-terminated array of pointers to the strings in 'set', sorted
+ * alphabetically. The caller must free the returned array when it is no
+ * longer needed, but the strings in the array belong to 'set' and thus must
+ * not be modified or freed. */
+const char **
+sset_sort(const struct sset *set)
+{
+ const char **array = sset_array(set);
+ qsort(array, sset_count(set), sizeof *array, compare_string_pointers);
return array;
}
/*
- * Copyright (c) 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2011, 2012, 2013, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
: false); \
(NAME) = (NEXT))
+const char **sset_array(const struct sset *);
const char **sset_sort(const struct sset *);
\f
/* Implementation helper macros. */
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
+
#include "async-append.h"
#include "bfd.h"
#include "bitmap.h"
#include "coverage.h"
#include "daemon.h"
#include "dirs.h"
+#include "dpif.h"
#include "dynamic-string.h"
#include "hash.h"
#include "hmap.h"
const struct ovsrec_interface *);
static ofp_port_t iface_pick_ofport(const struct ovsrec_interface *);
+
/* Linux VLAN device support (e.g. "eth0.10" for VLAN 10.)
*
* This is deprecated. It is only for compatibility with broken device drivers
const unsigned long int *splinter_vlans,
struct shash *ports);
+static void discover_types(const struct ovsrec_open_vswitch *cfg);
+
static void
bridge_init_ofproto(const struct ovsrec_open_vswitch *cfg)
{
ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_cur_cfg);
ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_statistics);
+ ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_datapath_types);
+ ovsdb_idl_omit_alert(idl, &ovsrec_open_vswitch_col_iface_types);
ovsdb_idl_omit(idl, &ovsrec_open_vswitch_col_external_ids);
ovsdb_idl_omit(idl, &ovsrec_open_vswitch_col_ovs_version);
ovsdb_idl_omit(idl, &ovsrec_open_vswitch_col_db_version);
smap_get_int(&ovs_cfg->other_config, "n-handler-threads", 0),
smap_get_int(&ovs_cfg->other_config, "n-revalidator-threads", 0));
+ if (ovs_cfg) {
+ discover_types(ovs_cfg);
+ }
+
/* Destroy "struct bridge"s, "struct port"s, and "struct iface"s according
* to 'ovs_cfg', with only very minimal configuration otherwise.
*
if (cfg) {
ovsrec_open_vswitch_set_cur_cfg(cfg, cfg->next_cfg);
+ discover_types(cfg);
}
/* If we are completing our initial configuration for this run
ovsrec_mirror_set_statistics(m->cfg, keys, values, stat_cnt);
}
+
+/*
+ * Add registered netdev and dpif types to ovsdb to allow external
+ * applications to query the capabilities of the Open vSwitch instance
+ * running on the node.
+ */
+static void
+discover_types(const struct ovsrec_open_vswitch *cfg)
+{
+ struct sset types;
+
+ /* Datapath types. */
+ sset_init(&types);
+ dp_enumerate_types(&types);
+ const char **datapath_types = sset_array(&types);
+ ovsrec_open_vswitch_set_datapath_types(cfg, datapath_types,
+ sset_count(&types));
+ free(datapath_types);
+ sset_destroy(&types);
+
+ /* Port types. */
+ sset_init(&types);
+ netdev_enumerate_types(&types);
+ const char **iface_types = sset_array(&types);
+ ovsrec_open_vswitch_set_iface_types(cfg, iface_types, sset_count(&types));
+ free(iface_types);
+ sset_destroy(&types);
+}
{"name": "Open_vSwitch",
- "version": "7.11.2",
- "cksum": "320332148 22294",
+ "version": "7.12.1",
+ "cksum": "2211824403 22535",
"tables": {
"Open_vSwitch": {
"columns": {
"min": 0, "max": 1}},
"system_version": {
"type": {"key": {"type": "string"},
- "min": 0, "max": 1}}},
+ "min": 0, "max": 1}},
+ "datapath_types": {
+ "type": {"key": {"type": "string"},
+ "min": 0, "max": "unlimited"}},
+ "iface_types": {
+ "type": {"key": {"type": "string"},
+ "min": 0, "max": "unlimited"}}},
"isRoot": true,
"maxRows": 1},
"Bridge": {
</group>
+ <group title="Capabilities">
+ <p>
+ These columns report capabilities of the Open vSwitch instance.
+ </p>
+ <column name="datapath_types">
+ <p>
+ This column reports the different dpifs registered with the system.
+ These are the values that this instance supports in the <ref
+ column="datapath_type" table="Bridge"/> column of the <ref
+ table="Bridge"/> table.
+ </p>
+ </column>
+ <column name="iface_types">
+ <p>
+ This column reports the different netdevs registered with the system.
+ These are the values that this instance supports in the <ref
+ column="type" table="Interface"/> column of the <ref
+ table="Interface"/> table.
+ </p>
+ </column>
+ </group>
+
<group title="Database Configuration">
<p>
These columns primarily configure the Open vSwitch database
<group title="Other Features">
<column name="datapath_type">
- Name of datapath provider. The kernel datapath has
- type <code>system</code>. The userspace datapath has
- type <code>netdev</code>.
+ Name of datapath provider. The kernel datapath has type
+ <code>system</code>. The userspace datapath has type
+ <code>netdev</code>. A manager may refer to the <ref
+ table="Open_vSwitch" column="datapath_types"/> column of the <ref
+ table="Open_vSwitch"/> table for a list of the types accepted by this
+ Open vSwitch instance.
</column>
<column name="external_ids" key="bridge-id">
<group title="System-Specific Details">
<column name="type">
<p>
- The interface type, one of:
+ The interface type. The types supported by a particular instance of
+ Open vSwitch are listed in the <ref table="Open_vSwitch"
+ column="iface_types"/> column in the <ref table="Open_vSwitch"/>
+ table. The following types are defined:
</p>
<dl>