summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-03-09 14:44:20 -0800
committerBen Pfaff <blp@nicira.com>2011-03-09 16:22:00 -0800
commit70315176de81b49b7dcd4d65f09991f3217813af (patch)
tree22ce27c1e6e841da813f5b256a4036339f400c82 /utilities
parent6cd1276311130c6b6576cff47aea1068c42b7829 (diff)
downloadopenvswitch-70315176de81b49b7dcd4d65f09991f3217813af.tar.gz
ovs-ofctl: Make add-flows command read from stdin if file name is "-".
It is conventional for Unix tools to read from standard input if "-" is specified as a file name. It's easy for "ovs-ofctl add-flows" to behave this way, too, so this commit implements it. Suggested-by: Paul Ingram <paul@nicira.com>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/ovs-ofctl.8.in3
-rw-r--r--utilities/ovs-ofctl.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/utilities/ovs-ofctl.8.in b/utilities/ovs-ofctl.8.in
index 95b088429..3472cc1a4 100644
--- a/utilities/ovs-ofctl.8.in
+++ b/utilities/ovs-ofctl.8.in
@@ -132,7 +132,8 @@ below.
.
.TP
\fBadd\-flows \fIswitch file\fR
-Add flow entries as described in \fIfile\fR to \fIswitch\fR's
+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.
.
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index a96b77a94..f7605f785 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -692,7 +692,7 @@ do_add_flows(int argc OVS_UNUSED, char *argv[])
struct vconn *vconn;
FILE *file;
- file = fopen(argv[2], "r");
+ file = !strcmp(argv[2], "-") ? stdin : fopen(argv[2], "r");
if (file == NULL) {
ovs_fatal(errno, "%s: open", argv[2]);
}
@@ -707,7 +707,9 @@ do_add_flows(int argc OVS_UNUSED, char *argv[])
}
vconn_close(vconn);
- fclose(file);
+ if (file != stdin) {
+ fclose(file);
+ }
}
static void