ovs-controller: Add support for OpenFlow queues.
authorBen Pfaff <blp@nicira.com>
Fri, 16 Jul 2010 00:08:17 +0000 (17:08 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 20 Jul 2010 18:22:36 +0000 (11:22 -0700)
Before, ovs-controller always sent packets using OFPAT_OUTPUT, which always
uses the default OpenFlow queue.  To help me debug the Open vSwitch QoS
implementation, I want to be able to send packets on other queues, so
this commit adds that feature.

utilities/ovs-controller.8.in
utilities/ovs-controller.c

index c345644..ab63677 100644 (file)
@@ -1,3 +1,9 @@
+.\" -*- nroff -*-
+.de IQ
+.  br
+.  ns
+.  IP "\\$1"
+..
 .TH ovs\-controller 8 "March 2009" "Open vSwitch" "Open vSwitch Manual"
 .ds PN ovs\-controller
 .
@@ -21,7 +27,8 @@ one or more of the following OpenFlow connection methods:
 .RE
 .
 .SH OPTIONS
-.IP "\fB\-n\fR, \fB\-\-noflow\fR"
+.IP "\fB\-n\fR"
+.IQ "\fB\-\-noflow\fR"
 By default, \fBovs\-controller\fR sets up a flow in each OpenFlow switch
 whenever it receives a packet whose destination is known due through
 MAC learning.  This option disables flow setup, so that every packet
@@ -45,7 +52,8 @@ on its own.  To set the idle time for those flows, pass
 This option has no effect when \fB\-n\fR (or \fB\-\-noflow\fR) is in use
 (because the controller does not set up flows in that case).
 .
-.IP "\fB\-H\fR, \fB\-\-hub\fR"
+.IP "\fB\-H\fR"
+.IQ "\fB\-\-hub\fR"
 By default, the controller acts as an L2 MAC-learning switch.  This
 option changes its behavior to that of a hub that floods packets on
 all but the incoming port.
@@ -57,7 +65,8 @@ through the controller and every packet is flooded.
 This option is most useful for debugging.  It reduces switching
 performance, so it should not be used in production.
 .
-.IP "\fB\-w\fR, \fB\-\-wildcard\fR"
+.IP "\fB\-w\fR"
+.IQ "\fB\-\-wildcard\fR"
 By default, \fBovs\-controller\fR sets up exact-match flows.  This
 option allows it to set up wildcarded flows, which may reduce
 flow-setup latency by causing less traffic to be sent up to the
@@ -66,7 +75,8 @@ controller.
 This option has no effect when \fB\-n\fR (or \fB\-\-noflow\fR) is in use
 (because the controller does not set up flows in that case).
 .
-.IP "\fB\-N\fR, \fB\-\-normal\fR"
+.IP "\fB\-N\fR"
+.IQ "\fB\-\-normal\fR"
 By default, \fBovs\-controller\fR directs packets to a particular port
 or floods them.  This option causes it to direct non-flooded packets
 to the OpenFlow \fBOFPP_NORMAL\fR port.  This allows the switch itself
@@ -81,6 +91,15 @@ to it by switches.
 This option is only for debugging the Open vSwitch implementation of
 ``fail open'' mode.  It must not be used in production.
 .
+.IP "\fB\-q \fIid\fR"
+.IQ "\fB\-\-queue=\fIid\fR"
+By default, \fBovs\-controller\fR uses the default OpenFlow queue for
+sending packets and setting up flows.  Use one of these options,
+supplying \fIid\fR as an OpenFlow queue ID as a decimal number, to
+instead use that specific queue.
+.IP
+This option may be useful for debugging quality of service setups.
+.
 .SS "Public Key Infrastructure Options"
 .so lib/ssl.man
 .so lib/ssl-peer-ca-cert.man
index f4358e9..2ae68ac 100644 (file)
@@ -67,6 +67,9 @@ static int max_idle = 60;
  * of their messages (for debugging fail-open mode). */
 static bool mute = false;
 
+/* -q, --queue: OpenFlow queue to use, or the default queue if UINT32_MAX. */
+static uint32_t queue_id = UINT32_MAX;
+
 /* --unixctl: Name of unixctl socket, or null to use the default. */
 static char *unixctl_path = NULL;
 
@@ -215,6 +218,7 @@ new_switch(struct switch_ *sw, struct vconn *vconn)
     sw->lswitch = lswitch_create(sw->rconn, learn_macs, exact_flows,
                                  set_up_flows ? max_idle : -1,
                                  action_normal);
+    lswitch_set_queue(sw->lswitch, queue_id);
 }
 
 static int
@@ -256,6 +260,7 @@ parse_options(int argc, char *argv[])
         {"wildcard",    no_argument, 0, 'w'},
         {"max-idle",    required_argument, 0, OPT_MAX_IDLE},
         {"mute",        no_argument, 0, OPT_MUTE},
+        {"queue",       required_argument, 0, 'q'},
         {"unixctl",     required_argument, 0, OPT_UNIXCTL},
         {"help",        no_argument, 0, 'h'},
         {"version",     no_argument, 0, 'V'},
@@ -311,6 +316,10 @@ parse_options(int argc, char *argv[])
             }
             break;
 
+        case 'q':
+            queue_id = atoi(optarg);
+            break;
+
         case OPT_UNIXCTL:
             unixctl_path = optarg;
             break;
@@ -359,6 +368,7 @@ usage(void)
            "  --max-idle=SECS         max idle time for new flows\n"
            "  -N, --normal            use OFPAT_NORMAL action\n"
            "  -w, --wildcard          use wildcards, not exact-match rules\n"
+           "  -q, --queue=QUEUE       OpenFlow queue ID to use for output\n"
            "  --unixctl=SOCKET        override default control socket name\n"
            "  -h, --help              display this help message\n"
            "  -V, --version           display version information\n");