Looks Good.
On Fri, Mar 11, 2011 at 1:20 PM, Ben Pfaff <[email protected]> wrote: > This makes it possible to modify or delete multiple flows in one run, > which is sometimes convenient. > > Requested-by: Paul Ingram <[email protected]> > --- > utilities/ovs-ofctl.8.in | 57 ++++++++++++++++++++++----------------------- > utilities/ovs-ofctl.c | 57 +++++++++++++++++++++++++++------------------ > 2 files changed, 62 insertions(+), 52 deletions(-) > > diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in > index 31017e5..e84d274 100644 > --- a/utilities/ovs-ofctl.8.in > +++ b/utilities/ovs-ofctl.8.in > @@ -124,34 +124,31 @@ If only \fIqueue\fR is omitted, then statistics are > printed for all > queues on \fIport\fR; if only \fIport\fR is omitted, then statistics > are printed for \fIqueue\fR on every port where it exists. > . > -.TP > -\fBadd\-flow \fIswitch flow\fR > -Add the flow entry as described by \fIflow\fR to the \fIswitch\fR's > -tables. The flow entry is in the format described in \fBFlow Syntax\fR, > -below. > -. > -.TP > -\fBadd\-flows \fIswitch file\fR > -Add the flow entries listed in \fIfile\fR, or supplied on \fBstdin\fR > -if \fIfile\fR is \fB\-\fR, to \fIswitch\fR's > -tables. Each line in \fIfile\fR is a flow entry in the format > -described in \fBFlow Syntax\fR, below. > -. > -.TP > -\fBmod\-flows \fIswitch flow\fR > -Modify the actions in entries from the \fIswitch\fR's tables > -that match \fIflow\fR. When invoked with the \fB\-\-strict\fR option, > -wildcards are not treated as active for matching purposes. See > -\fBFlow Syntax\fR, below, for the syntax of \fIflows\fR. > -. > -.TP > -\fBdel\-flows \fIswitch \fR[\fIflow\fR] > -Deletes entries from the \fIswitch\fR's tables that match > -\fIflow\fR. When invoked with the \fB\-\-strict\fR option, wildcards are > -not treated as active for matching purposes. If \fIflow\fR is > -omitted and the \fB\-\-strict\fR option is not used, all flows in the > -switch's tables are removed. See \fBFlow Syntax\fR, below, for the > -syntax of \fIflows\fR. > +.SS "OpenFlow Switch Flow Table Commands" > +. > +These commands manage the flow table in an OpenFlow switch. In each > +case, \fIflow\fR specifies a flow entry in the format described in > +\fBFlow Syntax\fR, below, and \fIfile\fR is a text file that contains > +zero or more flows in the same syntax, one per line. > +. > +.IP "\fBadd\-flow \fIswitch flow\fR" > +.IQ "\fBadd\-flow \fIswitch \fB\- < \fIfile\fR" > +.IQ "\fBadd\-flows \fIswitch file\fR" > +Add each flow entry to \fIswitch\fR's tables. > +. > +.IP "[\fB\-\-strict\fR] \fBmod\-flows \fIswitch flow\fR" > +.IQ "[\fB\-\-strict\fR] \fBmod\-flows \fIswitch \fB\- < \fIfile\fR" > +Modify the actions in entries from \fIswitch\fR's tables that match > +the specified flows. With \fB\-\-strict\fR, wildcards are not treated > +as active for matching purposes. > +. > +.IP "\fBdel\-flows \fIswitch\fR" > +.IQ "[\fB\-\-strict\fR] \fBdel\-flows \fIswitch \fR[\fIflow\fR]" > +.IQ "[\fB\-\-strict\fR] \fBdel\-flows \fIswitch \fB\- < \fIfile\fR" > +Deletes entries from \fIswitch\fR's flow table. With only a > +\fIswitch\fR argument, deletes all flows. Otherwise, deletes flow > +entries that match the specified flows. With \fB\-\-strict\fR, > +wildcards are not treated as active for matching purposes. > . > .IP "\fBreplace\-flows \fIswitch file\fR" > Reads flow entries from \fIfile\fR (or \fBstdin\fR if \fIfile\fR is > @@ -180,6 +177,8 @@ For this command, an exit status of 0 means that no > differences were > found, 1 means that an error occurred, and 2 means that some > differences were found. > . > +.SS "OpenFlow Switch Monitoring Commands" > +. > .IP "\fBsnoop \fIswitch\fR" > Connects to \fIswitch\fR and prints to the console all OpenFlow > messages received. Unlike other \fBovs\-ofctl\fR commands, if > @@ -205,7 +204,7 @@ If a switch has no controller configured, or if > the configured controller is disconnected, no traffic is sent, so > monitoring will not show any traffic. > . > -.IQ "\fBmonitor \fIswitch\fR [\fImiss-len\fR]" > +.IP "\fBmonitor \fIswitch\fR [\fImiss-len\fR]" > Connects to \fIswitch\fR and prints to the console all OpenFlow > messages received. Usually, \fIswitch\fR should specify a connection > named on \fBovs\-openflowd\fR(8)'s \fB\-l\fR or \fB\-\-listen\fR command line > diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c > index 4f2dc7f..b386ba3 100644 > --- a/utilities/ovs-ofctl.c > +++ b/utilities/ovs-ofctl.c > @@ -664,56 +664,67 @@ check_final_format_for_flow_mod(enum nx_flow_format > flow_format) > } > > static void > -do_flow_mod__(int argc OVS_UNUSED, char *argv[], uint16_t command) > +do_flow_mod_file__(int argc OVS_UNUSED, char *argv[], uint16_t command) > { > enum nx_flow_format flow_format; > struct list requests; > struct vconn *vconn; > + FILE *file; > + > + file = !strcmp(argv[2], "-") ? stdin : fopen(argv[2], "r"); > + if (file == NULL) { > + ovs_fatal(errno, "%s: open", argv[2]); > + } > > list_init(&requests); > flow_format = set_initial_format_for_flow_mod(&requests); > > - parse_ofp_flow_mod_str(&requests, &flow_format, argc > 2 ? argv[2] : "", > - command); > - check_final_format_for_flow_mod(flow_format); > - > open_vconn(argv[1], &vconn); > - transact_multiple_noreply(vconn, &requests); > + while (parse_ofp_flow_mod_file(&requests, &flow_format, file, command)) { > + check_final_format_for_flow_mod(flow_format); > + transact_multiple_noreply(vconn, &requests); > + } > vconn_close(vconn); > -} > > -static void > -do_add_flow(int argc, char *argv[]) > -{ > - do_flow_mod__(argc, argv, OFPFC_ADD); > + if (file != stdin) { > + fclose(file); > + } > } > > static void > -do_add_flows(int argc OVS_UNUSED, char *argv[]) > +do_flow_mod__(int argc, char *argv[], uint16_t command) > { > enum nx_flow_format flow_format; > struct list requests; > struct vconn *vconn; > - FILE *file; > > - file = !strcmp(argv[2], "-") ? stdin : fopen(argv[2], "r"); > - if (file == NULL) { > - ovs_fatal(errno, "%s: open", argv[2]); > + if (argc > 2 && !strcmp(argv[2], "-")) { > + do_flow_mod_file__(argc, argv, command); > + return; > } > > list_init(&requests); > flow_format = set_initial_format_for_flow_mod(&requests); > > + parse_ofp_flow_mod_str(&requests, &flow_format, argc > 2 ? argv[2] : "", > + command); > + check_final_format_for_flow_mod(flow_format); > + > open_vconn(argv[1], &vconn); > - while (parse_ofp_flow_mod_file(&requests, &flow_format, file, > OFPFC_ADD)) { > - check_final_format_for_flow_mod(flow_format); > - transact_multiple_noreply(vconn, &requests); > - } > + transact_multiple_noreply(vconn, &requests); > vconn_close(vconn); > +} > > - if (file != stdin) { > - fclose(file); > - } > +static void > +do_add_flow(int argc, char *argv[]) > +{ > + do_flow_mod__(argc, argv, OFPFC_ADD); > +} > + > +static void > +do_add_flows(int argc, char *argv[]) > +{ > + do_flow_mod_file__(argc, argv, OFPFC_ADD); > } > > static void > -- > 1.7.1 > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
