New functions are implemented in the conntrack module to support this. Signed-off-by: Daniele Di Proietto <diproiet...@vmware.com> Acked-by: Flavio Leitner <f...@sysclose.org> --- lib/conntrack.c | 23 +++++++++++++++++++++++ lib/conntrack.h | 2 ++ lib/dpif-netdev.c | 10 +++++++++- 3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/lib/conntrack.c b/lib/conntrack.c index 47214e1..15a9582 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1173,3 +1173,26 @@ conntrack_dump_done(struct conntrack_dump *dump OVS_UNUSED) { return 0; } + +int +conntrack_flush(struct conntrack *ct, const uint16_t *zone) +{ + unsigned i; + + for (i = 0; i < CONNTRACK_BUCKETS; i++) { + struct conn *conn, *next; + + ct_lock_lock(&ct->buckets[i].lock); + HMAP_FOR_EACH_SAFE(conn, next, node, &ct->buckets[i].connections) { + if (!zone || *zone == conn->key.zone) { + ovs_list_remove(&conn->exp_node); + hmap_remove(&ct->buckets[i].connections, &conn->node); + atomic_count_dec(&ct->n_conn); + delete_conn(conn); + } + } + ct_lock_unlock(&ct->buckets[i].lock); + } + + return 0; +} diff --git a/lib/conntrack.h b/lib/conntrack.h index 2f0680e..8802d35 100644 --- a/lib/conntrack.h +++ b/lib/conntrack.h @@ -83,6 +83,8 @@ int conntrack_dump_start(struct conntrack *, struct conntrack_dump *, const uint16_t *pzone); int conntrack_dump_next(struct conntrack_dump *, struct ct_dpif_entry *); int conntrack_dump_done(struct conntrack_dump *); + +int conntrack_flush(struct conntrack *, const uint16_t *zone); /* 'struct ct_lock' is a wrapper for an adaptive mutex. It's useful to try * different types of locks (e.g. spinlocks) */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 48861a2..5793995 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -4309,6 +4309,14 @@ dpif_netdev_ct_dump_done(struct dpif *dpif OVS_UNUSED, return err; } +static int +dpif_netdev_ct_flush(struct dpif *dpif, const uint16_t *zone) +{ + struct dp_netdev *dp = get_dp_netdev(dpif); + + return conntrack_flush(&dp->conntrack, zone); +} + const struct dpif_class dpif_netdev_class = { "netdev", dpif_netdev_init, @@ -4352,7 +4360,7 @@ const struct dpif_class dpif_netdev_class = { dpif_netdev_ct_dump_start, dpif_netdev_ct_dump_next, dpif_netdev_ct_dump_done, - NULL, /* ct_flush */ + dpif_netdev_ct_flush, }; static void -- 2.8.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev