Skip to content

Commit

Permalink
dpif-netdev: Implement conntrack flush interface.
Browse files Browse the repository at this point in the history
New functions are implemented in the conntrack module to support this.

Signed-off-by: Daniele Di Proietto <[email protected]>
Acked-by: Flavio Leitner <[email protected]>
  • Loading branch information
ddiproietto committed Jul 28, 2016
1 parent 4d4e68e commit 5d9cbb4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
23 changes: 23 additions & 0 deletions lib/conntrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions lib/conntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down
10 changes: 9 additions & 1 deletion lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5d9cbb4

Please sign in to comment.