1 /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
4 * We are making the OpenFlow specification and associated documentation
5 * (Software) available for public use and benefit with the expectation
6 * that others will use, modify and enhance the Software and contribute
7 * those enhancements back to the community. However, since we would
8 * like to make the Software available for broadest use, with as few
9 * restrictions as possible permission is hereby granted, free of
10 * charge, to any person obtaining a copy of this Software to deal in
11 * the Software under the copyrights without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Software, and to
14 * permit persons to whom the Software is furnished to do so, subject to
15 * the following conditions:
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * The name and trademarks of copyright holder(s) may NOT be used in
30 * advertising or publicity pertaining to the Software or any
31 * derivatives without specific, written prior permission.
38 #include <netinet/in.h>
46 #include "command-line.h"
52 #include "openflow-netlink.h"
55 #include "socket-util.h"
57 #include "ofp-print.h"
61 #include "vconn-ssl.h"
64 #define THIS_MODULE VLM_dpctl
66 #define DEFAULT_IDLE_TIMEOUT 60
67 #define MAX_ADD_ACTS 5
69 static const char* ifconfigbin = "/sbin/ifconfig";
75 void (*handler)(int argc, char *argv[]);
78 static struct command all_commands[];
80 static void usage(void) NO_RETURN;
81 static void parse_options(int argc, char *argv[]);
83 int main(int argc, char *argv[])
87 set_program_name(argv[0]);
90 parse_options(argc, argv);
91 signal(SIGPIPE, SIG_IGN);
96 fatal(0, "missing command name; use --help for help");
98 for (p = all_commands; p->name != NULL; p++) {
99 if (!strcmp(p->name, argv[0])) {
100 int n_arg = argc - 1;
101 if (n_arg < p->min_args)
102 fatal(0, "'%s' command requires at least %d arguments",
103 p->name, p->min_args);
104 else if (n_arg > p->max_args)
105 fatal(0, "'%s' command takes at most %d arguments",
106 p->name, p->max_args);
108 p->handler(argc, argv);
113 fatal(0, "unknown command '%s'; use --help for help", argv[0]);
119 parse_options(int argc, char *argv[])
121 static struct option long_options[] = {
122 {"timeout", required_argument, 0, 't'},
123 {"verbose", optional_argument, 0, 'v'},
124 {"help", no_argument, 0, 'h'},
125 {"version", no_argument, 0, 'V'},
126 VCONN_SSL_LONG_OPTIONS
129 char *short_options = long_options_to_short_options(long_options);
132 unsigned long int timeout;
135 c = getopt_long(argc, argv, short_options, long_options, NULL);
142 timeout = strtoul(optarg, NULL, 10);
144 fatal(0, "value %s on -t or --timeout is not at least 1",
155 printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]);
159 vlog_set_verbosity(optarg);
162 VCONN_SSL_OPTION_HANDLERS
177 printf("%s: OpenFlow switch management utility\n"
178 "usage: %s [OPTIONS] COMMAND [ARG...]\n"
180 "\nFor local datapaths only:\n"
181 " adddp nl:DP_ID add a new local datapath DP_ID\n"
182 " deldp nl:DP_ID delete local datapath DP_ID\n"
183 " addif nl:DP_ID IFACE add IFACE as a port on DP_ID\n"
184 " delif nl:DP_ID IFACE delete IFACE as a port on DP_ID\n"
185 " monitor nl:DP_ID print packets received\n"
187 "\nFor local datapaths and remote switches:\n"
188 " show SWITCH show information\n"
189 " dump-version SWITCH print version information\n"
190 " dump-tables SWITCH print table stats\n"
191 " dump-ports SWITCH print port statistics\n"
192 " dump-flows SWITCH print all flow entries\n"
193 " dump-flows SWITCH FLOW print matching FLOWs\n"
194 " dump-aggregate SWITCH print aggregate flow statistics\n"
195 " dump-aggregate SWITCH FLOW print aggregate stats for FLOWs\n"
196 " add-flow SWITCH FLOW add flow described by FLOW\n"
197 " add-flows SWITCH FILE add flows from FILE\n"
198 " del-flows SWITCH FLOW delete matching FLOWs\n"
199 "\nFor local datapaths, remote switches, and controllers:\n"
200 " probe VCONN probe whether VCONN is up\n"
201 " ping VCONN [N] latency of N-byte echos\n"
202 " benchmark VCONN N COUNT bandwidth of COUNT N-byte echos\n"
203 "where each SWITCH is an active OpenFlow connection method.\n",
204 program_name, program_name);
205 vconn_usage(true, false);
206 printf("\nOptions:\n"
207 " -t, --timeout=SECS give up after SECS seconds\n"
208 " -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n"
209 " -v, --verbose set maximum verbosity level\n"
210 " -h, --help display this help message\n"
211 " -V, --version display version information\n");
215 static void run(int retval, const char *message, ...)
218 static void run(int retval, const char *message, ...)
223 fprintf(stderr, "%s: ", program_name);
224 va_start(args, message);
225 vfprintf(stderr, message, args);
228 fputs(": unexpected end of file\n", stderr);
230 fprintf(stderr, ": %s\n", strerror(retval));
238 /* Netlink-only commands. */
240 static int if_up(const char* intf)
243 snprintf(command, sizeof command, "%s %s up &> /dev/null",
245 return system(command);
248 static void open_nl_vconn(const char *name, bool subscribe, struct dpif *dpif)
250 if (strncmp(name, "nl:", 3)
252 || name[strspn(name + 3, "0123456789") + 3]) {
253 fatal(0, "%s: argument is not of the form \"nl:DP_ID\"", name);
255 run(dpif_open(atoi(name + 3), subscribe, dpif), "opening datapath");
258 static void do_add_dp(int argc UNUSED, char *argv[])
261 open_nl_vconn(argv[1], false, &dp);
262 run(dpif_add_dp(&dp), "add_dp");
266 static void do_del_dp(int argc UNUSED, char *argv[])
269 open_nl_vconn(argv[1], false, &dp);
270 run(dpif_del_dp(&dp), "del_dp");
274 static void do_add_port(int argc UNUSED, char *argv[])
278 open_nl_vconn(argv[1], false, &dp);
279 run(dpif_add_port(&dp, argv[2]), "add_port");
283 static void do_del_port(int argc UNUSED, char *argv[])
286 open_nl_vconn(argv[1], false, &dp);
287 run(dpif_del_port(&dp, argv[2]), "del_port");
291 static void do_monitor(int argc UNUSED, char *argv[])
294 open_nl_vconn(argv[1], true, &dp);
297 run(dpif_recv_openflow(&dp, &b, true), "dpif_recv_openflow");
298 ofp_print(stderr, b->data, b->size, 2);
302 #endif /* HAVE_NETLINK */
304 /* Generic commands. */
307 alloc_stats_request(size_t body_len, uint16_t type, struct buffer **bufferp)
309 struct ofp_stats_request *rq;
310 rq = make_openflow((offsetof(struct ofp_stats_request, body)
311 + body_len), OFPT_STATS_REQUEST, bufferp);
312 rq->type = htons(type);
313 rq->flags = htons(0);
318 send_openflow_buffer(struct vconn *vconn, struct buffer *buffer)
320 update_openflow_length(buffer);
321 run(vconn_send_block(vconn, buffer), "failed to send packet to switch");
325 dump_transaction(const char *vconn_name, struct buffer *request)
328 struct buffer *reply;
330 update_openflow_length(request);
331 run(vconn_open_block(vconn_name, &vconn), "connecting to %s", vconn_name);
332 run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name);
333 ofp_print(stdout, reply->data, reply->size, 1);
338 dump_trivial_transaction(const char *vconn_name, uint8_t request_type)
340 struct buffer *request;
341 make_openflow(sizeof(struct ofp_header), request_type, &request);
342 dump_transaction(vconn_name, request);
346 dump_stats_transaction(const char *vconn_name, struct buffer *request)
348 uint32_t send_xid = ((struct ofp_header *) request->data)->xid;
352 run(vconn_open_block(vconn_name, &vconn), "connecting to %s", vconn_name);
353 send_openflow_buffer(vconn, request);
356 struct buffer *reply;
358 run(vconn_recv_block(vconn, &reply), "OpenFlow packet receive failed");
359 recv_xid = ((struct ofp_header *) reply->data)->xid;
360 if (send_xid == recv_xid) {
361 struct ofp_stats_reply *osr;
363 ofp_print(stdout, reply->data, reply->size, 1);
365 osr = buffer_at(reply, 0, sizeof *osr);
366 done = !osr || !(ntohs(osr->flags) & OFPSF_REPLY_MORE);
368 VLOG_DBG("received reply with xid %08"PRIx32" "
369 "!= expected %08"PRIx32, recv_xid, send_xid);
371 buffer_delete(reply);
377 dump_trivial_stats_transaction(const char *vconn_name, uint8_t stats_type)
379 struct buffer *request;
380 alloc_stats_request(0, stats_type, &request);
381 dump_stats_transaction(vconn_name, request);
385 do_show(int argc UNUSED, char *argv[])
387 dump_trivial_transaction(argv[1], OFPT_FEATURES_REQUEST);
388 dump_trivial_transaction(argv[1], OFPT_GET_CONFIG_REQUEST);
393 do_dump_version(int argc, char *argv[])
395 dump_trivial_stats_transaction(argv[1], OFPST_VERSION);
399 do_dump_tables(int argc, char *argv[])
401 dump_trivial_stats_transaction(argv[1], OFPST_TABLE);
406 str_to_int(const char *str)
409 if (sscanf(str, "%"SCNu32, &value) != 1) {
410 fatal(0, "invalid numeric format %s", str);
416 str_to_mac(const char *str, uint8_t mac[6])
418 if (sscanf(str, "%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8,
419 &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) != 6) {
420 fatal(0, "invalid mac address %s", str);
425 str_to_ip(const char *str, uint32_t *ip)
427 struct in_addr in_addr;
430 retval = lookup_ip(str, &in_addr);
432 fatal(0, "%s: could not convert to IP address", str);
434 *ip = in_addr.s_addr;
438 str_to_action(char *str, struct ofp_action *action, int *n_actions)
442 int max_actions = *n_actions;
444 char *saveptr = NULL;
446 memset(action, 0, sizeof(*action) * max_actions);
447 for (i=0, act = strtok_r(str, ", \t\r\n", &saveptr);
448 i<max_actions && act;
449 i++, act = strtok_r(NULL, ", \t\r\n", &saveptr))
453 /* Arguments are separated by colons */
454 arg = strchr(act, ':');
460 if (!strcasecmp(act, "mod_vlan")) {
461 action[i].type = htons(OFPAT_SET_DL_VLAN);
463 if (!strcasecmp(arg, "strip")) {
464 action[i].arg.vlan_id = htons(OFP_VLAN_NONE);
466 action[i].arg.vlan_id = htons(str_to_int(arg));
468 } else if (!strcasecmp(act, "output")) {
469 port = str_to_int(arg);
470 } else if (!strcasecmp(act, "TABLE")) {
472 } else if (!strcasecmp(act, "NORMAL")) {
474 } else if (!strcasecmp(act, "FLOOD")) {
476 } else if (!strcasecmp(act, "ALL")) {
478 } else if (!strcasecmp(act, "CONTROLLER")) {
479 port = OFPP_CONTROLLER;
481 if (!strcasecmp(arg, "all")) {
482 action[i].arg.output.max_len= htons(0);
484 action[i].arg.output.max_len= htons(str_to_int(arg));
487 } else if (!strcasecmp(act, "LOCAL")) {
489 } else if (strspn(act, "0123456789") == strlen(act)) {
490 port = str_to_int(act);
492 fatal(0, "Unknown action: %s", act);
495 if (port != OFPP_MAX) {
496 action[i].type = htons(OFPAT_OUTPUT);
497 action[i].arg.output.port = htons(port);
505 str_to_flow(char *string, struct ofp_match *match,
506 struct ofp_action *action, int *n_actions, uint8_t *table_idx,
507 uint16_t *priority, uint16_t *idle_timeout, uint16_t *hard_timeout)
512 enum { F_U8, F_U16, F_MAC, F_IP } type;
516 #define F_OFS(MEMBER) offsetof(struct ofp_match, MEMBER)
517 static const struct field fields[] = {
518 { "in_port", OFPFW_IN_PORT, F_U16, F_OFS(in_port) },
519 { "dl_vlan", OFPFW_DL_VLAN, F_U16, F_OFS(dl_vlan) },
520 { "dl_src", OFPFW_DL_SRC, F_MAC, F_OFS(dl_src) },
521 { "dl_dst", OFPFW_DL_DST, F_MAC, F_OFS(dl_dst) },
522 { "dl_type", OFPFW_DL_TYPE, F_U16, F_OFS(dl_type) },
523 { "nw_src", OFPFW_NW_SRC, F_IP, F_OFS(nw_src) },
524 { "nw_dst", OFPFW_NW_DST, F_IP, F_OFS(nw_dst) },
525 { "nw_proto", OFPFW_NW_PROTO, F_U8, F_OFS(nw_proto) },
526 { "tp_src", OFPFW_TP_SRC, F_U16, F_OFS(tp_src) },
527 { "tp_dst", OFPFW_TP_DST, F_U16, F_OFS(tp_dst) },
538 *priority = OFP_DEFAULT_PRIORITY;
541 *idle_timeout = DEFAULT_IDLE_TIMEOUT;
544 *hard_timeout = OFP_FLOW_PERMANENT;
547 act_str = strstr(string, "action");
549 fatal(0, "must specify an action");
553 act_str = strchr(act_str, '=');
555 fatal(0, "must specify an action");
560 str_to_action(act_str, action, n_actions);
562 memset(match, 0, sizeof *match);
563 wildcards = OFPFW_ALL;
564 for (name = strtok(string, "="), value = strtok(NULL, ", \t\r\n");
566 name = strtok(NULL, "="), value = strtok(NULL, ", \t\r\n"))
568 const struct field *f;
571 if (table_idx && !strcmp(name, "table")) {
572 *table_idx = atoi(value);
576 if (priority && !strcmp(name, "priority")) {
577 *priority = atoi(value);
581 if (idle_timeout && !strcmp(name, "idle_timeout")) {
582 *idle_timeout = atoi(value);
586 if (hard_timeout && !strcmp(name, "hard_timeout")) {
587 *hard_timeout = atoi(value);
591 for (f = fields; f < &fields[ARRAY_SIZE(fields)]; f++) {
592 if (!strcmp(f->name, name)) {
596 fprintf(stderr, "%s: unknown field %s (fields are",
598 for (f = fields; f < &fields[ARRAY_SIZE(fields)]; f++) {
602 fprintf(stderr, " %s", f->name);
604 fprintf(stderr, ")\n");
608 data = (char *) match + f->offset;
609 if (!strcmp(value, "*") || !strcmp(value, "ANY")) {
610 wildcards |= f->wildcard;
612 wildcards &= ~f->wildcard;
613 if (f->type == F_U8) {
614 *(uint8_t *) data = str_to_int(value);
615 } else if (f->type == F_U16) {
616 *(uint16_t *) data = htons(str_to_int(value));
617 } else if (f->type == F_MAC) {
618 str_to_mac(value, data);
619 } else if (f->type == F_IP) {
620 str_to_ip(value, data);
626 if (name && !value) {
627 fatal(0, "field %s missing value", name);
629 match->wildcards = htons(wildcards);
632 static void do_dump_flows(int argc, char *argv[])
634 struct ofp_flow_stats_request *req;
635 struct buffer *request;
637 req = alloc_stats_request(sizeof *req, OFPST_FLOW, &request);
638 str_to_flow(argc > 2 ? argv[2] : "", &req->match, NULL, 0,
639 &req->table_id, NULL, NULL, NULL);
640 memset(req->pad, 0, sizeof req->pad);
642 dump_stats_transaction(argv[1], request);
645 static void do_dump_aggregate(int argc, char *argv[])
647 struct ofp_aggregate_stats_request *req;
648 struct buffer *request;
650 req = alloc_stats_request(sizeof *req, OFPST_AGGREGATE, &request);
651 str_to_flow(argc > 2 ? argv[2] : "", &req->match, NULL, 0,
652 &req->table_id, NULL, NULL, NULL);
653 memset(req->pad, 0, sizeof req->pad);
655 dump_stats_transaction(argv[1], request);
658 static void do_add_flow(int argc, char *argv[])
661 struct buffer *buffer;
662 struct ofp_flow_mod *ofm;
663 uint16_t priority, idle_timeout, hard_timeout;
665 int n_actions = MAX_ADD_ACTS;
667 run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
669 /* Parse and send. */
670 size = sizeof *ofm + (sizeof ofm->actions[0] * MAX_ADD_ACTS);
671 ofm = make_openflow(size, OFPT_FLOW_MOD, &buffer);
672 str_to_flow(argv[2], &ofm->match, &ofm->actions[0], &n_actions,
673 NULL, &priority, &idle_timeout, &hard_timeout);
674 ofm->command = htons(OFPFC_ADD);
675 ofm->idle_timeout = htons(idle_timeout);
676 ofm->hard_timeout = htons(hard_timeout);
677 ofm->buffer_id = htonl(UINT32_MAX);
678 ofm->priority = htons(priority);
679 ofm->reserved = htonl(0);
681 /* xxx Should we use the buffer library? */
682 buffer->size -= (MAX_ADD_ACTS - n_actions) * sizeof ofm->actions[0];
684 send_openflow_buffer(vconn, buffer);
688 static void do_add_flows(int argc, char *argv[])
695 file = fopen(argv[2], "r");
697 fatal(errno, "%s: open", argv[2]);
700 run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
701 while (fgets(line, sizeof line, file)) {
702 struct buffer *buffer;
703 struct ofp_flow_mod *ofm;
704 uint16_t priority, idle_timeout, hard_timeout;
706 int n_actions = MAX_ADD_ACTS;
710 /* Delete comments. */
711 comment = strchr(line, '#');
716 /* Drop empty lines. */
717 if (line[strspn(line, " \t\n")] == '\0') {
721 /* Parse and send. */
722 size = sizeof *ofm + (sizeof ofm->actions[0] * MAX_ADD_ACTS);
723 ofm = make_openflow(size, OFPT_FLOW_MOD, &buffer);
724 str_to_flow(line, &ofm->match, &ofm->actions[0], &n_actions,
725 NULL, &priority, &idle_timeout, &hard_timeout);
726 ofm->command = htons(OFPFC_ADD);
727 ofm->idle_timeout = htons(idle_timeout);
728 ofm->hard_timeout = htons(hard_timeout);
729 ofm->buffer_id = htonl(UINT32_MAX);
730 ofm->priority = htons(priority);
731 ofm->reserved = htonl(0);
733 /* xxx Should we use the buffer library? */
734 buffer->size -= (MAX_ADD_ACTS - n_actions) * sizeof ofm->actions[0];
736 send_openflow_buffer(vconn, buffer);
742 static void do_del_flows(int argc, char *argv[])
747 run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
748 struct buffer *buffer;
749 struct ofp_flow_mod *ofm;
753 /* Parse and send. */
755 ofm = make_openflow(size, OFPT_FLOW_MOD, &buffer);
756 str_to_flow(argc > 2 ? argv[2] : "", &ofm->match, NULL, 0, NULL,
757 &priority, NULL, NULL);
758 ofm->command = htons(OFPFC_DELETE);
759 ofm->idle_timeout = htons(0);
760 ofm->hard_timeout = htons(0);
761 ofm->buffer_id = htonl(UINT32_MAX);
762 ofm->priority = htons(priority);
763 ofm->reserved = htonl(0);
765 send_openflow_buffer(vconn, buffer);
771 do_dump_ports(int argc, char *argv[])
773 dump_trivial_stats_transaction(argv[1], OFPST_PORT);
777 do_probe(int argc, char *argv[])
779 struct buffer *request;
781 struct buffer *reply;
783 make_openflow(sizeof(struct ofp_header), OFPT_ECHO_REQUEST, &request);
784 run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
785 run(vconn_transact(vconn, request, &reply), "talking to %s", argv[1]);
786 if (reply->size != request->size) {
787 fatal(0, "reply does not match request");
789 buffer_delete(reply);
794 do_ping(int argc, char *argv[])
796 size_t max_payload = 65535 - sizeof(struct ofp_header);
797 unsigned int payload;
801 payload = argc > 2 ? atoi(argv[2]) : 64;
802 if (payload > max_payload) {
803 fatal(0, "payload must be between 0 and %zu bytes", max_payload);
806 run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
807 for (i = 0; i < 10; i++) {
808 struct timeval start, end;
809 struct buffer *request, *reply;
810 struct ofp_header *rq_hdr, *rpy_hdr;
812 rq_hdr = make_openflow(sizeof(struct ofp_header) + payload,
813 OFPT_ECHO_REQUEST, &request);
814 random_bytes(rq_hdr + 1, payload);
816 gettimeofday(&start, NULL);
817 run(vconn_transact(vconn, buffer_clone(request), &reply), "transact");
818 gettimeofday(&end, NULL);
820 rpy_hdr = reply->data;
821 if (reply->size != request->size
822 || memcmp(rpy_hdr + 1, rq_hdr + 1, payload)
823 || rpy_hdr->xid != rq_hdr->xid
824 || rpy_hdr->type != OFPT_ECHO_REPLY) {
825 printf("Reply does not match request. Request:\n");
826 ofp_print(stdout, request, request->size, 2);
828 ofp_print(stdout, reply, reply->size, 2);
830 printf("%d bytes from %s: xid=%08"PRIx32" time=%.1f ms\n",
831 reply->size - sizeof *rpy_hdr, argv[1], rpy_hdr->xid,
832 (1000*(double)(end.tv_sec - start.tv_sec))
833 + (.001*(end.tv_usec - start.tv_usec)));
834 buffer_delete(request);
835 buffer_delete(reply);
841 do_benchmark(int argc, char *argv[])
843 size_t max_payload = 65535 - sizeof(struct ofp_header);
844 struct timeval start, end;
845 unsigned int payload_size, message_size;
851 payload_size = atoi(argv[2]);
852 if (payload_size > max_payload) {
853 fatal(0, "payload must be between 0 and %zu bytes", max_payload);
855 message_size = sizeof(struct ofp_header) + payload_size;
857 count = atoi(argv[3]);
859 printf("Sending %d packets * %u bytes (with header) = %u bytes total\n",
860 count, message_size, count * message_size);
862 run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
863 gettimeofday(&start, NULL);
864 for (i = 0; i < count; i++) {
865 struct buffer *request, *reply;
866 struct ofp_header *rq_hdr;
868 rq_hdr = make_openflow(message_size, OFPT_ECHO_REQUEST, &request);
869 memset(rq_hdr + 1, 0, payload_size);
870 run(vconn_transact(vconn, request, &reply), "transact");
871 buffer_delete(reply);
873 gettimeofday(&end, NULL);
876 duration = ((1000*(double)(end.tv_sec - start.tv_sec))
877 + (.001*(end.tv_usec - start.tv_usec)));
878 printf("Finished in %.1f ms (%.0f packets/s) (%.0f bytes/s)\n",
879 duration, count / (duration / 1000.0),
880 count * message_size / (duration / 1000.0));
883 static void do_help(int argc UNUSED, char *argv[] UNUSED)
888 static struct command all_commands[] = {
890 { "adddp", 1, 1, do_add_dp },
891 { "deldp", 1, 1, do_del_dp },
892 { "addif", 2, 2, do_add_port },
893 { "delif", 2, 2, do_del_port },
896 { "show", 1, 1, do_show },
898 { "help", 0, INT_MAX, do_help },
899 { "monitor", 1, 1, do_monitor },
900 { "dump-version", 1, 1, do_dump_version },
901 { "dump-tables", 1, 1, do_dump_tables },
902 { "dump-flows", 1, 2, do_dump_flows },
903 { "dump-aggregate", 1, 2, do_dump_aggregate },
904 { "add-flow", 2, 2, do_add_flow },
905 { "add-flows", 2, 2, do_add_flows },
906 { "del-flows", 1, 2, do_del_flows },
907 { "dump-ports", 1, 1, do_dump_ports },
908 { "probe", 1, 1, do_probe },
909 { "ping", 1, 2, do_ping },
910 { "benchmark", 3, 3, do_benchmark },
911 { NULL, 0, 0, NULL },