From f823133594320cd15071564126d3b5d554563562 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 6 Jul 2015 10:19:02 -0700 Subject: [PATCH] ofp-util: Require inner and outer message in bundle add to be same version. 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 Acked-by: Jarno Rajahalme --- 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 e6c921195..8d6ad9a90 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 89359c145..3722bf16d 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -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; diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 39a5bbb66..0ac6ea68e 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.20.1