ofp-util: Require inner and outer message in bundle add to be same version.
authorBen Pfaff <blp@nicira.com>
Mon, 6 Jul 2015 17:19:02 +0000 (10:19 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 7 Jul 2015 03:53:05 +0000 (20:53 -0700)
It doesn't make sense for the messages added to a bundle to have a
different OpenFlow version from the outer OpenFlow version.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
lib/ofp-errors.h
lib/ofp-util.c
tests/ofp-print.at

index e6c9211..8d6ad9a 100644 (file)
@@ -675,6 +675,10 @@ enum ofperr {
     /* OF1.4+(17,15).  Bundle is locking the resource. */
     OFPERR_OFPBFC_BUNDLE_IN_PROGRESS,
 
+    /* NX1.4+(22).  In an OFPT_BUNDLE_ADD_MESSAGE, the OpenFlow version in the
+     * inner and outer messages differ. */
+    OFPERR_NXBFC_BAD_VERSION,
+
 /* ## ------------------------- ## */
 /* ## OFPET_FLOW_MONITOR_FAILED ## */
 /* ## ------------------------- ## */
index 89359c1..3722bf1 100644 (file)
@@ -8849,6 +8849,9 @@ ofputil_decode_bundle_add(const struct ofp_header *oh,
     msg->flags = ntohs(m->flags);
 
     msg->msg = b.data;
+    if (msg->msg->version != oh->version) {
+        return OFPERR_NXBFC_BAD_VERSION;
+    }
     inner_len = ntohs(msg->msg->length);
     if (inner_len < sizeof(struct ofp_header) || inner_len > b.size) {
         return OFPERR_OFPBFC_MSG_BAD_LEN;
index 39a5bbb..0ac6ea6 100644 (file)
@@ -3239,7 +3239,7 @@ AT_SETUP([OFPT_BUNDLE_ADD_MESSAGE - verify xid])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print "\
 05 22 00 20 00 00 00 00 00 00 00 01 00 00 00 01 \
-02 00 00 08 00 00 00 01 00 00 00 00 00 00 00 00 \
+05 00 00 08 00 00 00 01 00 00 00 00 00 00 00 00 \
 "], [0], [dnl
 OFPT_BUNDLE_ADD_MESSAGE (OF1.4) (xid=0x0): ***decode error: OFPBFC_MSG_BAD_XID***
 ])
@@ -3249,7 +3249,7 @@ AT_SETUP([OFPT_BUNDLE_ADD_MESSAGE - reject OFPT_HELLO])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print "\
 05 22 00 20 00 00 00 00 00 00 00 01 00 00 00 01 \
-02 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 \
+05 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 \
 "], [0], [dnl
 OFPT_BUNDLE_ADD_MESSAGE (OF1.4) (xid=0x0): ***decode error: OFPBFC_MSG_UNSUP***
 ])
@@ -3259,7 +3259,7 @@ AT_SETUP([OFPT_BUNDLE_ADD_MESSAGE - FLOW_MOD])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print "\
 05 22 00 a0 00 00 00 02 00 00 00 01 00 00 00 01 \
-03 0e 00 90 00 00 00 02 00 00 00 00 00 00 00 00 \
+05 0e 00 90 00 00 00 02 00 00 00 00 00 00 00 00 \
 00 00 00 00 00 00 00 00 01 00 00 00 00 00 ff ff \
 ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00 \
 00 01 00 42 80 00 00 04 00 00 00 01 80 00 08 06 \
@@ -3271,7 +3271,7 @@ ff ff ff ff ff ff ff ff ff ff ff ff 00 00 00 00 \
 "], [0], [dnl
 OFPT_BUNDLE_ADD_MESSAGE (OF1.4) (xid=0x2):
  bundle_id=0x1 flags=atomic
-OFPT_FLOW_MOD (OF1.2) (xid=0x2): ADD table:1 priority=65535,arp,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2 actions=output:3
+OFPT_FLOW_MOD (OF1.4) (xid=0x2): ADD table:1 priority=65535,arp,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,arp_spa=192.168.0.2,arp_tpa=192.168.0.1,arp_op=2 actions=output:3
 ])
 AT_CLEANUP