[ovs-dev] [PATCH v2 3/9] datapath-windows: Add support for flushing conntrack entries

Sairam Venugopal vsairam at vmware.com
Fri Jun 24 18:43:00 UTC 2016


Flush out all conntrack entries or those that match a given zone. Since
the conntrack module is internal to OVS in Windows, this functionality
needs to be added in.

Signed-off-by: Sairam Venugopal <vsairam at vmware.com>
---
 datapath-windows/ovsext/Conntrack.c | 75 +++++++++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git a/datapath-windows/ovsext/Conntrack.c b/datapath-windows/ovsext/Conntrack.c
index 5fc9282..15c495d 100644
--- a/datapath-windows/ovsext/Conntrack.c
+++ b/datapath-windows/ovsext/Conntrack.c
@@ -624,3 +624,78 @@ ovsConntrackEntryCleaner(PVOID data)
 
     PsTerminateSystemThread(STATUS_SUCCESS);
 }
+
+/*
+ *----------------------------------------------------------------------------
+ * OvsCtFlush
+ *     Flushes out all Conntrack Entries that match the given zone
+ *----------------------------------------------------------------------------
+ */
+static __inline NDIS_STATUS
+OvsCtFlush(UINT16 zone)
+{
+    PLIST_ENTRY link, next;
+    POVS_CT_ENTRY entry;
+
+    LOCK_STATE_EX lockState;
+    NdisAcquireRWLockWrite(ovsConntrackLockObj, &lockState, 0);
+
+    for (int i = 0; i < CT_HASH_TABLE_SIZE; i++) {
+        LIST_FORALL_SAFE(&ovsConntrackTable[i], link, next) {
+            entry = CONTAINING_RECORD(link, OVS_CT_ENTRY, link);
+            if (!zone || zone == entry->key.zone)
+                OvsCtEntryDelete(entry);
+        }
+    }
+
+    NdisReleaseRWLock(ovsConntrackLockObj, &lockState);
+    return NDIS_STATUS_SUCCESS;
+}
+
+NTSTATUS
+OvsCtDeleteCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
+                      UINT32 *replyLen)
+{
+    POVS_MESSAGE msgIn = (POVS_MESSAGE)usrParamsCtx->inputBuffer;
+    PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg);
+    PNL_ATTR ctAttrs[__CTA_MAX];
+    UINT32 attrOffset = NLMSG_HDRLEN + NF_GEN_MSG_HDRLEN + OVS_HDRLEN;
+    NL_ERROR nlError = NL_ERROR_SUCCESS;
+    NTSTATUS status;
+    UINT16 zone = 0;
+
+    static const NL_POLICY ctZonePolicy[] = {
+        [CTA_ZONE] = { .type = NL_A_BE16, .optional = TRUE },
+    };
+
+    if ((NlAttrParse(nlMsgHdr, attrOffset, NfNlMsgAttrsLen(nlMsgHdr),
+        ctZonePolicy, ARRAY_SIZE(ctZonePolicy),
+        ctAttrs, ARRAY_SIZE(ctAttrs)))
+        != TRUE) {
+        OVS_LOG_ERROR("Zone attr parsing failed for msg: %p", nlMsgHdr);
+        status = STATUS_INVALID_PARAMETER;
+        goto done;
+    }
+
+    if (ctAttrs[CTA_ZONE]) {
+        zone = NlAttrGetU16(ctAttrs[CTA_ZONE]);
+    }
+
+    status = OvsCtFlush(zone);
+
+done:
+    if (status) {
+        nlError = NlMapStatusToNlErr(status);
+    }
+    if (nlError != NL_ERROR_SUCCESS) {
+        POVS_MESSAGE_ERROR msgError = (POVS_MESSAGE_ERROR)
+                                       usrParamsCtx->outputBuffer;
+
+        ASSERT(msgError);
+        NlBuildErrorMsg(msgIn, msgError, nlError, replyLen);
+        ASSERT(*replyLen != 0);
+        status = STATUS_SUCCESS;
+    }
+
+    return status;
+}
-- 
2.5.0.windows.1




More information about the dev mailing list