summaryrefslogtreecommitdiff
path: root/lib/ofp-print.c
diff options
context:
space:
mode:
authorJesse Gross <jesse@nicira.com>2015-06-02 15:11:00 -0700
committerJesse Gross <jesse@nicira.com>2015-06-25 11:08:58 -0700
commit6159c531d09a19f5eb6865fc5221c04156aa0bf4 (patch)
tree406926cec3ff3b727a4924e768053047607692fa /lib/ofp-print.c
parent00fe22f85baf76f5a4dca0312d4a7d7c920065af (diff)
downloadopenvswitch-6159c531d09a19f5eb6865fc5221c04156aa0bf4.tar.gz
openflow: Table maintenance commands for Geneve options.
In order to work with Geneve options, we need to maintain a mapping table between an option (defined by <class, type, length>) and an NXM field that can be operated on for the purposes of matches, actions, etc. This mapping must be explicitly specified by the user. Conceptually, this table could be communicated using either OpenFlow or OVSDB. Using OVSDB requires less code and definition of extensions than OpenFlow but introduces the possibility that mapping table updates and flow modifications are desynchronized from each other. This is dangerous because the mapping table signifcantly impacts the way that flows using Geneve options are installed and processed by OVS. Therefore, the mapping table is maintained using OpenFlow commands instead, which opens the possibility of using synchronization between table changes and flow modifications through barriers, bundles, etc. There are two primary groups of OpenFlow messages that are introduced as Nicira extensions: modification commands (add, delete, clear mappings) and table status request/reply to dump the current table along with switch information. Note that mappings should not be changed while they are in active use by a flow. The result of doing so is undefined. This only adds the OpenFlow infrastructure but doesn't actually do anything with the information yet after the messages have been decoded. Signed-off-by: Jesse Gross <jesse@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/ofp-print.c')
-rw-r--r--lib/ofp-print.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 2ac11b1ea..1b25180e3 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -2642,6 +2642,85 @@ ofp_print_bundle_add(struct ds *s, const struct ofp_header *oh, int verbosity)
}
static void
+print_geneve_table(struct ds *s, struct ovs_list *mappings)
+{
+ struct ofputil_geneve_map *map;
+
+ ds_put_cstr(s, " mapping table:\n");
+ ds_put_cstr(s, " class\ttype\tlength\tmatch field\n");
+ ds_put_cstr(s, " -----\t----\t------\t-----------");
+
+ LIST_FOR_EACH (map, list_node, mappings) {
+ ds_put_char(s, '\n');
+ ds_put_format(s, " 0x%"PRIx16"\t0x%"PRIx8"\t%"PRIu8"\ttun_metadata%"PRIu16,
+ map->option_class, map->option_type, map->option_len,
+ map->index);
+ }
+}
+
+static void
+ofp_print_geneve_table_mod(struct ds *s, const struct ofp_header *oh)
+{
+ int error;
+ struct ofputil_geneve_table_mod gtm;
+
+ error = ofputil_decode_geneve_table_mod(oh, &gtm);
+ if (error) {
+ ofp_print_error(s, error);
+ return;
+ }
+
+ ds_put_cstr(s, "\n ");
+
+ switch (gtm.command) {
+ case NXGTMC_ADD:
+ ds_put_cstr(s, "ADD");
+ break;
+ case NXGTMC_DELETE:
+ ds_put_cstr(s, "DEL");
+ break;
+ case NXGTMC_CLEAR:
+ ds_put_cstr(s, "CLEAR");
+ break;
+ }
+
+ if (gtm.command != NXGTMC_CLEAR) {
+ print_geneve_table(s, &gtm.mappings);
+ }
+
+ ofputil_uninit_geneve_table(&gtm.mappings);
+}
+
+static void
+ofp_print_geneve_table_reply(struct ds *s, const struct ofp_header *oh)
+{
+ int error;
+ struct ofputil_geneve_table_reply gtr;
+ struct ofputil_geneve_map *map;
+ int allocated_space = 0;
+
+ error = ofputil_decode_geneve_table_reply(oh, &gtr);
+ if (error) {
+ ofp_print_error(s, error);
+ return;
+ }
+
+ ds_put_char(s, '\n');
+
+ LIST_FOR_EACH (map, list_node, &gtr.mappings) {
+ allocated_space += map->option_len;
+ }
+
+ ds_put_format(s, " max option space=%"PRIu32" max fields=%"PRIu16"\n",
+ gtr.max_option_space, gtr.max_fields);
+ ds_put_format(s, " allocated option space=%d\n", allocated_space);
+ ds_put_char(s, '\n');
+ print_geneve_table(s, &gtr.mappings);
+
+ ofputil_uninit_geneve_table(&gtr.mappings);
+}
+
+static void
ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw,
struct ds *string, int verbosity)
{
@@ -2899,6 +2978,18 @@ ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw,
case OFPTYPE_BUNDLE_ADD_MESSAGE:
ofp_print_bundle_add(string, msg, verbosity);
break;
+
+ case OFPTYPE_NXT_GENEVE_TABLE_MOD:
+ ofp_print_geneve_table_mod(string, msg);
+ break;
+
+ case OFPTYPE_NXT_GENEVE_TABLE_REQUEST:
+ break;
+
+ case OFPTYPE_NXT_GENEVE_TABLE_REPLY:
+ ofp_print_geneve_table_reply(string, msg);
+ break;
+
}
}