git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prepare for post-2.2.0 (2.2.90).
[sliver-openvswitch.git]
/
lib
/
mac-learning.c
diff --git
a/lib/mac-learning.c
b/lib/mac-learning.c
index
f540d6d
..
7dcce41
100644
(file)
--- a/
lib/mac-learning.c
+++ b/
lib/mac-learning.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
, 2014
Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-45,9
+45,7
@@
static uint32_t
mac_table_hash(const struct mac_learning *ml, const uint8_t mac[ETH_ADDR_LEN],
uint16_t vlan)
{
mac_table_hash(const struct mac_learning *ml, const uint8_t mac[ETH_ADDR_LEN],
uint16_t vlan)
{
- unsigned int mac1 = get_unaligned_u32(ALIGNED_CAST(uint32_t *, mac));
- unsigned int mac2 = get_unaligned_u16(ALIGNED_CAST(uint16_t *, mac + 4));
- return hash_3words(mac1, mac2 | (vlan << 16), ml->secret);
+ return hash_mac(mac, vlan, ml->secret);
}
static struct mac_entry *
}
static struct mac_entry *
@@
-111,7
+109,7
@@
mac_learning_create(unsigned int idle_time)
ml->idle_time = normalize_idle_time(idle_time);
ml->max_entries = MAC_DEFAULT_MAX;
ml->need_revalidate = false;
ml->idle_time = normalize_idle_time(idle_time);
ml->max_entries = MAC_DEFAULT_MAX;
ml->need_revalidate = false;
-
atomic_init(&ml->ref_cnt, 1
);
+
ovs_refcount_init(&ml->ref_cnt
);
ovs_rwlock_init(&ml->rwlock);
return ml;
}
ovs_rwlock_init(&ml->rwlock);
return ml;
}
@@
-121,9
+119,7
@@
mac_learning_ref(const struct mac_learning *ml_)
{
struct mac_learning *ml = CONST_CAST(struct mac_learning *, ml_);
if (ml) {
{
struct mac_learning *ml = CONST_CAST(struct mac_learning *, ml_);
if (ml) {
- int orig;
- atomic_add(&ml->ref_cnt, 1, &orig);
- ovs_assert(orig > 0);
+ ovs_refcount_ref(&ml->ref_cnt);
}
return ml;
}
}
return ml;
}
@@
-132,15
+128,7
@@
mac_learning_ref(const struct mac_learning *ml_)
void
mac_learning_unref(struct mac_learning *ml)
{
void
mac_learning_unref(struct mac_learning *ml)
{
- int orig;
-
- if (!ml) {
- return;
- }
-
- atomic_sub(&ml->ref_cnt, 1, &orig);
- ovs_assert(orig > 0);
- if (orig == 1) {
+ if (ml && ovs_refcount_unref(&ml->ref_cnt) == 1) {
struct mac_entry *e, *next;
HMAP_FOR_EACH_SAFE (e, next, hmap_node, &ml->table) {
struct mac_entry *e, *next;
HMAP_FOR_EACH_SAFE (e, next, hmap_node, &ml->table) {
@@
-151,7
+139,6
@@
mac_learning_unref(struct mac_learning *ml)
bitmap_free(ml->flood_vlans);
ovs_rwlock_destroy(&ml->rwlock);
bitmap_free(ml->flood_vlans);
ovs_rwlock_destroy(&ml->rwlock);
- atomic_destroy(&ml->ref_cnt);
free(ml);
}
}
free(ml);
}
}