Looks good. --Justin
On May 1, 2013, at 5:15 PM, Ben Pfaff <b...@nicira.com> wrote: > These helpers simplify new code to be added in an upcoming commit. > > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > lib/dpif-linux.c | 46 +++++++++++++++++++++++++++++++++------------- > 1 files changed, 33 insertions(+), 13 deletions(-) > > diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c > index 933aabe..b80c27a 100644 > --- a/lib/dpif-linux.c > +++ b/lib/dpif-linux.c > @@ -668,46 +668,66 @@ struct dpif_linux_port_state { > struct nl_dump dump; > }; > > -static int > -dpif_linux_port_dump_start(const struct dpif *dpif_, void **statep) > +static void > +dpif_linux_port_dump_start__(const struct dpif *dpif_, struct nl_dump *dump) > { > struct dpif_linux *dpif = dpif_linux_cast(dpif_); > - struct dpif_linux_port_state *state; > struct dpif_linux_vport request; > struct ofpbuf *buf; > > - *statep = state = xmalloc(sizeof *state); > - > dpif_linux_vport_init(&request); > request.cmd = OVS_DP_CMD_GET; > request.dp_ifindex = dpif->dp_ifindex; > > buf = ofpbuf_new(1024); > dpif_linux_vport_to_ofpbuf(&request, buf); > - nl_dump_start(&state->dump, genl_sock, buf); > + nl_dump_start(dump, genl_sock, buf); > ofpbuf_delete(buf); > +} > + > +static int > +dpif_linux_port_dump_start(const struct dpif *dpif, void **statep) > +{ > + struct dpif_linux_port_state *state; > + > + *statep = state = xmalloc(sizeof *state); > + dpif_linux_port_dump_start__(dpif, &state->dump); > > return 0; > } > > +static bool > +dpif_linux_port_dump_next__(const struct dpif *dpif_, struct nl_dump *dump, > + struct dpif_linux_vport *vport) > +{ > + struct dpif_linux *dpif = dpif_linux_cast(dpif_); > + struct ofpbuf buf; > + int error; > + > + if (!nl_dump_next(dump, &buf)) { > + return EOF; > + } > + > + error = dpif_linux_vport_from_ofpbuf(vport, &buf); > + if (error) { > + VLOG_WARN_RL(&error_rl, "%s: failed to parse vport record (%s)", > + dpif_name(&dpif->dpif), strerror(error)); > + } > + return error; > +} > + > static int > dpif_linux_port_dump_next(const struct dpif *dpif OVS_UNUSED, void *state_, > struct dpif_port *dpif_port) > { > struct dpif_linux_port_state *state = state_; > struct dpif_linux_vport vport; > - struct ofpbuf buf; > int error; > > - if (!nl_dump_next(&state->dump, &buf)) { > - return EOF; > - } > - > - error = dpif_linux_vport_from_ofpbuf(&vport, &buf); > + error = dpif_linux_port_dump_next__(dpif, &state->dump, &vport); > if (error) { > return error; > } > - > dpif_port->name = CONST_CAST(char *, vport.name); > dpif_port->type = CONST_CAST(char *, get_vport_type(&vport)); > dpif_port->port_no = vport.port_no; > -- > 1.7.2.5 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev