From da51fecc3d2fe47b138d8e8b19dd018e09764210 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 16 Mar 2009 10:07:04 -0700 Subject: [PATCH] dpctl: Allow requesting flow misses, expirations in "monitor" command. This makes it possible to debug problems where one wonders whether flow misses or flow expirations are making it up to the controller. --- utilities/dpctl.8.in | 17 +++++++++++++++-- utilities/dpctl.c | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/utilities/dpctl.8.in b/utilities/dpctl.8.in index e421aa25..0ddbc7eb 100644 --- a/utilities/dpctl.8.in +++ b/utilities/dpctl.8.in @@ -239,13 +239,26 @@ switch's tables are removed. See \fBFlow Syntax\fR, below, for the syntax of \fIflows\fR. .TP -\fBmonitor \fIswitch\fR +\fBmonitor \fIswitch\fR [\fImiss-len\fR [\fIsend-exp]] Connects to \fIswitch\fR and prints to the console all OpenFlow messages received. Usually, \fIswitch\fR should specify a connection named on \fBsecchan\fR(8)'s \fB-l\fR or \fB--listen\fR command line option. -This option may be useful for debugging switch implementations. +If \fImiss-len\fR is provided, \fBdpctl\fR sends an OpenFlow ``set +configuration'' message at connection setup time that requests +\fImiss-len\fR bytes of each packet that misses the flow table. The +OpenFlow reference implementation not send these messages to the +\fBdpctl monitor\fR client connection unless a nonzero value is +specified on this argument. + +If \fIsend-exp\fR is specified as \fB1\fR, \fBdpctl\fR will also +request to be sent flow expiration messages. If this argument is +omitted, or \fB0\fR is specified, then \fRdpctl\fR will not request +flow expirations. + +This command may be useful for debugging switch or controller +implementations. .TP \fBexecute \fIswitch command \fR[\fIarg\fR...] diff --git a/utilities/dpctl.c b/utilities/dpctl.c index f66f9219..c7a17b72 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -238,7 +238,7 @@ usage(void) " add-flows SWITCH FILE add flows from FILE\n" " mod-flows SWITCH FLOW modify actions of matching FLOWs\n" " del-flows SWITCH [FLOW] delete matching FLOWs\n" - " monitor SWITCH print packets received from SWITCH\n" + " monitor SWITCH MISSLEN EXP print packets received from SWITCH\n" " execute SWITCH CMD [ARG...] execute CMD with ARGS on SWITCH\n" "\nFor OpenFlow switches and controllers:\n" " probe VCONN probe whether VCONN is up\n" @@ -1321,6 +1321,17 @@ do_monitor(const struct settings *s UNUSED, int argc UNUSED, char *argv[]) struct vconn *vconn; open_vconn(argv[1], &vconn); + if (argc > 2) { + int miss_send_len = atoi(argv[2]); + int send_flow_exp = argc > 3 ? atoi(argv[3]) : 0; + struct ofp_switch_config *osc; + struct ofpbuf *buf; + + osc = make_openflow(sizeof *osc, OFPT_SET_CONFIG, &buf); + osc->flags = htons(send_flow_exp ? OFPC_SEND_FLOW_EXP : 0); + osc->miss_send_len = htons(miss_send_len); + send_openflow_buffer(vconn, buf); + } for (;;) { struct ofpbuf *b; run(vconn_recv_block(vconn, &b), "vconn_recv"); @@ -1610,7 +1621,7 @@ static struct command all_commands[] = { { "status", 1, 2, do_status }, { "help", 0, INT_MAX, do_help }, - { "monitor", 1, 1, do_monitor }, + { "monitor", 1, 3, do_monitor }, { "dump-desc", 1, 1, do_dump_desc }, { "dump-tables", 1, 1, do_dump_tables }, { "dump-flows", 1, 2, do_dump_flows }, -- 2.30.2