Support for extracting original direction 5 tuple fields from the
connection tracking module may differ on some platforms between the IPv4
original tuple fields vs. IPv6. Detect IPv6 original tuple support
separately and reflect this support up to the OpenFlow layer.

Signed-off-by: Joe Stringer <[email protected]>
---
CC: Sairam Venugopal <[email protected]>

v3: Only serialize IPv6 orig tuple in ODP if datapath support exists.
v2: Fix setting of support.ct_orig_tuple6 field prior to probe.
---
 lib/odp-util.c         |  8 +++++---
 lib/odp-util.h         |  3 ++-
 ofproto/ofproto-dpif.c | 28 +++++++++++++++++++---------
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 1eeac1a38bb9..ec35f6271151 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -4442,8 +4442,9 @@ odp_flow_key_from_flow__(const struct odp_flow_key_parms 
*parms,
         nl_msg_put_unspec(buf, OVS_KEY_ATTR_CT_LABELS, &data->ct_label,
                           sizeof(data->ct_label));
     }
-    if (parms->support.ct_orig_tuple && flow->ct_nw_proto) {
-        if (flow->dl_type == htons(ETH_TYPE_IP)) {
+    if (flow->ct_nw_proto) {
+        if (parms->support.ct_orig_tuple
+            && flow->dl_type == htons(ETH_TYPE_IP)) {
             struct ovs_key_ct_tuple_ipv4 ct = {
                 data->ct_nw_src,
                 data->ct_nw_dst,
@@ -4453,7 +4454,8 @@ odp_flow_key_from_flow__(const struct odp_flow_key_parms 
*parms,
             };
             nl_msg_put_unspec(buf, OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4, &ct,
                               sizeof ct);
-        } else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
+        } else if (parms->support.ct_orig_tuple6
+                   && flow->dl_type == htons(ETH_TYPE_IPV6)) {
             struct ovs_key_ct_tuple_ipv6 ct = {
                 data->ct_ipv6_src,
                 data->ct_ipv6_dst,
diff --git a/lib/odp-util.h b/lib/odp-util.h
index fafbb10ee7d2..aa7fb825b710 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -193,7 +193,8 @@ int odp_flow_from_string(const char *s,
     ODP_SUPPORT_FIELD(bool, ct_state_nat, "CT state NAT")                    \
                                                                              \
     /* Conntrack original direction tuple matching * supported. */           \
-    ODP_SUPPORT_FIELD(bool, ct_orig_tuple, "CT orig tuple")
+    ODP_SUPPORT_FIELD(bool, ct_orig_tuple, "CT orig tuple")                  \
+    ODP_SUPPORT_FIELD(bool, ct_orig_tuple6, "CT orig tuple for IPv6")
 
 /* Indicates support for various fields. This defines how flows will be
  * serialised. */
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 5d247e3e675b..7a17f2141c67 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1358,6 +1358,7 @@ CHECK_FEATURE__(ct_label, ct_label, ct_label.u64.lo, 1, 
ETH_TYPE_IP)
 CHECK_FEATURE__(ct_state_nat, ct_state, ct_state, \
                 CS_TRACKED|CS_SRC_NAT, ETH_TYPE_IP)
 CHECK_FEATURE__(ct_orig_tuple, ct_orig_tuple, ct_nw_proto, 1, ETH_TYPE_IP)
+CHECK_FEATURE__(ct_orig_tuple6, ct_orig_tuple6, ct_nw_proto, 1, ETH_TYPE_IPV6)
 
 #undef CHECK_FEATURE
 #undef CHECK_FEATURE__
@@ -1388,6 +1389,7 @@ check_support(struct dpif_backer *backer)
 
     backer->support.odp.ct_state_nat = check_ct_state_nat(backer);
     backer->support.odp.ct_orig_tuple = check_ct_orig_tuple(backer);
+    backer->support.odp.ct_orig_tuple6 = check_ct_orig_tuple6(backer);
 }
 
 static int
@@ -4266,7 +4268,7 @@ check_mask(struct ofproto_dpif *ofproto, const struct 
miniflow *flow)
      * the features we know of. */
     if (support->ct_state && support->ct_zone && support->ct_mark
         && support->ct_label && support->ct_state_nat
-        && support->ct_orig_tuple) {
+        && support->ct_orig_tuple && support->ct_orig_tuple6) {
         return ct_state & CS_UNSUPPORTED_MASK ? OFPERR_OFPBMC_BAD_MASK : 0;
     }
 
@@ -4283,14 +4285,22 @@ check_mask(struct ofproto_dpif *ofproto, const struct 
miniflow *flow)
         return OFPERR_OFPBMC_BAD_MASK;
     }
 
-    if (!support->ct_orig_tuple &&
-        (MINIFLOW_GET_U8(flow, ct_nw_proto) ||
-         MINIFLOW_GET_U16(flow, ct_tp_src) ||
-         MINIFLOW_GET_U16(flow, ct_tp_dst) ||
-         MINIFLOW_GET_U32(flow, ct_nw_src) ||
-         MINIFLOW_GET_U32(flow, ct_nw_dst) ||
-         !ovs_u128_is_zero(MINIFLOW_GET_U128(flow, ct_ipv6_src)) ||
-         !ovs_u128_is_zero(MINIFLOW_GET_U128(flow, ct_ipv6_dst)))) {
+    if (!support->ct_orig_tuple && !support->ct_orig_tuple6
+        && (MINIFLOW_GET_U8(flow, ct_nw_proto)
+            || MINIFLOW_GET_U16(flow, ct_tp_src)
+            || MINIFLOW_GET_U16(flow, ct_tp_dst))) {
+        return OFPERR_OFPBMC_BAD_MASK;
+    }
+
+    if (!support->ct_orig_tuple
+        && (MINIFLOW_GET_U32(flow, ct_nw_src)
+            || MINIFLOW_GET_U32(flow, ct_nw_dst))) {
+        return OFPERR_OFPBMC_BAD_MASK;
+    }
+
+    if (!support->ct_orig_tuple6
+        && (!ovs_u128_is_zero(MINIFLOW_GET_U128(flow, ct_ipv6_src))
+            || !ovs_u128_is_zero(MINIFLOW_GET_U128(flow, ct_ipv6_dst)))) {
         return OFPERR_OFPBMC_BAD_MASK;
     }
 
-- 
2.11.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to