Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167154447
D58803.id184018.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D58803.id184018.diff
View Options
diff --git a/sys/net/route/fib_algo.h b/sys/net/route/fib_algo.h
--- a/sys/net/route/fib_algo.h
+++ b/sys/net/route/fib_algo.h
@@ -84,7 +84,7 @@
struct fib_lookup_module {
char *flm_name; /* algo name */
int flm_family; /* address family this module supports */
- int flm_refcount; /* # of references */
+ u_int flm_refcount; /* # of references */
uint32_t flm_flags; /* flags */
uint8_t flm_index; /* internal algo index */
flm_init_t *flm_init_cb; /* instance init */
diff --git a/sys/net/route/fib_algo.c b/sys/net/route/fib_algo.c
--- a/sys/net/route/fib_algo.c
+++ b/sys/net/route/fib_algo.c
@@ -36,6 +36,7 @@
#include <sys/sbuf.h>
#include <sys/lock.h>
#include <sys/rmlock.h>
+#include <sys/refcount.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/module.h>
@@ -1176,7 +1177,7 @@
fd->fd_flm = flm;
FIB_MOD_LOCK();
- flm->flm_refcount++;
+ refcount_acquire(&flm->flm_refcount);
fd->fd_gen = ++fib_gen;
FIB_MOD_UNLOCK();
@@ -1431,7 +1432,7 @@
TAILQ_FOREACH(flm, &all_algo_list, entries) {
if ((strcmp(flm->flm_name, algo_name) == 0) &&
(family == flm->flm_family)) {
- flm->flm_refcount++;
+ refcount_acquire(&flm->flm_refcount);
FIB_MOD_UNLOCK();
return (flm);
}
@@ -1445,9 +1446,7 @@
fib_unref_algo(struct fib_lookup_module *flm)
{
- FIB_MOD_LOCK();
- flm->flm_refcount--;
- FIB_MOD_UNLOCK();
+ refcount_release(&flm->flm_refcount);
}
static int
@@ -1922,11 +1921,12 @@
if (flm == orig_flm)
curr_preference = preference;
}
+ FIB_MOD_UNLOCK();
+
if ((best_flm != NULL) && (curr_preference + BEST_DIFF_PERCENT < best_preference))
- best_flm->flm_refcount++;
+ refcount_acquire(&best_flm->flm_refcount);
else
best_flm = NULL;
- FIB_MOD_UNLOCK();
RH_PRINTF(LOG_DEBUG, rh, "candidate_algos: %d, curr: %s(%d) result: %s(%d)",
candidate_algos, orig_flm ? orig_flm->flm_name : "NULL", curr_preference,
@@ -2026,6 +2026,7 @@
FIB_MOD_LOCK();
ALGO_PRINTF(LOG_INFO, "attaching %s to %s", flm->flm_name,
print_family(flm->flm_family));
+ refcount_init(&flm->flm_refcount, 0);
TAILQ_INSERT_TAIL(&all_algo_list, flm, entries);
FIB_MOD_UNLOCK();
@@ -2043,7 +2044,7 @@
{
FIB_MOD_LOCK();
- if (flm->flm_refcount > 0) {
+ if (refcount_load(&flm->flm_refcount) > 0) {
FIB_MOD_UNLOCK();
return (EBUSY);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Aug 20, 1:14 PM (5 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36755368
Default Alt Text
D58803.id184018.diff (2 KB)
Attached To
Mode
D58803: route/fib_algo: Use refcount(9) for fib_lookup_module
Attached
Detach File
Event Timeline
Log In to Comment