Implement new statistics format in kernel and userspace switches.
[sliver-openvswitch.git] / utilities / dpctl.c
1 /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
2  * Junior University
3  * 
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:
16  * 
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  * 
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
27  * SOFTWARE.
28  * 
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.
32  */
33
34 #include <errno.h>
35 #include <getopt.h>
36 #include <inttypes.h>
37 #include <netinet/in.h>
38 #include <stdarg.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <unistd.h>
42 #include <sys/time.h>
43
44 #include "command-line.h"
45 #include "compiler.h"
46 #include "buffer.h"
47 #include "dpif.h"
48 #ifdef HAVE_NETLINK
49 #include "netlink.h"
50 #include "openflow-netlink.h"
51 #endif
52 #include "util.h"
53 #include "socket-util.h"
54 #include "openflow.h"
55 #include "ofp-print.h"
56 #include "vconn.h"
57 #include "vconn-ssl.h"
58
59 #include "vlog.h"
60 #define THIS_MODULE VLM_dpctl
61
62 static const char* ifconfigbin = "/sbin/ifconfig";
63
64 struct command {
65     const char *name;
66     int min_args;
67     int max_args;
68     void (*handler)(int argc, char *argv[]);
69 };
70
71 static struct command all_commands[];
72
73 static void usage(void) NO_RETURN;
74 static void parse_options(int argc, char *argv[]);
75
76 int main(int argc, char *argv[])
77 {
78     struct command *p;
79
80     set_program_name(argv[0]);
81     vlog_init();
82     parse_options(argc, argv);
83
84     argc -= optind;
85     argv += optind;
86     if (argc < 1)
87         fatal(0, "missing command name; use --help for help");
88
89     for (p = all_commands; p->name != NULL; p++) {
90         if (!strcmp(p->name, argv[0])) {
91             int n_arg = argc - 1;
92             if (n_arg < p->min_args)
93                 fatal(0, "'%s' command requires at least %d arguments",
94                       p->name, p->min_args);
95             else if (n_arg > p->max_args)
96                 fatal(0, "'%s' command takes at most %d arguments",
97                       p->name, p->max_args);
98             else {
99                 p->handler(argc, argv);
100                 exit(0);
101             }
102         }
103     }
104     fatal(0, "unknown command '%s'; use --help for help", argv[0]);
105
106     return 0;
107 }
108
109 static void
110 parse_options(int argc, char *argv[])
111 {
112     static struct option long_options[] = {
113         {"verbose", optional_argument, 0, 'v'},
114         {"help", no_argument, 0, 'h'},
115         {"version", no_argument, 0, 'V'},
116         VCONN_SSL_LONG_OPTIONS
117         {0, 0, 0, 0},
118     };
119     char *short_options = long_options_to_short_options(long_options);
120
121     for (;;) {
122         int indexptr;
123         int c;
124
125         c = getopt_long(argc, argv, short_options, long_options, &indexptr);
126         if (c == -1) {
127             break;
128         }
129
130         switch (c) {
131         case 'h':
132             usage();
133
134         case 'V':
135             printf("%s "VERSION" compiled "__DATE__" "__TIME__"\n", argv[0]);
136             exit(EXIT_SUCCESS);
137
138         case 'v':
139             vlog_set_verbosity(optarg);
140             break;
141
142         VCONN_SSL_OPTION_HANDLERS
143
144         case '?':
145             exit(EXIT_FAILURE);
146
147         default:
148             abort();
149         }
150     }
151     free(short_options);
152 }
153
154 static void
155 usage(void)
156 {
157     printf("%s: OpenFlow switch management utility\n"
158            "usage: %s [OPTIONS] COMMAND [ARG...]\n"
159 #ifdef HAVE_NETLINK
160            "\nCommands that apply to local datapaths only:\n"
161            "  adddp nl:DP_ID              add a new local datapath DP_ID\n"
162            "  deldp nl:DP_ID              delete local datapath DP_ID\n"
163            "  addif nl:DP_ID IFACE        add IFACE as a port on DP_ID\n"
164            "  delif nl:DP_ID IFACE        delete IFACE as a port on DP_ID\n"
165            "  monitor nl:DP_ID            print packets received\n"
166            "  benchmark-nl nl:DP_ID N SIZE   send N packets of SIZE bytes\n"
167 #endif
168            "\nCommands that apply to local datapaths and remote switches:\n"
169            "  show SWITCH                 show information\n"
170            "  dump-tables SWITCH          print table stats\n"
171            "  dump-ports SWITCH           print port statistics\n"
172            "  dump-flows SWITCH           print all flow entries\n"
173            "  dump-flows SWITCH FLOW      print matching FLOWs\n"
174            "  add-flows SWITCH FILE       add flows from FILE\n"
175            "  del-flows SWITCH FLOW       delete matching FLOWs\n"
176            "where each SWITCH is an active OpenFlow connection method.\n",
177            program_name, program_name);
178     vconn_usage(true, false);
179     printf("\nOptions:\n"
180            "  -v, --verbose               set maximum verbosity level\n"
181            "  -h, --help                  display this help message\n"
182            "  -V, --version               display version information\n");
183     exit(EXIT_SUCCESS);
184 }
185
186 static void run(int retval, const char *message, ...)
187     PRINTF_FORMAT(2, 3);
188
189 static void run(int retval, const char *message, ...)
190 {
191     if (retval) {
192         va_list args;
193
194         fprintf(stderr, "%s: ", program_name);
195         va_start(args, message);
196         vfprintf(stderr, message, args);
197         va_end(args);
198         if (retval == EOF) {
199             fputs(": unexpected end of file\n", stderr);
200         } else {
201             fprintf(stderr, ": %s\n", strerror(retval));
202         }
203
204         exit(EXIT_FAILURE);
205     }
206 }
207 \f
208 #ifdef HAVE_NETLINK
209 /* Netlink-only commands. */
210
211 static int  if_up(const char* intf)
212 {
213     char command[256];
214     snprintf(command, sizeof command, "%s %s up &> /dev/null",
215             ifconfigbin, intf);
216     return system(command);
217 }
218
219 static void open_nl_vconn(const char *name, bool subscribe, struct dpif *dpif)
220 {
221     if (strncmp(name, "nl:", 3)
222         || strlen(name) < 4
223         || name[strspn(name + 3, "0123456789") + 3]) {
224         fatal(0, "%s: argument is not of the form \"nl:DP_ID\"", name);
225     }
226     run(dpif_open(atoi(name + 3), subscribe, dpif), "opening datapath");
227 }
228
229 static void do_add_dp(int argc UNUSED, char *argv[])
230 {
231     struct dpif dp;
232     open_nl_vconn(argv[1], false, &dp);
233     run(dpif_add_dp(&dp), "add_dp");
234     dpif_close(&dp);
235 }
236
237 static void do_del_dp(int argc UNUSED, char *argv[])
238 {
239     struct dpif dp;
240     open_nl_vconn(argv[1], false, &dp);
241     run(dpif_del_dp(&dp), "del_dp");
242     dpif_close(&dp);
243 }
244
245 static void do_add_port(int argc UNUSED, char *argv[])
246 {
247     struct dpif dp;
248     if_up(argv[2]);
249     open_nl_vconn(argv[1], false, &dp);
250     run(dpif_add_port(&dp, argv[2]), "add_port");
251     dpif_close(&dp);
252 }
253
254 static void do_del_port(int argc UNUSED, char *argv[])
255 {
256     struct dpif dp;
257     open_nl_vconn(argv[1], false, &dp);
258     run(dpif_del_port(&dp, argv[2]), "del_port");
259     dpif_close(&dp);
260 }
261
262 static void do_monitor(int argc UNUSED, char *argv[])
263 {
264     struct dpif dp;
265     open_nl_vconn(argv[1], true, &dp);
266     for (;;) {
267         struct buffer *b;
268         run(dpif_recv_openflow(&dp, &b, true), "dpif_recv_openflow");
269         ofp_print(stderr, b->data, b->size, 2);
270         buffer_delete(b);
271     }
272 }
273
274 #define BENCHMARK_INCR   100
275
276 static void do_benchmark_nl(int argc UNUSED, char *argv[])
277 {
278     struct dpif dp;
279     uint32_t num_packets, i, milestone;
280     struct timeval start, end;
281
282     open_nl_vconn(argv[1], false, &dp);
283     num_packets = atoi(argv[2]);
284     milestone = BENCHMARK_INCR;
285     run(dpif_benchmark_nl(&dp, num_packets, atoi(argv[3])), "benchmark_nl");
286     if (gettimeofday(&start, NULL) == -1) {
287         run(errno, "gettimeofday");
288     }
289     for (i = 0; i < num_packets;i++) {
290         struct buffer *b;
291         run(dpif_recv_openflow(&dp, &b, true), "dpif_recv_openflow");
292         if (i == milestone) {
293             gettimeofday(&end, NULL);
294             printf("%u packets received in %f ms\n",
295                    BENCHMARK_INCR,
296                    (1000*(double)(end.tv_sec - start.tv_sec))
297                    + (.001*(end.tv_usec - start.tv_usec)));
298             milestone += BENCHMARK_INCR;
299             start = end;
300         }
301         buffer_delete(b);
302     }
303     gettimeofday(&end, NULL);
304     printf("%u packets received in %f ms\n",
305            i - (milestone - BENCHMARK_INCR),
306            (1000*(double)(end.tv_sec - start.tv_sec))
307            + (.001*(end.tv_usec - start.tv_usec)));
308
309     dpif_close(&dp);
310 }
311 #endif /* HAVE_NETLINK */
312 \f
313 /* Generic commands. */
314
315 static uint32_t
316 random_xid(void)
317 {
318     static bool inited = false;
319     if (!inited) {
320         struct timeval tv;
321         inited = true;
322         if (gettimeofday(&tv, NULL) < 0) {
323             fatal(errno, "gettimeofday");
324         }
325         srand(tv.tv_sec ^ tv.tv_usec);
326     }
327     return rand();
328 }
329
330 static void *
331 alloc_openflow_buffer(size_t openflow_len, uint8_t type,
332                       struct buffer **bufferp)
333 {
334         struct buffer *buffer;
335         struct ofp_header *oh;
336
337         buffer = *bufferp = buffer_new(openflow_len);
338         oh = buffer_put_uninit(buffer, openflow_len);
339     memset(oh, 0, openflow_len);
340         oh->version = OFP_VERSION;
341         oh->type = type;
342         oh->length = 0;
343         oh->xid = random_xid();
344         return oh;
345 }
346
347 static void *
348 alloc_stats_request(size_t body_len, uint16_t type, struct buffer **bufferp)
349 {
350     struct ofp_stats_request *rq;
351     rq = alloc_openflow_buffer((offsetof(struct ofp_stats_request, body)
352                                 + body_len), OFPT_STATS_REQUEST, bufferp);
353     rq->type = htons(type);
354     rq->flags = htons(0);
355     return rq->body;
356 }
357
358 static void
359 send_openflow_buffer(struct vconn *vconn, struct buffer *buffer)
360 {
361     struct ofp_header *oh;
362
363     oh = buffer_at_assert(buffer, 0, sizeof *oh);
364     oh->length = htons(buffer->size);
365
366     run(vconn_send_block(vconn, buffer), "failed to send packet to switch");
367 }
368
369 static struct buffer *
370 transact_openflow(struct vconn *vconn, struct buffer *request)
371 {
372     uint32_t send_xid = ((struct ofp_header *) request->data)->xid;
373
374     send_openflow_buffer(vconn, request);
375     for (;;) {
376         uint32_t recv_xid;
377         struct buffer *reply;
378
379         run(vconn_recv_block(vconn, &reply), "OpenFlow packet receive failed");
380         recv_xid = ((struct ofp_header *) reply->data)->xid;
381         if (send_xid == recv_xid) {
382             return reply;
383         }
384
385         VLOG_DBG("received reply with xid %08"PRIx32" != expected %08"PRIx32,
386                  recv_xid, send_xid);
387         buffer_delete(reply);
388     }
389 }
390
391 static void
392 dump_transaction(const char *vconn_name, struct buffer *request)
393 {
394     struct vconn *vconn;
395     struct buffer *reply;
396
397     run(vconn_open_block(vconn_name, &vconn), "connecting to %s", vconn_name);
398     reply = transact_openflow(vconn, request);
399     ofp_print(stdout, reply->data, reply->size, 1);
400     vconn_close(vconn);
401 }
402
403 static void
404 dump_trivial_transaction(const char *vconn_name, uint8_t request_type)
405 {
406     struct buffer *request;
407     alloc_openflow_buffer(sizeof(struct ofp_header), request_type, &request);
408     dump_transaction(vconn_name, request);
409 }
410
411 static void
412 dump_stats_transaction(const char *vconn_name, struct buffer *request)
413 {
414     uint32_t send_xid = ((struct ofp_header *) request->data)->xid;
415     struct vconn *vconn;
416     bool done = false;
417
418     run(vconn_open_block(vconn_name, &vconn), "connecting to %s", vconn_name);
419     send_openflow_buffer(vconn, request);
420     while (!done) {
421         uint32_t recv_xid;
422         struct buffer *reply;
423
424         run(vconn_recv_block(vconn, &reply), "OpenFlow packet receive failed");
425         recv_xid = ((struct ofp_header *) reply->data)->xid;
426         if (send_xid == recv_xid) {
427             struct ofp_stats_reply *osr;
428
429             ofp_print(stdout, reply->data, reply->size, 1);
430
431             osr = buffer_at(reply, 0, sizeof *osr);
432             done = !osr || !(ntohs(osr->flags) & OFPSF_REPLY_MORE);
433         } else {
434             VLOG_DBG("received reply with xid %08"PRIx32" "
435                      "!= expected %08"PRIx32, recv_xid, send_xid);
436         }
437         buffer_delete(reply);
438     }
439     vconn_close(vconn);
440 }
441
442 static void
443 dump_trivial_stats_transaction(const char *vconn_name, uint8_t stats_type)
444 {
445     struct buffer *request;
446     alloc_stats_request(0, stats_type, &request);
447     dump_stats_transaction(vconn_name, request);
448 }
449
450 static void
451 do_show(int argc UNUSED, char *argv[])
452 {
453     dump_trivial_transaction(argv[1], OFPT_FEATURES_REQUEST);
454     dump_trivial_transaction(argv[1], OFPT_GET_CONFIG_REQUEST);
455 }
456
457
458 static void
459 do_dump_tables(int argc, char *argv[])
460 {
461     dump_trivial_stats_transaction(argv[1], OFPST_TABLE);
462 }
463
464
465 static uint32_t
466 str_to_int(const char *str) 
467 {
468     uint32_t value;
469     if (sscanf(str, "%"SCNu32, &value) != 1) {
470         fatal(0, "invalid numeric format %s", str);
471     }
472     return value;
473 }
474
475 static void
476 str_to_mac(const char *str, uint8_t mac[6]) 
477 {
478     if (sscanf(str, "%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8,
479                &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) != 6) {
480         fatal(0, "invalid mac address %s", str);
481     }
482 }
483
484 static void
485 str_to_ip(const char *str, uint32_t *ip) 
486 {
487     struct in_addr in_addr;
488     int retval;
489
490     retval = lookup_ip(str, &in_addr);
491     if (retval) {
492         fatal(0, "%s: could not convert to IP address", str);
493     }
494     *ip = in_addr.s_addr;
495 }
496
497 static void
498 str_to_action(const char *str, struct ofp_action *action) 
499 {
500     uint16_t port;
501
502     if (!strcasecmp(str, "flood")) {
503         port = OFPP_FLOOD;
504     } else if (!strcasecmp(str, "controller")) {
505         port = OFPP_CONTROLLER;
506     } else {
507         port = str_to_int(str);
508     }
509
510     memset(action, 0, sizeof *action);
511     action->type = OFPAT_OUTPUT;
512     action->arg.output.port = htons(port);
513 }
514
515 static void
516 str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
517             uint8_t *table_idx, uint16_t *priority)
518 {
519     struct field {
520         const char *name;
521         uint32_t wildcard;
522         enum { F_U8, F_U16, F_MAC, F_IP } type;
523         size_t offset;
524     };
525
526 #define F_OFS(MEMBER) offsetof(struct ofp_match, MEMBER)
527     static const struct field fields[] = { 
528         { "in_port", OFPFW_IN_PORT, F_U16, F_OFS(in_port) },
529         { "dl_vlan", OFPFW_DL_VLAN, F_U16, F_OFS(dl_vlan) },
530         { "dl_src", OFPFW_DL_SRC, F_MAC, F_OFS(dl_src) },
531         { "dl_dst", OFPFW_DL_DST, F_MAC, F_OFS(dl_dst) },
532         { "dl_type", OFPFW_DL_TYPE, F_U16, F_OFS(dl_type) },
533         { "nw_src", OFPFW_NW_SRC, F_IP, F_OFS(nw_src) },
534         { "nw_dst", OFPFW_NW_DST, F_IP, F_OFS(nw_dst) },
535         { "nw_proto", OFPFW_NW_PROTO, F_U8, F_OFS(nw_proto) },
536         { "tp_src", OFPFW_TP_SRC, F_U16, F_OFS(tp_src) },
537         { "tp_dst", OFPFW_TP_DST, F_U16, F_OFS(tp_dst) },
538     };
539
540     char *name, *value;
541     uint32_t wildcards;
542     bool got_action = false;
543
544     if (table_idx) {
545         *table_idx = 0xff;
546     }
547     if (priority) {
548         *priority = OFP_DEFAULT_PRIORITY;
549     }
550     memset(match, 0, sizeof *match);
551     wildcards = OFPFW_ALL;
552     for (name = strtok(string, "="), value = strtok(NULL, " \t\n");
553          name && value;
554          name = strtok(NULL, "="), value = strtok(NULL, " \t\n"))
555     {
556         const struct field *f;
557         void *data;
558
559         if (action && !strcmp(name, "action")) {
560             got_action = true;
561             str_to_action(value, action);
562             continue;
563         }
564
565         if (table_idx && !strcmp(name, "table")) {
566             *table_idx = atoi(value);
567             continue;
568         }
569
570         if (priority && !strcmp(name, "priority")) {
571             *priority = atoi(value);
572             continue;
573         }
574
575         for (f = fields; f < &fields[ARRAY_SIZE(fields)]; f++) {
576             if (!strcmp(f->name, name)) {
577                 goto found;
578             }
579         }
580         fprintf(stderr, "%s: unknown field %s (fields are",
581                 program_name, name);
582         for (f = fields; f < &fields[ARRAY_SIZE(fields)]; f++) {
583             if (f != fields) {
584                 putc(',', stderr);
585             }
586             fprintf(stderr, " %s", f->name);
587         }
588         fprintf(stderr, ")\n");
589         exit(1);
590
591     found:
592         data = (char *) match + f->offset;
593         if (!strcmp(value, "*")) {
594             wildcards |= f->wildcard;
595         } else {
596             wildcards &= ~f->wildcard;
597             if (f->type == F_U8) {
598                 *(uint8_t *) data = str_to_int(value);
599             } else if (f->type == F_U16) {
600                 *(uint16_t *) data = htons(str_to_int(value));
601             } else if (f->type == F_MAC) {
602                 str_to_mac(value, data);
603             } else if (f->type == F_IP) {
604                 str_to_ip(value, data);
605             } else {
606                 NOT_REACHED();
607             }
608         }
609     }
610     if (name && !value) {
611         fatal(0, "field %s missing value", name);
612     }
613     if (action && !got_action) {
614         fatal(0, "must specify an action");
615     }
616     match->wildcards = htons(wildcards);
617 }
618
619 static void do_dump_flows(int argc, char *argv[])
620 {
621     struct ofp_flow_stats_request *req;
622     struct buffer *request;
623
624     req = alloc_stats_request(sizeof *req, OFPST_FLOW, &request);
625     str_to_flow(argc > 2 ? argv[2] : "", &req->match, NULL, &req->table_id, 
626             NULL);
627     req->type = OFPFS_INDIV;
628     req->pad = 0;
629
630     dump_stats_transaction(argv[1], request);
631 }
632
633 static void do_add_flows(int argc, char *argv[])
634 {
635     struct vconn *vconn;
636
637     FILE *file;
638     char line[1024];
639
640     file = fopen(argv[2], "r");
641     if (file == NULL) {
642         fatal(errno, "%s: open", argv[2]);
643     }
644
645     run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
646     while (fgets(line, sizeof line, file)) {
647         struct buffer *buffer;
648         struct ofp_flow_mod *ofm;
649         uint16_t priority;
650         size_t size;
651
652         char *comment;
653
654         /* Delete comments. */
655         comment = strchr(line, '#');
656         if (comment) {
657             *comment = '\0';
658         }
659
660         /* Drop empty lines. */
661         if (line[strspn(line, " \t\n")] == '\0') {
662             continue;
663         }
664
665         /* Parse and send. */
666         size = sizeof *ofm + sizeof ofm->actions[0];
667         ofm = alloc_openflow_buffer(size, OFPT_FLOW_MOD, &buffer);
668         str_to_flow(line, &ofm->match, &ofm->actions[0], NULL, &priority);
669         ofm->command = htons(OFPFC_ADD);
670         ofm->max_idle = htons(50);
671         ofm->buffer_id = htonl(UINT32_MAX);
672         ofm->priority = htons(priority);
673         ofm->reserved = htonl(0);
674
675         send_openflow_buffer(vconn, buffer);
676     }
677     vconn_close(vconn);
678     fclose(file);
679 }
680
681 static void do_del_flows(int argc, char *argv[])
682 {
683     struct vconn *vconn;
684
685     run(vconn_open_block(argv[1], &vconn), "connecting to %s", argv[1]);
686     struct buffer *buffer;
687     struct ofp_flow_mod *ofm;
688     size_t size;
689
690
691     /* Parse and send. */
692     size = sizeof *ofm;
693     ofm = alloc_openflow_buffer(size, OFPT_FLOW_MOD, &buffer);
694     ofm->command = htons(OFPFC_DELETE);
695     ofm->max_idle = htons(0);
696     ofm->buffer_id = htonl(UINT32_MAX);
697     ofm->priority = htons(0);
698     ofm->reserved = htonl(0);
699     str_to_flow(argc > 2 ? argv[2] : "", &ofm->match, NULL, NULL, NULL);
700
701     send_openflow_buffer(vconn, buffer);
702
703     vconn_close(vconn);
704 }
705
706 static void
707 do_dump_ports(int argc, char *argv[])
708 {
709     dump_trivial_stats_transaction(argv[1], OFPST_PORT);
710 }
711
712 static void do_help(int argc UNUSED, char *argv[] UNUSED)
713 {
714     usage();
715 }
716
717 static struct command all_commands[] = {
718 #ifdef HAVE_NETLINK
719     { "adddp", 1, 1, do_add_dp },
720     { "deldp", 1, 1, do_del_dp },
721     { "addif", 2, 2, do_add_port },
722     { "delif", 2, 2, do_del_port },
723     { "benchmark-nl", 3, 3, do_benchmark_nl },
724 #endif
725
726     { "show", 1, 1, do_show },
727
728     { "help", 0, INT_MAX, do_help },
729     { "monitor", 1, 1, do_monitor },
730     { "dump-tables", 1, 1, do_dump_tables },
731     { "dump-flows", 1, 2, do_dump_flows },
732     { "add-flows", 2, 2, do_add_flows },
733     { "del-flows", 1, 2, do_del_flows },
734     { "dump-ports", 1, 1, do_dump_ports },
735     { NULL, 0, 0, NULL },
736 };