[ovs-dev] [monitor 3/3] ovs-ofctl: Make "ovs-ofctl monitor" respond to echo requests.
Ben Pfaff
blp at nicira.com
Fri Feb 1 00:17:14 UTC 2013
Otherwise the command will time out after a while when there's no traffic,
which probably isn't what we want.
Reported-by: Henry Mai <hmai at nicira.com>
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
utilities/ovs-ofctl.c | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 4d8c39f..5591b5f 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1312,8 +1312,12 @@ ofctl_unblock(struct unixctl_conn *conn, int argc OVS_UNUSED,
}
}
+/* Prints to stdout all of the messages received on 'vconn'.
+ *
+ * Iff 'reply_to_echo_requests' is true, sends a reply to any echo request
+ * received on 'vconn'. */
static void
-monitor_vconn(struct vconn *vconn)
+monitor_vconn(struct vconn *vconn, bool reply_to_echo_requests)
{
struct barrier_aux barrier_aux = { vconn, NULL };
struct unixctl_server *server;
@@ -1366,12 +1370,28 @@ monitor_vconn(struct vconn *vconn)
ofptype_decode(&type, b->data);
ofp_print(stderr, b->data, b->size, verbosity + 2);
- ofpbuf_delete(b);
- if (barrier_aux.conn && type == OFPTYPE_BARRIER_REPLY) {
- unixctl_command_reply(barrier_aux.conn, NULL);
- barrier_aux.conn = NULL;
+ switch ((int) type) {
+ case OFPTYPE_BARRIER_REPLY:
+ if (barrier_aux.conn) {
+ unixctl_command_reply(barrier_aux.conn, NULL);
+ barrier_aux.conn = NULL;
+ }
+ break;
+
+ case OFPTYPE_ECHO_REQUEST:
+ if (reply_to_echo_requests) {
+ struct ofpbuf *reply;
+
+ reply = make_echo_reply(b->data);
+ retval = vconn_send(vconn, reply);
+ if (retval && retval != EAGAIN) {
+ ovs_fatal(retval, "failed to send echo reply");
+ }
+ }
+ break;
}
+ ofpbuf_delete(b);
}
if (exiting) {
@@ -1454,7 +1474,7 @@ ofctl_monitor(int argc, char *argv[])
}
}
- monitor_vconn(vconn);
+ monitor_vconn(vconn, true);
}
static void
@@ -1463,7 +1483,7 @@ ofctl_snoop(int argc OVS_UNUSED, char *argv[])
struct vconn *vconn;
open_vconn__(argv[1], SNOOP, &vconn);
- monitor_vconn(vconn);
+ monitor_vconn(vconn, false);
}
static void
--
1.7.2.5
More information about the dev
mailing list