This patch simplifies buffer usage in dpif_linux_flow_dump_next() in preparation for later changes.
Signed-off-by: Joe Stringer <joestrin...@nicira.com> --- lib/dpif-linux.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index ed824a6..d985f4b 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -1010,7 +1010,7 @@ dpif_linux_flow_dump_start(const struct dpif *dpif_, void **statep) nl_dump_start(&state->dump, NETLINK_GENERIC, buf); ofpbuf_delete(buf); - state->buf = NULL; + state->buf = ofpbuf_new(1024); return 0; } @@ -1027,10 +1027,7 @@ dpif_linux_flow_dump_next(const struct dpif *dpif_ OVS_UNUSED, void *state_, int error; do { - ofpbuf_delete(state->buf); - state->buf = NULL; - - if (!nl_dump_next(&state->dump, &buf, &state->dump.buffer)) { + if (!nl_dump_next(&state->dump, &buf, state->buf)) { return EOF; } @@ -1040,9 +1037,16 @@ dpif_linux_flow_dump_next(const struct dpif *dpif_ OVS_UNUSED, void *state_, } if (actions && !state->flow.actions) { + struct ofpbuf *tmp_buf = NULL; + error = dpif_linux_flow_get__(dpif_, state->flow.key, state->flow.key_len, - &state->flow, &state->buf); + &state->flow, &tmp_buf); + if (tmp_buf) { + ofpbuf_delete(state->buf); + state->buf = tmp_buf; + } + if (error == ENOENT) { VLOG_DBG("dumped flow disappeared on get"); } else if (error) { -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev