[ovs-dev] [PATCH 3/8] OF1.4 bundles: Verify xids.

Jarno Rajahalme jrajahalme at nicira.com
Mon Dec 8 22:01:29 UTC 2014


A switch may optionally verify that the 'xid' of an added message is
the same as the 'xid' of the bundle add message itself.  Do it.

Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
 lib/ofp-util.c     |    3 +++
 tests/ofp-print.at |   10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 839f56f..8ee51ac 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -8509,6 +8509,9 @@ ofputil_decode_bundle_add(const struct ofp_header *oh,
     if (inner_len < sizeof(struct ofp_header) || inner_len > ofpbuf_size(&b)) {
         return OFPERR_OFPBFC_MSG_BAD_LEN;
     }
+    if (msg->msg->xid != oh->xid) {
+        return OFPERR_OFPBFC_MSG_BAD_XID;
+    }
 
     return 0;
 }
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index c58ab7d..fb227c7 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -3210,6 +3210,16 @@ OFPT_BUNDLE_CONTROL (OF1.4) (xid=0x0):
 ])
 AT_CLEANUP
 
+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 \
+"], [0], [dnl
+OFPT_BUNDLE_ADD_MESSAGE (OF1.4) (xid=0x0): ***decode error: OFPBFC_MSG_BAD_XID***
+])
+AT_CLEANUP
+
 AT_SETUP([OFPT_BUNDLE_ADD_MESSAGE - OFPT_HELLO])
 AT_KEYWORDS([ofp-print])
 AT_CHECK([ovs-ofctl ofp-print "\
-- 
1.7.10.4




More information about the dev mailing list