Page MenuHomeFreeBSD

D58803.id183926.diff
No OneTemporary

D58803.id183926.diff

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);
}
@@ -1446,7 +1447,7 @@
{
FIB_MOD_LOCK();
- flm->flm_refcount--;
+ refcount_release(&flm->flm_refcount);
FIB_MOD_UNLOCK();
}
@@ -1923,7 +1924,7 @@
curr_preference = preference;
}
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();
@@ -2026,6 +2027,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 +2045,7 @@
{
FIB_MOD_LOCK();
- if (flm->flm_refcount > 0) {
+ if (refcount_load(&flm->flm_refcount) > 0) {
FIB_MOD_UNLOCK();
return (EBUSY);
}

File Metadata

Mime Type
text/plain
Expires
Thu, Aug 20, 5:16 AM (1 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36674146
Default Alt Text
D58803.id183926.diff (2 KB)

Event Timeline