From: Ben Pfaff Date: Wed, 14 Jan 2009 22:08:40 +0000 (-0800) Subject: dpctl: Fix "add-flow" and "add-flows" when actions are specified. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8997a8aa4a9e96cecf1f47e84c699cb050d04cf2;p=openvswitch dpctl: Fix "add-flow" and "add-flows" when actions are specified. Thanks to Justin for noticing the problem. --- diff --git a/utilities/dpctl.c b/utilities/dpctl.c index 828e33a3..60341276 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -944,11 +944,15 @@ do_add_flow(const struct settings *s UNUSED, int argc UNUSED, char *argv[]) struct ofpbuf *buffer; struct ofp_flow_mod *ofm; uint16_t priority, idle_timeout, hard_timeout; + struct ofp_match match; - /* Parse and send. */ - ofm = make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer); - str_to_flow(argv[2], &ofm->match, buffer, + /* Parse and send. str_to_flow() will expand and reallocate the data in + * 'buffer', so we can't keep pointers to across the str_to_flow() call. */ + make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer); + str_to_flow(argv[2], &match, buffer, NULL, NULL, &priority, &idle_timeout, &hard_timeout); + ofm = buffer->data; + ofm->match = match; ofm->command = htons(OFPFC_ADD); ofm->idle_timeout = htons(idle_timeout); ofm->hard_timeout = htons(hard_timeout); @@ -978,6 +982,7 @@ do_add_flows(const struct settings *s UNUSED, int argc UNUSED, char *argv[]) struct ofpbuf *buffer; struct ofp_flow_mod *ofm; uint16_t priority, idle_timeout, hard_timeout; + struct ofp_match match; char *comment; @@ -992,10 +997,14 @@ do_add_flows(const struct settings *s UNUSED, int argc UNUSED, char *argv[]) continue; } - /* Parse and send. */ + /* Parse and send. str_to_flow() will expand and reallocate the data + * in 'buffer', so we can't keep pointers to across the str_to_flow() + * call. */ ofm = make_openflow(sizeof *ofm, OFPT_FLOW_MOD, &buffer); - str_to_flow(line, &ofm->match, buffer, + str_to_flow(line, &match, buffer, NULL, NULL, &priority, &idle_timeout, &hard_timeout); + ofm = buffer->data; + ofm->match = match; ofm->command = htons(OFPFC_ADD); ofm->idle_timeout = htons(idle_timeout); ofm->hard_timeout = htons(hard_timeout);