ofproto: Add support for barrier command (OpenFlow 0.9)
authorJustin Pettit <jpettit@nicira.com>
Fri, 13 Nov 2009 20:41:57 +0000 (12:41 -0800)
committerJustin Pettit <jpettit@nicira.com>
Sat, 20 Feb 2010 10:22:27 +0000 (02:22 -0800)
OpenFlow 0.9 introduces the concept of the barrier command.  When the
controller sends a Barrier Request, the switch is not allowed to respond
with a Barrier Reply until it has finished processing any other commands
that preceded it.  This commit provides that support.

NOTE: OVS at this point is not wire-compatible with OpenFlow 0.9 until the
final commit in this OpenFlow 0.9 set.

include/openflow/openflow.h
lib/ofp-print.c
ofproto/ofproto.c

index 1376149b0c674658799f663aedcf6932be15977c..60ed8b899c6efd7c30e02cbb83d66ecc952f8727 100644 (file)
@@ -105,7 +105,11 @@ enum ofp_type {
 
     /* Statistics messages. */
     OFPT_STATS_REQUEST,       /* Controller/switch message */
-    OFPT_STATS_REPLY          /* Controller/switch message */
+    OFPT_STATS_REPLY,         /* Controller/switch message */
+
+    /* Barrier messages. */
+    OFPT_BARRIER_REQUEST,     /* Controller/switch message */
+    OFPT_BARRIER_REPLY        /* Controller/switch message */
 };
 
 /* Header on all OpenFlow packets. */
index 926531ec4d4fa856120f8f6ca5e55b0b2a617b82..eb6f521ec254a8ee2bb03fcf1301f593648c15a6 100644 (file)
@@ -1380,6 +1380,18 @@ static const struct openflow_packet packets[] = {
         sizeof (struct ofp_vendor_header),
         NULL,
     },
+    {
+        OFPT_BARRIER_REQUEST,
+        "barrier_request",
+        sizeof (struct ofp_header),
+        NULL,
+    },
+    {
+        OFPT_BARRIER_REPLY,
+        "barrier_reply",
+        sizeof (struct ofp_header),
+        NULL,
+    }
 };
 
 /* Composes and returns a string representing the OpenFlow packet of 'len'
index f80439c8c279bac7be8d1a1ea9fc81adc35d0958..b6b13a15a36af3d04a06e383895c09dfb65163b8 100644 (file)
@@ -3013,6 +3013,19 @@ handle_vendor(struct ofproto *p, struct ofconn *ofconn, void *msg)
     return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_BAD_SUBTYPE);
 }
 
+static int
+handle_barrier_request(struct ofconn *ofconn, struct ofp_header *oh)
+{
+    struct ofp_header *ob;
+    struct ofpbuf *buf;
+
+    /* Currently, everything executes synchronously, so we can just
+     * immediately send the barrier reply. */
+    ob = make_openflow_xid(sizeof *ob, OFPT_BARRIER_REPLY, oh->xid, &buf);
+    queue_tx(buf, ofconn, ofconn->reply_counter);
+    return 0;
+}
+
 static void
 handle_openflow(struct ofconn *ofconn, struct ofproto *p,
                 struct ofpbuf *ofp_msg)
@@ -3062,6 +3075,10 @@ handle_openflow(struct ofconn *ofconn, struct ofproto *p,
         error = handle_vendor(p, ofconn, ofp_msg->data);
         break;
 
+    case OFPT_BARRIER_REQUEST:
+        error = handle_barrier_request(ofconn, oh);
+        break;
+
     default:
         if (VLOG_IS_WARN_ENABLED()) {
             char *s = ofp_to_string(oh, ntohs(oh->length), 2);