[ovs-dev,v1,1/2] conntrack: Don't re-add cleaned 'conn' to expiry list.
diff mbox series

Message ID 1558815379-75858-1-git-send-email-dlu998@gmail.com
State New
Headers show
Series
  • [ovs-dev,v1,1/2] conntrack: Don't re-add cleaned 'conn' to expiry list.
Related show

Commit Message

Darrell Ball May 25, 2019, 8:16 p.m. UTC
When a 'conn' entry is cleaned up from an expiry list, we don't
want to put it back during an update.  Hence, we detect and block this.

Fixes: 967bb5c5cd90 ("conntrack: Add rcu support.")
Signed-off-by: Darrell Ball <dlu998@gmail.com>
---
 lib/conntrack-private.h | 11 +++++++----
 lib/conntrack.c         |  2 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/lib/conntrack-private.h b/lib/conntrack-private.h
index 51b7d7f..bcfbe10 100644
--- a/lib/conntrack-private.h
+++ b/lib/conntrack-private.h
@@ -102,11 +102,12 @@  struct conn {
     /* Mutable data. */
     struct ovs_mutex lock; /* Guards all mutable fields. */
     ovs_u128 label;
-    uint32_t mark;
     long long expiration;
+    uint32_t mark;
     int seq_skew;
     bool seq_skew_dir; /* TCP sequence skew direction due to NATTing of FTP
                         * control messages; true if reply direction. */
+    bool cleaned; /* True if cleaned from expiry lists. */
 
     /* Immutable data. */
     bool alg_related; /* True if alg data connection. */
@@ -218,9 +219,11 @@  conn_update_expiration(struct conntrack *ct, struct conn *conn,
 
     ovs_mutex_lock(&ct->ct_lock);
     ovs_mutex_lock(&conn->lock);
-    conn->expiration = now + ct_timeout_val[tm];
-    ovs_list_remove(&conn->exp_node);
-    ovs_list_push_back(&ct->exp_lists[tm], &conn->exp_node);
+    if (!conn->cleaned) {
+        conn->expiration = now + ct_timeout_val[tm];
+        ovs_list_remove(&conn->exp_node);
+        ovs_list_push_back(&ct->exp_lists[tm], &conn->exp_node);
+    }
     ovs_mutex_unlock(&conn->lock);
     ovs_mutex_unlock(&ct->ct_lock);
 
diff --git a/lib/conntrack.c b/lib/conntrack.c
index d7d48a4..c57d9fd 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -343,6 +343,7 @@  conn_clean(struct conntrack *ct, struct conn *conn)
         cmap_remove(&ct->conns, &conn->nat_conn->cm_node, hash);
     }
     ovs_list_remove(&conn->exp_node);
+    conn->cleaned = true;
     ovsrcu_postpone(delete_conn, conn);
     atomic_count_dec(&ct->n_conn);
 }
@@ -354,6 +355,7 @@  conn_clean_one(struct conntrack *ct, struct conn *conn)
     conn_clean_cmn(ct, conn);
     if (conn->conn_type == CT_CONN_TYPE_DEFAULT) {
         ovs_list_remove(&conn->exp_node);
+        conn->cleaned = true;
         atomic_count_dec(&ct->n_conn);
     }
     ovsrcu_postpone(delete_conn_one, conn);