mirror of
https://github.com/openvswitch/ovs
synced 2025-10-17 14:28:02 +00:00
dpif-netdev: Implement conntrack flush interface.
New functions are implemented in the conntrack module to support this. Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com> Acked-by: Flavio Leitner <fbl@sysclose.org>
This commit is contained in:
@@ -1171,3 +1171,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;
|
||||
}
|
||||
|
@@ -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) */
|
||||
|
@@ -4593,6 +4593,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,
|
||||
@@ -4637,7 +4645,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
|
||||
|
Reference in New Issue
Block a user