[ovs-dev] [PATCH] ofp-msgs: Added NXT_REQUESTFORWARD for OF1.0-1.3

Zak Whittington zwhitt.vmware at gmail.com
Tue Oct 23 18:23:32 UTC 2018


Backported OFPT14_REQUESTFORWARD to OF1.0-1.3 as a Nicira
extension. Will only forward GROUP_MOD messages in OF
1.0 through 1.2, since METER_MOD was only added in 1.3.

VMware-BZ: 2136594
Signed-off-by: Zak Whittington <zwhitt.vmware at gmail.com>
---
 include/openvswitch/ofp-monitor.h |  1 +
 include/openvswitch/ofp-msgs.h    |  5 ++-
 lib/ofp-monitor.c                 | 11 ++++--
 ofproto/connmgr.c                 |  6 +++-
 tests/ofp-print.at                | 76 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 94 insertions(+), 5 deletions(-)

diff --git a/include/openvswitch/ofp-monitor.h b/include/openvswitch/ofp-monitor.h
index 1bfcf92..7015200 100644
--- a/include/openvswitch/ofp-monitor.h
+++ b/include/openvswitch/ofp-monitor.h
@@ -116,6 +116,7 @@ struct ofpbuf *ofputil_encode_flow_monitor_cancel(uint32_t id);
 
 struct ofputil_requestforward {
     ovs_be32 xid;
+    /* Also used for OF 1.0-1.3 when using Nicera Extension: */
     enum ofp14_requestforward_reason reason;
     union {
         /* reason == OFPRFR_METER_MOD. */
diff --git a/include/openvswitch/ofp-msgs.h b/include/openvswitch/ofp-msgs.h
index 8a32a3d..012aa06 100644
--- a/include/openvswitch/ofp-msgs.h
+++ b/include/openvswitch/ofp-msgs.h
@@ -274,6 +274,8 @@ enum ofpraw {
     /* OFPT 1.4+ (31): struct ofp14_table_status, uint8_t[8][]. */
     OFPRAW_OFPT14_TABLE_STATUS,
 
+    /* NXT 1.0-1.3 (132): struct ofp14_requestforward, uint8_t[8][]. */
+    OFPRAW_NXT_REQUESTFORWARD,
     /* OFPT 1.4+ (32): struct ofp14_requestforward, uint8_t[8][]. */
     OFPRAW_OFPT14_REQUESTFORWARD,
 
@@ -645,7 +647,8 @@ enum ofptype {
                                    * OFPRAW_OFPT14_ROLE_STATUS. */
 
     /* Request forwarding by the switch. */
-    OFPTYPE_REQUESTFORWARD,       /* OFPRAW_OFPT14_REQUESTFORWARD. */
+    OFPTYPE_REQUESTFORWARD,       /* OFPRAW_NXT_REQUESTFORWARD.
+                                   * OFPRAW_OFPT14_REQUESTFORWARD. */
 
     /* Asynchronous messages. */
     OFPTYPE_TABLE_STATUS,          /* OFPRAW_OFPT14_TABLE_STATUS. */
diff --git a/lib/ofp-monitor.c b/lib/ofp-monitor.c
index d1853d9..5ae7308 100644
--- a/lib/ofp-monitor.c
+++ b/lib/ofp-monitor.c
@@ -786,7 +786,9 @@ ofputil_flow_update_format(struct ds *s,
 }
 
 /* Encodes 'rf' according to 'protocol', and returns the encoded message.
- * 'protocol' must be for OpenFlow 1.4 or later. */
+ * Version checking should be done before calling this.
+ * (Only OF1.3+ has METER_MOD capabilities)
+ */
 struct ofpbuf *
 ofputil_encode_requestforward(const struct ofputil_requestforward *rf,
                               enum ofputil_protocol protocol)
@@ -812,7 +814,8 @@ ofputil_encode_requestforward(const struct ofputil_requestforward *rf,
     struct ofp_header *inner_oh = inner->data;
     inner_oh->xid = rf->xid;
     inner_oh->length = htons(inner->size);
-
+    /* OFPRAW_OFPT14_REQUESTFORWARD is the same size as
+       OFPRAW_NXT_REQUESTFORWARD:*/
     struct ofpbuf *outer = ofpraw_alloc_xid(OFPRAW_OFPT14_REQUESTFORWARD,
                                             ofp_version, htonl(0),
                                             inner->size);
@@ -836,7 +839,9 @@ ofputil_decode_requestforward(const struct ofp_header *outer,
     struct ofpbuf b = ofpbuf_const_initializer(outer, ntohs(outer->length));
 
     /* Skip past outer message. */
-    ovs_assert(ofpraw_pull_assert(&b) == OFPRAW_OFPT14_REQUESTFORWARD);
+    enum ofpraw raw_msg_type = ofpraw_pull_assert(&b);
+    ovs_assert(raw_msg_type == OFPRAW_OFPT14_REQUESTFORWARD ||
+               raw_msg_type == OFPRAW_NXT_REQUESTFORWARD);
 
     /* Validate inner message. */
     if (b.size < sizeof(struct ofp_header)) {
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 50e0b8f..d8b7603 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1687,8 +1687,12 @@ connmgr_send_requestforward(struct connmgr *mgr, const struct ofconn *source,
     struct ofconn *ofconn;
 
     LIST_FOR_EACH (ofconn, node, &mgr->all_conns) {
+        /* METER_MOD only supported in OF13 and up. */
+        if (rf->reason == OFPRFR_METER_MOD &&
+            rconn_get_version(ofconn->rconn) < OFP13_VERSION)
+            continue;
+
         if (ofconn_receives_async_msg(ofconn, OAM_REQUESTFORWARD, rf->reason)
-            && rconn_get_version(ofconn->rconn) >= OFP14_VERSION
             && ofconn != source) {
             enum ofputil_protocol protocol = ofconn_get_protocol(ofconn);
             ofconn_send(ofconn, ofputil_encode_requestforward(rf, protocol),
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index e38ca4a..966061a 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -3138,6 +3138,82 @@ OFPT_REQUESTFORWARD (OF1.4) (xid=0x2): reason=meter_mod MOD meter=1 flags:0x100
 ])
 AT_CLEANUP
 
+AT_SETUP([NXT_REQUESTFORWARD - inner NXT_GROUP_MOD])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+dnl OF version 1.0; type=extension:
+01 04 \
+dnl size in bytes:
+00 b8 \
+dnl xid:
+00 00 00 02 \
+dnl Nicira vendor number:
+00 00 23 20 \
+dnl subtype (message id number = 132 in this case)
+00 00 00 84 \
+dnl inner msg copied and pasted from NXT_GROUP_MOD test above:
+01 04 00 a8 00 00 00 02 00 00 23 20 00 00 00 1f 00 00 01 00 87 65 43 21 \
+00 60 00 00 ff ff ff ff 00 20 00 08 00 00 00 00 00 00 00 08 00 01 00 00 \
+00 00 00 08 00 64 00 00 00 01 00 08 00 00 00 01 00 20 00 08 00 00 00 01 \
+00 00 00 08 00 02 00 00 00 00 00 08 00 c8 00 00 00 01 00 08 00 00 00 02 \
+00 20 00 08 00 00 00 02 00 00 00 08 00 03 00 00 00 00 00 08 00 c8 00 00 \
+00 01 00 08 00 00 00 03 ff ff 00 28 00 00 15 40 00 00 00 01 00 00 00 00 \
+68 61 73 68 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 \
+"], [0], [dnl
+NXT_REQUESTFORWARD (xid=0x2): reason=group_mod
+ ADD group_id=2271560481,type=select,selection_method=hash,selection_method_param=7,bucket=bucket_id:0,weight:100,watch_port:1,actions=output:1,bucket=bucket_id:1,weight:200,watch_port:2,actions=output:2,bucket=bucket_id:2,weight:200,watch_port:3,actions=output:3
+])
+AT_CLEANUP
+
+AT_SETUP([NXT_REQUESTFORWARD - inner OFPT_GROUP_MOD - OF1.1])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+dnl OF Version 1.1; type=extension:
+02 04 \
+dnl size in bytes:
+00 80 \
+dnl xid:
+00 00 00 02 \
+dnl Nicira vendor number:
+00 00 23 20 \
+dnl subtype (message id number = 132 in this case)
+00 00 00 84 \
+dnl inner msg copied and pasted from OFPT_GROUP_MOD OF1.1 test above:
+02 0f 00 70 11 22 33 44 00 00 01 00 87 65 43 21 \
+00 20 00 64 00 00 00 01 ff ff ff ff 00 00 00 00 \
+00 00 00 10 00 00 00 01 00 00 00 00 00 00 00 00 \
+00 20 00 c8 00 00 00 02 ff ff ff ff 00 00 00 00 \
+00 00 00 10 00 00 00 02 00 00 00 00 00 00 00 00 \
+00 20 00 c8 00 00 00 03 ff ff ff ff 00 00 00 00 \
+00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 00 \
+"], [0], [dnl
+NXT_REQUESTFORWARD (OF1.1) (xid=0x2): reason=group_mod
+ ADD group_id=2271560481,type=select,bucket=weight:100,watch_port:1,actions=output:1,bucket=weight:200,watch_port:2,actions=output:2,bucket=weight:200,watch_port:3,actions=output:3
+])
+AT_CLEANUP
+
+AT_SETUP([NXT_REQUESTFORWARD - inner OFPT_METER_MOD - OF1.3])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+dnl OF Version 1.3; type=extension:
+04 04 \
+dnl size in bytes:
+00 30 \
+dnl xid:
+00 00 00 02 \
+dnl Nicira vendor number:
+00 00 23 20 \
+dnl subtype (message id number = 132 in this case)
+00 00 00 84 \
+dnl inner msg copied and pasted from the valid OFPT_METER_MOD OF1.3 test:
+04 1d 00 20 00 00 00 02 00 00 00 0d 00 00 00 05 \
+00 01 00 10 00 00 04 00 00 00 00 80 00 00 00 00 \
+"], [0], [dnl
+NXT_REQUESTFORWARD (OF1.3) (xid=0x2): reason=meter_mod ADD meter=5 kbps burst stats bands=
+type=drop rate=1024 burst_size=128
+])
+AT_CLEANUP
+
 AT_SETUP([NXT_SET_PACKET_IN])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print "\
-- 
2.7.4



More information about the dev mailing list