[ovs-dev] [of1.5 v2 20/20] meta-flow: Use OXM-defined constant for TCP flags in OpenFlow 1.5.
Ben Pfaff
blp at nicira.com
Sat May 10 02:40:36 UTC 2014
This also adds the definitions of a few other OXM headers we didn't have
yet.
EXT-109.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
include/openflow/openflow-1.2.h | 15 +++++++++++++--
lib/meta-flow.c | 2 +-
tests/ovs-ofctl.at | 24 ++++++++++++++++++++++++
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/include/openflow/openflow-1.2.h b/include/openflow/openflow-1.2.h
index 54b9804..d25f2dc 100644
--- a/include/openflow/openflow-1.2.h
+++ b/include/openflow/openflow-1.2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2011, 2012, 2013 The Board of Trustees of The Leland Stanford
+/* Copyright (c) 2008, 2011, 2012, 2013, 2014 The Board of Trustees of The Leland Stanford
* Junior University
*
* We are making the OpenFlow specification and associated documentation
@@ -117,7 +117,15 @@ enum oxm12_ofb_match_fields {
OFPXMT13_OFB_TUNNEL_ID, /* Logical Port Metadata */
OFPXMT13_OFB_IPV6_EXTHDR, /* IPv6 Extension Header pseudo-field */
#define OFPXMT13_MASK ((1ULL << (OFPXMT13_OFB_IPV6_EXTHDR + 1)) - 1)
-};
+
+ /* Following added in OpenFlow 1.4. */
+ OFPXMT14_OFB_PBB_UCA = 41, /* PBB UCA header field. */
+#define OFPXMT14_MASK (1ULL << OFPXMT14_OFB_PBB_UCA)
+
+ /* Following added in OpenFlow 1.5. */
+ OFPXMT15_OFB_TCP_FLAGS = 42, /* TCP flags. */
+#define OFPXMT15_MASK (1ULL << OFPXMT15_OFB_TCP_FLAGS)
+ };
/* OXM implementation makes use of NXM as they are the same format
* with different field definitions
@@ -185,6 +193,9 @@ enum oxm12_ofb_match_fields {
#define OXM_OF_TUNNEL_ID_W OXM_HEADER_W (OFPXMT13_OFB_TUNNEL_ID, 8)
#define OXM_OF_IPV6_EXTHDR OXM_HEADER (OFPXMT13_OFB_IPV6_EXTHDR, 2)
#define OXM_OF_IPV6_EXTHDR_W OXM_HEADER_W (OFPXMT13_OFB_IPV6_EXTHDR, 2)
+#define OXM_OF_PBB_UCA OXM_HEADER (OFPXMT14_OFB_PBB_UCA, 1)
+#define OXM_OF_TCP_FLAGS OXM_HEADER (OFPXMT15_OFB_TCP_FLAGS, 2)
+#define OXM_OF_TCP_FLAGS_W OXM_HEADER_W (OFPXMT15_OFB_TCP_FLAGS, 2)
/* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
* special conditions.
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index 5803ded..44fc2a9 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -637,7 +637,7 @@ const struct mf_field mf_fields[MFF_N_IDS] = {
MFP_TCP,
false,
NXM_NX_TCP_FLAGS, "NXM_NX_TCP_FLAGS",
- NXM_NX_TCP_FLAGS, "NXM_NX_TCP_FLAGS", 0,
+ OXM_OF_TCP_FLAGS, "OXM_OF_TCP_FLAGS", OFP15_VERSION,
OFPUTIL_P_NXM_OXM_ANY,
OFPUTIL_P_NXM_OXM_ANY,
-1,
diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at
index 88e4220..d169ce2 100644
--- a/tests/ovs-ofctl.at
+++ b/tests/ovs-ofctl.at
@@ -2132,6 +2132,30 @@ OXM_OF_IN_PORT(00000001), OXM_OF_ETH_TYPE(0800)
])
AT_CLEANUP
+AT_SETUP([check TCP flags expression in OXM and NXM])
+# NXM/OXM input for matching on TCP flags.
+tcp_flags='OXM_OF_ETH_TYPE(0800), OXM_OF_IP_PROTO(06), OXM_OF_TCP_FLAGS(0fff)'
+
+# Check that marshaling into NXM gives all NXM headers.
+AT_CHECK([echo "$tcp_flags" | ovs-ofctl parse-nxm], [0],
+ [NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_NX_TCP_FLAGS(0fff)
+])
+
+# Check that marshaling in OXM for OF1.2 through OF1.4 gives OXM
+# headers except for TCP flags, which didn't have an OXM definition in
+# OF1.2.
+for version in OpenFlow12 OpenFlow13 OpenFlow14; do
+ AT_CHECK([echo "$tcp_flags" | ovs-ofctl parse-oxm $version], [0],
+ [OXM_OF_ETH_TYPE(0800), OXM_OF_IP_PROTO(06), NXM_NX_TCP_FLAGS(0fff)
+])
+done
+
+# In OpenFlow 1.5, though, there's an OXM header for TCP flags:
+AT_CHECK([echo "$tcp_flags" | ovs-ofctl parse-oxm OpenFlow15], [0],
+ [OXM_OF_ETH_TYPE(0800), OXM_OF_IP_PROTO(06), OXM_OF_TCP_FLAGS(0fff)
+])
+AT_CLEANUP
+
dnl Check all of the patterns mentioned in the "VLAN Matching" section
dnl in the DESIGN file at top level.
AT_SETUP([ovs-ofctl check-vlan])
--
1.9.1
More information about the dev
mailing list