[ovs-dev] [PATCH 2/3] ofp-util: Require inner and outer message in bundle add to be same version.
Ben Pfaff
blp at nicira.com
Mon Jul 6 17:20:22 UTC 2015
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 at nicira.com>
---
lib/ofp-errors.h | 4 ++++
lib/ofp-util.c | 3 +++
tests/ofp-print.at | 8 ++++----
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/ofp-errors.h b/lib/ofp-errors.h
index fbcc641..c020f7a 100644
--- a/lib/ofp-errors.h
+++ b/lib/ofp-errors.h
@@ -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 ## */
/* ## ------------------------- ## */
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index f7dbdd5..d02ee3a 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -9096,6 +9096,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;
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index e08a201..83c7b9e 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -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
--
2.1.3
More information about the dev
mailing list