Skip to content

Commit

Permalink
classifier: Clean up destroy_subtable.
Browse files Browse the repository at this point in the history
Add asserts to make sure the containers within are already empty.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
Jarno Rajahalme committed Nov 6, 2014
1 parent f80028f commit 01c0f83
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/classifier.c
Expand Up @@ -1080,20 +1080,24 @@ insert_subtable(struct classifier *cls, const struct minimask *mask)
return subtable;
}

/* RCU readers may still access the subtable before it is actually freed. */
static void
destroy_subtable(struct classifier *cls, struct cls_subtable *subtable)
OVS_REQUIRES(cls->mutex)
{
int i;

pvector_remove(&cls->subtables, subtable);
trie_destroy(&subtable->ports_trie);
cmap_remove(&cls->subtables_map, &subtable->cmap_node,
minimask_hash(&subtable->mask, 0));

ovs_assert(ovsrcu_get_protected(struct trie_node *, &subtable->ports_trie)
== NULL);
ovs_assert(cmap_is_empty(&subtable->rules));

for (i = 0; i < subtable->n_indices; i++) {
cmap_destroy(&subtable->indices[i]);
}
cmap_remove(&cls->subtables_map, &subtable->cmap_node,
minimask_hash(&subtable->mask, 0));
cmap_destroy(&subtable->rules);
ovsrcu_postpone(free, subtable);
}
Expand Down

0 comments on commit 01c0f83

Please sign in to comment.