diff mbox series

[ovs-dev,RFC,5/5] conntrack: Make ovs-appctl dpctl/ct-bkts work with multiple buckets

Message ID 163820917300.3001886.2414895920910370135.stgit@fed.void
State RFC
Headers show
Series conntrack: Introduce buckets and reduce contention. | expand

Commit Message

Paolo Valerio Nov. 29, 2021, 6:06 p.m. UTC
Without this patch "ovs-appctl dpctl/ct-bkts" produces the following
output:

Total Buckets: 1
Current Connections: 10246

+-----------+-----------------------------------------+
|  Buckets  |         Connections per Buckets         |
+-----------+-----------------------------------------+
   0..  7   |     10246

with this patch applied, the output becomes:

Total Buckets: 1024
Current Connections: 95956

+-----------+-----------------------------------------+
|  Buckets  |         Connections per Buckets         |
+-----------+-----------------------------------------+
   0..  7   |    87  100   90   91   92   92  101   83
   8.. 15   |    98   86   80   91   92   93   92   84
  16.. 23   |    82  114  103   90   94   80   95   96
  ...
 1000..1007   |    98   88  106  100   91   99   89   81
 1008..1015   |    97   99   93   67  102   97   89   86
 1016..1023   |   113   79   97   86  106   93   80   90

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
---
 lib/conntrack.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 1c019af29..cbeafb22b 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -2675,7 +2675,7 @@  tuple_to_conn_key(const struct ct_dpif_tuple *tuple, uint16_t zone,
 
 static void
 conn_to_ct_dpif_entry(const struct conn *conn, struct ct_dpif_entry *entry,
-                      long long now)
+                      long long now, unsigned int bkt)
 {
     const struct conn_key *key = &conn->key_node[CT_DIR_FWD].key,
         *rev_key = &conn->key_node[CT_DIR_REV].key;
@@ -2699,6 +2699,7 @@  conn_to_ct_dpif_entry(const struct conn *conn, struct ct_dpif_entry *entry,
     ovs_mutex_unlock(&conn->lock);
 
     entry->timeout = (expiration > 0) ? expiration / 1000 : 0;
+    entry->bkt = bkt;
 
     if (conn->alg) {
         /* Caller is responsible for freeing. */
@@ -2724,7 +2725,7 @@  conntrack_dump_start(struct conntrack *ct, struct conntrack_dump *dump,
     }
 
     dump->ct = ct;
-    *ptot_bkts = 1; /* Need to clean up the callers. */
+    *ptot_bkts = CONNTRACK_BUCKETS;
     return 0;
 }
 
@@ -2757,7 +2758,7 @@  conntrack_dump_next(struct conntrack_dump *dump, struct ct_dpif_entry *entry)
 
             if ((!dump->filter_zone || keyn->key.zone == dump->zone) &&
                 (keyn->key.dir == CT_DIR_FWD)) {
-                conn_to_ct_dpif_entry(conn, entry, now);
+                conn_to_ct_dpif_entry(conn, entry, now, dump->bucket);
                 break;
             }
         }