ovs-ofctl: Fix "snoop" command.
authorBen Pfaff <blp@nicira.com>
Fri, 27 Jan 2012 17:22:41 +0000 (09:22 -0800)
committerEthan Jackson <ethan@nicira.com>
Sat, 18 Feb 2012 17:45:43 +0000 (09:45 -0800)
The vconn that "snoop" opens does not process and reply to requests, so
sending a request to set the packet-in format will hang forever, which
means that "snoop" never actually prints any of the traffic that it
receives.

Bug #9346.
Reported-by: Alan Shieh <ashieh@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
AUTHORS
utilities/ovs-ofctl.8.in
utilities/ovs-ofctl.c

diff --git a/AUTHORS b/AUTHORS
index 6be092f..150d1bb 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -61,6 +61,7 @@ provided helpful bug reports or suggestions.
 
 Aaron M. Ucko           ucko@debian.org
 Ahmed Bilal             numan252@gmail.com
+Alan Shieh              ashieh@nicira.com
 Alban Browaeys          prahal@yahoo.com
 Alex Yip                alex@nicira.com
 Alexey I. Froloff       raorn@altlinux.org
index 4bfd543..cacf039 100644 (file)
@@ -1069,7 +1069,7 @@ allow the switch to choose its default if \fBnxm\fR is unsupported.  When
 \fIformat\fR is one of the formats listed in the above table, \fBovs\-ofctl\fR
 will insist on the selected format.  If the switch does not support the
 requested format, \fBovs\-ofctl\fR will report a fatal error.  This option only
-affects the \fBmonitor\fR and \fBsnoop\fR commands.
+affects the \fBmonitor\fR command.
 .
 .IP "\fB\-m\fR"
 .IQ "\fB\-\-more\fR"
index 995a6c6..d9d1d19 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -800,24 +800,6 @@ monitor_vconn(struct vconn *vconn)
     bool exiting = false;
     int error, fd;
 
-    if (preferred_packet_in_format >= 0) {
-        set_packet_in_format(vconn, preferred_packet_in_format);
-    } else {
-        struct ofpbuf *spif, *reply;
-
-        spif = ofputil_make_set_packet_in_format(NXPIF_NXM);
-        run(vconn_transact_noreply(vconn, spif, &reply),
-            "talking to %s", vconn_get_name(vconn));
-        if (reply) {
-            char *s = ofp_to_string(reply->data, reply->size, 2);
-            VLOG_DBG("%s: failed to set packet in format to nxm, controller"
-                     " replied: %s. Falling back to the switch default.",
-                     vconn_get_name(vconn), s);
-            free(s);
-            ofpbuf_delete(reply);
-        }
-    }
-
     /* Daemonization will close stderr but we really want to keep it, so make a
      * copy. */
     fd = dup(STDERR_FILENO);
@@ -875,6 +857,24 @@ do_monitor(int argc, char *argv[])
         config.miss_send_len = htons(atoi(argv[2]));
         set_switch_config(vconn, &config);
     }
+    if (preferred_packet_in_format >= 0) {
+        set_packet_in_format(vconn, preferred_packet_in_format);
+    } else {
+        struct ofpbuf *spif, *reply;
+
+        spif = ofputil_make_set_packet_in_format(NXPIF_NXM);
+        run(vconn_transact_noreply(vconn, spif, &reply),
+            "talking to %s", vconn_get_name(vconn));
+        if (reply) {
+            char *s = ofp_to_string(reply->data, reply->size, 2);
+            VLOG_DBG("%s: failed to set packet in format to nxm, controller"
+                     " replied: %s. Falling back to the switch default.",
+                     vconn_get_name(vconn), s);
+            free(s);
+            ofpbuf_delete(reply);
+        }
+    }
+
     monitor_vconn(vconn);
 }