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
classifier: Use array for subtables instead of a list.
[sliver-openvswitch.git]
/
ofproto
/
ofproto-dpif-mirror.c
diff --git
a/ofproto/ofproto-dpif-mirror.c
b/ofproto/ofproto-dpif-mirror.c
index
9734718
..
fcc7758
100644
(file)
--- a/
ofproto/ofproto-dpif-mirror.c
+++ b/
ofproto/ofproto-dpif-mirror.c
@@
-36,7
+36,7
@@
struct mbridge {
bool need_revalidate;
bool has_mirrors;
bool need_revalidate;
bool has_mirrors;
-
i
nt ref_cnt;
+
struct ovs_refcou
nt ref_cnt;
};
struct mbundle {
};
struct mbundle {
@@
-75,7
+75,6
@@
static void mbundle_lookup_multiple(const struct mbridge *, struct ofbundle **,
size_t n_bundles, struct hmapx *mbundles);
static int mirror_scan(struct mbridge *);
static void mirror_update_dups(struct mbridge *);
size_t n_bundles, struct hmapx *mbundles);
static int mirror_scan(struct mbridge *);
static void mirror_update_dups(struct mbridge *);
-static int mirror_mask_ffs(mirror_mask_t);
struct mbridge *
mbridge_create(void)
struct mbridge *
mbridge_create(void)
@@
-83,7
+82,7
@@
mbridge_create(void)
struct mbridge *mbridge;
mbridge = xzalloc(sizeof *mbridge);
struct mbridge *mbridge;
mbridge = xzalloc(sizeof *mbridge);
-
mbridge->ref_cnt = 1
;
+
ovs_refcount_init(&mbridge->ref_cnt)
;
hmap_init(&mbridge->mbundles);
return mbridge;
hmap_init(&mbridge->mbundles);
return mbridge;
@@
-94,8
+93,7
@@
mbridge_ref(const struct mbridge *mbridge_)
{
struct mbridge *mbridge = CONST_CAST(struct mbridge *, mbridge_);
if (mbridge) {
{
struct mbridge *mbridge = CONST_CAST(struct mbridge *, mbridge_);
if (mbridge) {
- ovs_assert(mbridge->ref_cnt > 0);
- mbridge->ref_cnt++;
+ ovs_refcount_ref(&mbridge->ref_cnt);
}
return mbridge;
}
}
return mbridge;
}
@@
-110,22
+108,20
@@
mbridge_unref(struct mbridge *mbridge)
return;
}
return;
}
- ovs_assert(mbridge->ref_cnt > 0);
- if (--mbridge->ref_cnt) {
- return;
- }
+ if (ovs_refcount_unref(&mbridge->ref_cnt) == 1) {
+ for (i = 0; i < MAX_MIRRORS; i++) {
+ if (mbridge->mirrors[i]) {
+ mirror_destroy(mbridge, mbridge->mirrors[i]->aux);
+ }
+ }
- for (i = 0; i < MAX_MIRRORS; i++) {
- if (mbridge->mirrors[i]) {
- mirror_destroy(mbridge, mbridge->mirrors[i]->aux);
+ HMAP_FOR_EACH_SAFE (mbundle, next, hmap_node, &mbridge->mbundles) {
+ mbridge_unregister_bundle(mbridge, mbundle->ofbundle);
}
}
- }
- HMAP_FOR_EACH_SAFE (mbundle, next, hmap_node, &mbridge->mbundles) {
-
mbridge_unregister_bundle(mbridge, mbundle->ofbundl
e);
+ hmap_destroy(&mbridge->mbundles);
+
free(mbridg
e);
}
}
-
- free(mbridge);
}
bool
}
bool
@@
-362,7
+358,7
@@
mirror_update_stats(struct mbridge *mbridge, mirror_mask_t mirrors,
for (; mirrors; mirrors = zero_rightmost_1bit(mirrors)) {
struct mirror *m;
for (; mirrors; mirrors = zero_rightmost_1bit(mirrors)) {
struct mirror *m;
- m = mbridge->mirrors[
mirror_mask_ffs(mirrors) - 1
];
+ m = mbridge->mirrors[
raw_ctz(mirrors)
];
if (!m) {
/* In normal circumstances 'm' will not be NULL. However,
if (!m) {
/* In normal circumstances 'm' will not be NULL. However,