diff mbox series

[ovs-dev,v2,3/6] conntrack: Do not use atomics to report zones info.

Message ID 20240930205034.65484-3-pvalerio@redhat.com
State Accepted
Commit 8ff40f33581ba2548d6b772b0834892d389cf03b
Delegated to: aaron conole
Headers show
Series [ovs-dev,v2,1/6] conntrack: Correctly annotate conntrack member. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Paolo Valerio Sept. 30, 2024, 8:50 p.m. UTC
Atomics are not needed when reporting zone limits.
Remove the restriction by defining a non-atomic common structure
to report such data.
The change also access atomics using the related operations to
retrieve atomics reporting only the fields required by the requesting
level instead of relying of struct copy.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
---
 lib/conntrack-private.h |  8 ++++++++
 lib/conntrack.c         | 11 ++++++-----
 lib/conntrack.h         |  9 ++++-----
 lib/dpif-netdev.c       |  6 +++---
 4 files changed, 21 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/lib/conntrack-private.h b/lib/conntrack-private.h
index 6c65caa07..2c625d710 100644
--- a/lib/conntrack-private.h
+++ b/lib/conntrack-private.h
@@ -198,6 +198,14 @@  enum ct_ephemeral_range {
 #define FOR_EACH_PORT_IN_RANGE(curr, min, max) \
     FOR_EACH_PORT_IN_RANGE__(curr, min, max, OVS_JOIN(idx, __COUNTER__))
 
+
+struct conntrack_zone_limit {
+    int32_t zone;
+    uint32_t limit;
+    atomic_count count;
+    uint32_t zone_limit_seq; /* Used to disambiguate zone limit counts. */
+};
+
 struct conntrack {
     struct ovs_mutex ct_lock; /* Protects the following fields. */
     struct cmap conns[UINT16_MAX + 1] OVS_GUARDED;
diff --git a/lib/conntrack.c b/lib/conntrack.c
index 8cf200e06..112d43216 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -330,18 +330,19 @@  zone_limit_lookup_or_default(struct conntrack *ct, int32_t zone)
     return zl ? zl : zone_limit_lookup(ct, DEFAULT_ZONE);
 }
 
-struct conntrack_zone_limit
+struct conntrack_zone_info
 zone_limit_get(struct conntrack *ct, int32_t zone)
 {
-    struct conntrack_zone_limit czl = {
+    struct conntrack_zone_info czl = {
         .zone = DEFAULT_ZONE,
         .limit = 0,
-        .count = ATOMIC_COUNT_INIT(0),
-        .zone_limit_seq = 0,
+        .count = 0,
     };
     struct zone_limit *zl = zone_limit_lookup_or_default(ct, zone);
     if (zl) {
-        czl = zl->czl;
+        czl.zone = zl->czl.zone;
+        czl.limit = zl->czl.limit;
+        czl.count = atomic_count_get(&zl->czl.count);
     }
     return czl;
 }
diff --git a/lib/conntrack.h b/lib/conntrack.h
index 13bb02ea9..c3136e955 100644
--- a/lib/conntrack.h
+++ b/lib/conntrack.h
@@ -115,11 +115,10 @@  struct conntrack_dump {
     uint16_t current_zone;
 };
 
-struct conntrack_zone_limit {
+struct conntrack_zone_info {
     int32_t zone;
     uint32_t limit;
-    atomic_count count;
-    uint32_t zone_limit_seq; /* Used to disambiguate zone limit counts. */
+    unsigned int count;
 };
 
 struct timeout_policy {
@@ -161,8 +160,8 @@  int conntrack_set_sweep_interval(struct conntrack *ct, uint32_t ms);
 uint32_t conntrack_get_sweep_interval(struct conntrack *ct);
 bool conntrack_get_tcp_seq_chk(struct conntrack *ct);
 struct ipf *conntrack_ipf_ctx(struct conntrack *ct);
-struct conntrack_zone_limit zone_limit_get(struct conntrack *ct,
-                                           int32_t zone);
+struct conntrack_zone_info zone_limit_get(struct conntrack *ct,
+                                          int32_t zone);
 int zone_limit_update(struct conntrack *ct, int32_t zone, uint32_t limit);
 int zone_limit_delete(struct conntrack *ct, int32_t zone);
 
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 3d262463f..2a529f272 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9732,7 +9732,7 @@  dpif_netdev_ct_get_limits(struct dpif *dpif,
                            struct ovs_list *zone_limits_reply)
 {
     struct dp_netdev *dp = get_dp_netdev(dpif);
-    struct conntrack_zone_limit czl;
+    struct conntrack_zone_info czl;
 
     if (!ovs_list_is_empty(zone_limits_request)) {
         struct ct_dpif_zone_limit *zone_limit;
@@ -9741,7 +9741,7 @@  dpif_netdev_ct_get_limits(struct dpif *dpif,
             if (czl.zone == zone_limit->zone || czl.zone == DEFAULT_ZONE) {
                 ct_dpif_push_zone_limit(zone_limits_reply, zone_limit->zone,
                                         czl.limit,
-                                        atomic_count_get(&czl.count));
+                                        czl.count);
             } else {
                 return EINVAL;
             }
@@ -9757,7 +9757,7 @@  dpif_netdev_ct_get_limits(struct dpif *dpif,
             czl = zone_limit_get(dp->conntrack, z);
             if (czl.zone == z) {
                 ct_dpif_push_zone_limit(zone_limits_reply, z, czl.limit,
-                                        atomic_count_get(&czl.count));
+                                        czl.count);
             }
         }
     }