aboutsummaryrefslogtreecommitdiff
path: root/ovsdb
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-04-16 12:09:49 -0700
committerEthan Jackson <ethan@nicira.com>2012-04-17 13:36:01 -0700
commitcea157688977bbbb136f9c3bfe020fe485b43d39 (patch)
treec16b1d2ebe166b403720ada4c1a70f4bdc409ddf /ovsdb
parentef8a3d14976080fc5e29ce04bea8bd88f8b631f2 (diff)
vswitch: Use consistent representation of DSCP bits.
There are two sensible ways to represent the 6 DSCP bits of an IP packet. One could represent them as an integer in the range 0 to 63. Or one could represent them as they would appear in the tos field (0 to 63) << 2. Before this patch, OVS had used the former method for the DSCP bits in the Queue Table, and the latter for the DSCP in the Controller and Manager tables. Since the ability to set DSCP bits in the Controller and Manager tables is so new that it hasn't been released yet, this patch changes it to use the existing style employed in the Queue table. Hopefully this should make the code and configuration less confusing. Signed-off-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'ovsdb')
-rw-r--r--ovsdb/ovsdb-server.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 69940181..d8363a2c 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -319,12 +319,11 @@ get_datum(struct ovsdb_row *row, const char *column_name,
return &row->fields[column->index];
}
-/* This function is used to read the string-string key-values from a map.
- * Returns the true if the 'key' is found and returns the "value" associated
- * with the 'key' in 'stringp', else returns false. */
-static bool
+/* Read string-string key-values from a map. Returns the value associated with
+ * 'key', if found, or NULL */
+static const char *
read_map_string_column(const struct ovsdb_row *row, const char *column_name,
- const char **stringp, const char *key)
+ const char *key)
{
const struct ovsdb_datum *datum;
union ovsdb_atom *atom_key = NULL, *atom_value = NULL;
@@ -334,8 +333,7 @@ read_map_string_column(const struct ovsdb_row *row, const char *column_name,
OVSDB_TYPE_STRING, UINT_MAX);
if (!datum) {
- *stringp = NULL;
- return false;
+ return NULL;
}
for (i = 0; i < datum->n; i++) {
@@ -346,8 +344,7 @@ read_map_string_column(const struct ovsdb_row *row, const char *column_name,
}
}
- *stringp = atom_value ? atom_value->string : NULL;
- return atom_value != NULL;
+ return atom_value ? atom_value->string : NULL;
}
static const union ovsdb_atom *
@@ -427,21 +424,6 @@ write_string_string_column(struct ovsdb_row *row, const char *column_name,
ovsdb_datum_sort_assert(datum, column->type.key.type);
}
-/* Get the other config for the manager from the database. */
-static void
-manager_get_other_config(const struct ovsdb_row *row,
- struct ovsdb_jsonrpc_options *options)
-{
- const char *temp_string;
-
- /* Retrieve the configs and store in the options. */
- if (read_map_string_column(row, "other_config", &temp_string, "dscp")) {
- options->dscp = atoi(temp_string);
- } else {
- options->dscp = DSCP_DEFAULT;
- }
-}
-
/* Adds a remote and options to 'remotes', based on the Manager table row in
* 'row'. */
static void
@@ -450,7 +432,7 @@ add_manager_options(struct shash *remotes, const struct ovsdb_row *row)
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
struct ovsdb_jsonrpc_options *options;
long long int max_backoff, probe_interval;
- const char *target;
+ const char *target, *dscp_string;
if (!read_string_column(row, "target", &target) || !target) {
VLOG_INFO_RL(&rl, "Table `%s' has missing or invalid `target' column",
@@ -466,7 +448,14 @@ add_manager_options(struct shash *remotes, const struct ovsdb_row *row)
options->probe_interval = probe_interval;
}
- manager_get_other_config(row, options);
+ options->dscp = DSCP_DEFAULT;
+ dscp_string = read_map_string_column(row, "other_config", "dscp");
+ if (dscp_string) {
+ int dscp = atoi(dscp_string);
+ if (dscp >= 0 && dscp <= 63) {
+ options->dscp = dscp;
+ }
+ }
}
static void