]> git.proxmox.com Git - ovs.git/commitdiff
conntrack: Don't re-add cleaned 'conn' to expiry list.
authorDarrell Ball <dlu998@gmail.com>
Tue, 28 May 2019 18:14:42 +0000 (11:14 -0700)
committerBen Pfaff <blp@ovn.org>
Wed, 5 Jun 2019 21:58:43 +0000 (14:58 -0700)
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>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/conntrack-private.h
lib/conntrack.c

index 51b7d7f7658276c60b507915849edaea5eef843f..bcfbe104b973ed34dc96b8244ccf4c014a1d056e 100644 (file)
@@ -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);
 
index d7d48a43a5883d9a43332e3c3954a7b58cba0f8f..c57d9fdf5d46b7eaa941fc662f0c655c1cf31eff 100644 (file)
@@ -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);