@@ -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;
@@ -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;
}
@@ -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);
@@ -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);
}
}
}
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(-)