From: Justin Pettit Date: Fri, 13 Nov 2009 20:41:57 +0000 (-0800) Subject: ofproto: Add support for barrier command (OpenFlow 0.9) X-Git-Tag: v1.0.0~259^2~107 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=246e61ea75df598de1ef11130ca32407196dd736;p=sliver-openvswitch.git ofproto: Add support for barrier command (OpenFlow 0.9) 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. --- diff --git a/include/openflow/openflow.h b/include/openflow/openflow.h index 1376149b0..60ed8b899 100644 --- a/include/openflow/openflow.h +++ b/include/openflow/openflow.h @@ -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. */ diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 926531ec4..eb6f521ec 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -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' diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index f80439c8c..b6b13a15a 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -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);