git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ofproto: Fix typo in documentation.
[sliver-openvswitch.git]
/
utilities
/
ovs-ofctl.c
diff --git
a/utilities/ovs-ofctl.c
b/utilities/ovs-ofctl.c
index
e7997c6
..
bc8cc6b
100644
(file)
--- a/
utilities/ovs-ofctl.c
+++ b/
utilities/ovs-ofctl.c
@@
-18,6
+18,7
@@
#include <errno.h>
#include <getopt.h>
#include <inttypes.h>
#include <errno.h>
#include <getopt.h>
#include <inttypes.h>
+#include <sys/socket.h>
#include <net/if.h>
#include <signal.h>
#include <stdlib.h>
#include <net/if.h>
#include <signal.h>
#include <stdlib.h>
@@
-198,17
+199,8
@@
static void run(int retval, const char *message, ...)
if (retval) {
va_list args;
if (retval) {
va_list args;
- fprintf(stderr, "%s: ", program_name);
va_start(args, message);
va_start(args, message);
- vfprintf(stderr, message, args);
- va_end(args);
- if (retval == EOF) {
- fputs(": unexpected end of file\n", stderr);
- } else {
- fprintf(stderr, ": %s\n", strerror(retval));
- }
-
- exit(EXIT_FAILURE);
+ ovs_fatal_valist(retval, message, args);
}
}
\f
}
}
\f
@@
-633,56
+625,67
@@
check_final_format_for_flow_mod(enum nx_flow_format flow_format)
}
static void
}
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;
{
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);
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);
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);
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
}
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;
{
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);
}
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);
open_vconn(argv[1], &vconn);
- while (parse_ofp_add_flow_file(&requests, &flow_format, file)) {
- check_final_format_for_flow_mod(flow_format);
- transact_multiple_noreply(vconn, &requests);
- }
+ transact_multiple_noreply(vconn, &requests);
vconn_close(vconn);
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
}
static void
@@
-824,9
+827,9
@@
do_ping(int argc, char *argv[])
OFPT_ECHO_REQUEST, &request);
random_bytes(rq_hdr + 1, payload);
OFPT_ECHO_REQUEST, &request);
random_bytes(rq_hdr + 1, payload);
-
gettimeofday(&start, NULL
);
+
xgettimeofday(&start
);
run(vconn_transact(vconn, ofpbuf_clone(request), &reply), "transact");
run(vconn_transact(vconn, ofpbuf_clone(request), &reply), "transact");
-
gettimeofday(&end, NULL
);
+
xgettimeofday(&end
);
rpy_hdr = reply->data;
if (reply->size != request->size
rpy_hdr = reply->data;
if (reply->size != request->size
@@
-871,7
+874,7
@@
do_benchmark(int argc OVS_UNUSED, char *argv[])
count, message_size, count * message_size);
open_vconn(argv[1], &vconn);
count, message_size, count * message_size);
open_vconn(argv[1], &vconn);
-
gettimeofday(&start, NULL
);
+
xgettimeofday(&start
);
for (i = 0; i < count; i++) {
struct ofpbuf *request, *reply;
struct ofp_header *rq_hdr;
for (i = 0; i < count; i++) {
struct ofpbuf *request, *reply;
struct ofp_header *rq_hdr;
@@
-881,7
+884,7
@@
do_benchmark(int argc OVS_UNUSED, char *argv[])
run(vconn_transact(vconn, request, &reply), "transact");
ofpbuf_delete(reply);
}
run(vconn_transact(vconn, request, &reply), "transact");
ofpbuf_delete(reply);
}
-
gettimeofday(&end, NULL
);
+
xgettimeofday(&end
);
vconn_close(vconn);
duration = ((1000*(double)(end.tv_sec - start.tv_sec))
vconn_close(vconn);
duration = ((1000*(double)(end.tv_sec - start.tv_sec))
@@
-1139,8
+1142,6
@@
read_flows_from_switch(struct vconn *vconn, enum nx_flow_format flow_format,
fte_insert(cls, &fs.rule, version, index);
}
fte_insert(cls, &fs.rule, version, index);
}
-
- osr = ofpbuf_at(reply, 0, sizeof *osr);
} else {
VLOG_DBG("received reply with xid %08"PRIx32" "
"!= expected %08"PRIx32, recv_xid, send_xid);
} else {
VLOG_DBG("received reply with xid %08"PRIx32" "
"!= expected %08"PRIx32, recv_xid, send_xid);
@@
-1339,7
+1340,7
@@
do_parse_flows(int argc OVS_UNUSED, char *argv[])
}
list_init(&packets);
}
list_init(&packets);
- while (parse_ofp_
add_flow_file(&packets, &flow_format, file
)) {
+ while (parse_ofp_
flow_mod_file(&packets, &flow_format, file, OFPFC_ADD
)) {
print_packet_list(&packets);
}
fclose(file);
print_packet_list(&packets);
}
fclose(file);