summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-02-22 16:24:19 -0800
committerBen Pfaff <blp@nicira.com>2011-02-23 09:42:32 -0800
commit770f1f66bb9dc4e784e6c2c5351089c62b9a5919 (patch)
tree1644362c7317b82d350508e88bf9f21cd9ad91f7 /utilities
parentc4894ed48f0c727a87fc64629623bd62aef1e95b (diff)
downloadopenvswitch-770f1f66bb9dc4e784e6c2c5351089c62b9a5919.tar.gz
multipath: Validate multipath actions more thoroughly in multipath_parse().
The stricter validation requires updates to the calls to test-multipath to supply a valid n_links value. test-multipath doesn't actually use that value (it runs over different values in an internal "for" loop), so this doesn't change any behavior. Also adds a test to exercise each possible multipath_parse() error message. Reported-by: Reid Price <reid@nicira.com> Bug #4462.
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-ofctl.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 68f2edaff..9f5a0a524 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -884,6 +884,36 @@ do_help(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
/* Undocumented commands for unit testing. */
+static void
+print_packet_list(struct list *packets)
+{
+ struct ofpbuf *packet, *next;
+
+ LIST_FOR_EACH_SAFE (packet, next, list_node, packets) {
+ ofp_print(stdout, packet->data, packet->size, verbosity);
+ list_remove(&packet->list_node);
+ ofpbuf_delete(packet);
+ }
+}
+
+/* "parse-flow FLOW": parses the argument as a flow (like add-flow) and prints
+ * it back to stdout. */
+static void
+do_parse_flow(int argc OVS_UNUSED, char *argv[])
+{
+ enum nx_flow_format flow_format;
+ struct list packets;
+
+ flow_format = NXFF_OPENFLOW10;
+ if (preferred_flow_format > 0) {
+ flow_format = preferred_flow_format;
+ }
+
+ list_init(&packets);
+ parse_ofp_flow_mod_str(&packets, &flow_format, argv[1], OFPFC_ADD);
+ print_packet_list(&packets);
+}
+
/* "parse-flows FILENAME": reads the named file as a sequence of flows (like
* add-flows) and prints each of the flows back to stdout. */
static void
@@ -898,20 +928,14 @@ do_parse_flows(int argc OVS_UNUSED, char *argv[])
ovs_fatal(errno, "%s: open", argv[2]);
}
- list_init(&packets);
flow_format = NXFF_OPENFLOW10;
if (preferred_flow_format > 0) {
flow_format = preferred_flow_format;
}
+ list_init(&packets);
while (parse_ofp_add_flow_file(&packets, &flow_format, file)) {
- struct ofpbuf *packet, *next;
-
- LIST_FOR_EACH_SAFE (packet, next, list_node, &packets) {
- ofp_print(stdout, packet->data, packet->size, verbosity);
- list_remove(&packet->list_node);
- ofpbuf_delete(packet);
- }
+ print_packet_list(&packets);
}
fclose(file);
}
@@ -1011,6 +1035,7 @@ static const struct command all_commands[] = {
{ "help", 0, INT_MAX, do_help },
/* Undocumented commands for testing. */
+ { "parse-flow", 1, 1, do_parse_flow },
{ "parse-flows", 1, 1, do_parse_flows },
{ "parse-nx-match", 0, 0, do_parse_nx_match },
{ "ofp-print", 1, 2, do_ofp_print },