This patch implments some helper function for conntrack zone limit.
It will be useful for the following patches.

Signed-off-by: Yi-Hung Wei <[email protected]>
---
 lib/ct-dpif.c | 22 ++++++++++++++++++++++
 lib/ct-dpif.h |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/lib/ct-dpif.c b/lib/ct-dpif.c
index d1e8a6b8b4a9..f1db8394db5c 100644
--- a/lib/ct-dpif.c
+++ b/lib/ct-dpif.c
@@ -597,3 +597,25 @@ error:
     free(copy);
     return false;
 }
+
+void
+ct_dpif_push_zone_limit(struct ovs_list *zone_limits, uint16_t zone,
+                        uint32_t limit, uint32_t count)
+{
+    struct ct_dpif_zone_limit *zone_limit = xmalloc(sizeof *zone_limit);
+    zone_limit->zone = zone;
+    zone_limit->limit = limit;
+    zone_limit->count = count;
+    ovs_list_push_back(zone_limits, &zone_limit->node);
+}
+
+void
+ct_dpif_free_zone_limits(struct ovs_list *zone_limits)
+{
+    while (!ovs_list_is_empty(zone_limits)) {
+        struct ovs_list *entry = ovs_list_pop_front(zone_limits);
+        struct ct_dpif_zone_limit* cdzl;
+        cdzl = CONTAINER_OF(entry, struct ct_dpif_zone_limit, node);
+        free(cdzl);
+    }
+}
diff --git a/lib/ct-dpif.h b/lib/ct-dpif.h
index fd3ea7205761..7cffd0451e37 100644
--- a/lib/ct-dpif.h
+++ b/lib/ct-dpif.h
@@ -219,5 +219,8 @@ void ct_dpif_format_tuple(struct ds *, const struct 
ct_dpif_tuple *);
 uint8_t ct_dpif_coalesce_tcp_state(uint8_t state);
 void ct_dpif_format_tcp_stat(struct ds *, int, int);
 bool ct_dpif_parse_tuple(struct ct_dpif_tuple *, const char *s, struct ds *);
+void ct_dpif_push_zone_limit(struct ovs_list *, uint16_t zone, uint32_t limit,
+                             uint32_t count);
+void ct_dpif_free_zone_limits(struct ovs_list *);
 
 #endif /* CT_DPIF_H */
-- 
2.7.4

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

Reply via email to