This will remove the inefficiencies we would have when just iterating
using a position.

Signed-off-by: Felix Huettner <[email protected]>
---
 lib/conntrack.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/conntrack.c b/lib/conntrack.c
index eb8248ed9..12109f03b 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "conntrack.h"
+#include "cmap.h"
 #include "conntrack-private.h"
 #include "conntrack-tp.h"
 #include "coverage.h"
@@ -1505,7 +1506,6 @@ ct_sweep_zone(struct conntrack *ct, uint16_t zone, long 
long now,
     struct conntrack_zone *cz;
     unsigned int conn_count = 0;
     struct conn *conn;
-    struct cmap_node *node;
     long long expiration;
 
     cz = zone_lookup(ct, zone);
@@ -1517,9 +1517,12 @@ ct_sweep_zone(struct conntrack *ct, uint16_t zone, long 
long now,
         *current_position = xzalloc(sizeof(**current_position));
     }
 
-    while ((node = cmap_next_position(&cz->conns, *current_position))) {
-        keyn = OBJECT_CONTAINING(node, keyn, cm_node);
+    struct cmap_cursor cursor = cmap_position_to_cursor(&cz->conns,
+                                                        *current_position);
+
+    CMAP_CURSOR_FOR_EACH_CONTINUE (keyn, cm_node, &cursor) {
         if (conn_count > limit) {
+            cmap_cursor_to_position(&cursor, *current_position);
             return conn_count;
         }
 
-- 
2.43.0


_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to