diff options
author | Ethan Jackson <ethan@nicira.com> | 2013-06-18 19:41:51 -0700 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2013-06-27 18:23:40 -0700 |
commit | 5d9895170f5b066d4cb2984fc5a890478a5b8206 (patch) | |
tree | 3d058809464d53a71d8a5bbd16bd326a032799ff /lib/mac-learning.c | |
parent | 03366a2d585a6917d7d94c79073e1e615d8d8025 (diff) | |
download | openvswitch-5d9895170f5b066d4cb2984fc5a890478a5b8206.tar.gz |
mac-learning: Reference count 'struct mac_learning".
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/mac-learning.c')
-rw-r--r-- | lib/mac-learning.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/mac-learning.c b/lib/mac-learning.c index f9b3171cf..ca0ccb8e1 100644 --- a/lib/mac-learning.c +++ b/lib/mac-learning.c @@ -124,14 +124,31 @@ mac_learning_create(unsigned int idle_time) ml->idle_time = normalize_idle_time(idle_time); ml->max_entries = MAC_DEFAULT_MAX; tag_set_init(&ml->tags); + ml->ref_cnt = 1; return ml; } -/* Destroys MAC learning table 'ml'. */ -void -mac_learning_destroy(struct mac_learning *ml) +struct mac_learning * +mac_learning_ref(const struct mac_learning *ml_) { + struct mac_learning *ml = CONST_CAST(struct mac_learning *, ml_); if (ml) { + ovs_assert(ml->ref_cnt > 0); + ml->ref_cnt++; + } + return ml; +} + +/* Unreferences (and possibly destroys) MAC learning table 'ml'. */ +void +mac_learning_unref(struct mac_learning *ml) +{ + if (!ml) { + return; + } + + ovs_assert(ml->ref_cnt > 0); + if (!--ml->ref_cnt) { struct mac_entry *e, *next; HMAP_FOR_EACH_SAFE (e, next, hmap_node, &ml->table) { |