[ovs-dev] [PATCH v2 07/15] conntrack: Implement flush function.

Daniele Di Proietto diproiettod at vmware.com
Sat Apr 16 00:02:39 UTC 2016


Signed-off-by: Daniele Di Proietto <diproiettod at vmware.com>
---
 lib/conntrack.c | 21 +++++++++++++++++++++
 lib/conntrack.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 840335b..7913e76 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -849,3 +849,24 @@ delete_conn(struct conn *conn)
 {
     free(conn);
 }
+
+int
+conntrack_flush(struct conntrack *ct, const uint16_t *zone)
+{
+    unsigned i;
+
+    for (i = 0; i < CONNTRACK_BUCKETS; i++) {
+        struct conn *conn, *next;
+
+        ct_lock_lock(&ct->locks[i]);
+        HMAP_FOR_EACH_SAFE(conn, next, node, &ct->connections[i]) {
+            if (!zone || *zone == conn->key.zone) {
+                hmap_remove(&ct->connections[i], &conn->node);
+                delete_conn(conn);
+            }
+        }
+        ct_lock_unlock(&ct->locks[i]);
+    }
+
+    return 0;
+}
diff --git a/lib/conntrack.h b/lib/conntrack.h
index 8561273..7e8b604 100644
--- a/lib/conntrack.h
+++ b/lib/conntrack.h
@@ -68,6 +68,8 @@ int conntrack_execute(struct conntrack *, struct dp_packet **, size_t,
                       bool commit, uint16_t zone, const uint32_t *setmark,
                       const struct ovs_key_ct_labels *setlabel,
                       const char *helper);
+
+int conntrack_flush(struct conntrack *, const uint16_t *zone);
 
 /* struct ct_lock is a standard mutex or a spinlock when using DPDK */
 
-- 
2.1.4




More information about the dev mailing list