From 8997a8aa4a9e96cecf1f47e84c699cb050d04cf2 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 14 Jan 2009 14:08:40 -0800 Subject: [PATCH] dpctl: Fix "add-flow" and "add-flows" when actions are specified. Thanks to Justin for noticing the problem. --- utilities/dpctl.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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); -- 2.30.2