- Update the CT comparison function to compare individual fields instead of
NdisEqualMemory.
- Add in some padding for the ct_endpoint's union.
- Update the Orig Tuple to use ICMP Type and Code instead of Port for ICMP

Co-authored-by: Sairam Venugopal <vsai...@vmware.com>
Signed-off-by: Anand Kumar <kumaran...@vmware.com>
---
 datapath-windows/ovsext/Conntrack.c | 27 +++++++++++++++++++++------
 datapath-windows/ovsext/Conntrack.h |  5 ++++-
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/datapath-windows/ovsext/Conntrack.c 
b/datapath-windows/ovsext/Conntrack.c
index 917ebee..81c2167 100644
--- a/datapath-windows/ovsext/Conntrack.c
+++ b/datapath-windows/ovsext/Conntrack.c
@@ -373,10 +373,18 @@ OvsDetectCtPacket(OvsForwardingContext *fwdCtx,
 BOOLEAN
 OvsCtKeyAreSame(OVS_CT_KEY ctxKey, OVS_CT_KEY entryKey)
 {
-    return ((NdisEqualMemory(&ctxKey.src, &entryKey.src,
-                             sizeof(struct ct_endpoint))) &&
-            (NdisEqualMemory(&ctxKey.dst, &entryKey.dst,
-                             sizeof(struct ct_endpoint))) &&
+    return ((ctxKey.src.addr.ipv4 == entryKey.src.addr.ipv4) &&
+            (ctxKey.src.addr.ipv4_aligned == entryKey.src.addr.ipv4_aligned) &&
+            (ctxKey.src.port == entryKey.src.port) &&
+            (ctxKey.src.icmp_id == entryKey.src.icmp_id) &&
+            (ctxKey.src.icmp_type == entryKey.src.icmp_type) &&
+            (ctxKey.src.icmp_code == entryKey.src.icmp_code) &&
+            (ctxKey.dst.addr.ipv4 == entryKey.dst.addr.ipv4) &&
+            (ctxKey.dst.addr.ipv4_aligned == entryKey.dst.addr.ipv4_aligned) &&
+            (ctxKey.dst.port == entryKey.dst.port) &&
+            (ctxKey.dst.icmp_id == entryKey.dst.icmp_id) &&
+            (ctxKey.dst.icmp_type == entryKey.dst.icmp_type) &&
+            (ctxKey.dst.icmp_code == entryKey.dst.icmp_code) &&
             (ctxKey.dl_type == entryKey.dl_type) &&
             (ctxKey.nw_proto == entryKey.nw_proto) &&
             (ctxKey.zone == entryKey.zone));
@@ -782,9 +790,16 @@ OvsCtExecute_(OvsForwardingContext *fwdCtx,
 
         key->ct.tuple_ipv4.ipv4_src = ctKey->src.addr.ipv4_aligned;
         key->ct.tuple_ipv4.ipv4_dst = ctKey->dst.addr.ipv4_aligned;
-        key->ct.tuple_ipv4.src_port = ctKey->src.port;
-        key->ct.tuple_ipv4.dst_port = ctKey->dst.port;
         key->ct.tuple_ipv4.ipv4_proto = ctKey->nw_proto;
+
+        /* Orig tuple Port is overloaded to take in ICMP-Type & Code */
+        /* This mimics the behavior in lib/conntrack.c*/
+        key->ct.tuple_ipv4.src_port = ctKey->nw_proto != IPPROTO_ICMP ?
+                                      ctKey->src.port :
+                                      htons(ctKey->src.icmp_type);
+        key->ct.tuple_ipv4.dst_port = ctKey->nw_proto != IPPROTO_ICMP ?
+                                      ctKey->dst.port :
+                                      htons(ctKey->src.icmp_code);
     }
 
     if (entryCreated && entry) {
diff --git a/datapath-windows/ovsext/Conntrack.h 
b/datapath-windows/ovsext/Conntrack.h
index 04ca299..4904c7e 100644
--- a/datapath-windows/ovsext/Conntrack.h
+++ b/datapath-windows/ovsext/Conntrack.h
@@ -41,7 +41,10 @@ struct ct_addr {
 struct ct_endpoint {
     struct ct_addr addr;
     union {
-        ovs_be16 port;
+        struct {
+            ovs_be16 port;
+            uint16 pad_port;
+        };
         struct {
             ovs_be16 icmp_id;
             uint8_t icmp_type;
-- 
2.9.3.windows.1

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to