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, 23 Jan 2010 02:08:04 +0000 (18:08 -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 1376149..60ed8b8 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 6236a96..397807e 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 d3fd45a..bcffc42 100644 (file)
@@ -3071,6 +3071,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)
@@ -3120,6 +3133,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);