From 4a1c5a01967225086795f5660fec4098f458948c Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Fri, 13 Nov 2009 12:41:57 -0800 Subject: [PATCH] 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. --- include/openflow/openflow.h | 6 +++++- lib/ofp-print.c | 12 ++++++++++++ ofproto/ofproto.c | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) 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 6236a9689..397807e43 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 d3fd45a3d..bcffc42e7 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -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); -- 2.43.0