Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/route_helpers.c
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | |||||
rib_walk(uint32_t fibnum, int family, bool wlock, rib_walktree_f_t *wa_f, | rib_walk(uint32_t fibnum, int family, bool wlock, rib_walktree_f_t *wa_f, | ||||
void *arg) | void *arg) | ||||
{ | { | ||||
rib_walk_ext(fibnum, family, wlock, wa_f, NULL, arg); | rib_walk_ext(fibnum, family, wlock, wa_f, NULL, arg); | ||||
} | } | ||||
/* | /* | ||||
* Calls @wa_f with @arg for each entry in the table with @prefix/@mask. | |||||
* | |||||
* The following flags are supported: | |||||
* RIB_FLAG_WLOCK: acquire exclusive lock | |||||
* RIB_FLAG_UNLOCKED: no locking. Assumes the table is already locked. | |||||
donner: That's a bad name for a read-lock. | |||||
melifaroAuthorUnsubmitted Done Inline ActionsIt doesn’t assume read lock. It requests function not to acquire lock at all, assuming that the lock is already taken. melifaro: It doesn’t assume read lock. It requests function not to acquire lock at all, assuming that the… | |||||
* | |||||
* By default, table is traversed under read lock. | |||||
*/ | |||||
void | |||||
rib_walk_from(uint32_t fibnum, int family, uint32_t flags, struct sockaddr *prefix, | |||||
struct sockaddr *mask, rib_walktree_f_t *wa_f, void *arg) | |||||
{ | |||||
RIB_RLOCK_TRACKER; | |||||
struct rib_head *rnh = rt_tables_get_rnh(fibnum, family); | |||||
if (rnh == NULL) | |||||
return; | |||||
if (flags & RIB_FLAG_WLOCK) | |||||
RIB_WLOCK(rnh); | |||||
else if (!(flags & RIB_FLAG_UNLOCKED)) | |||||
RIB_RLOCK(rnh); | |||||
rnh->rnh_walktree_from(&rnh->head, prefix, mask, (walktree_f_t *)wa_f, arg); | |||||
if (flags & RIB_FLAG_WLOCK) | |||||
RIB_WUNLOCK(rnh); | |||||
else if (!(flags & RIB_FLAG_UNLOCKED)) | |||||
RIB_RUNLOCK(rnh); | |||||
} | |||||
/* | |||||
* Iterates over all existing fibs in system calling | * Iterates over all existing fibs in system calling | ||||
* @hook_f function before/after traversing each fib. | * @hook_f function before/after traversing each fib. | ||||
* Calls @wa_f function for each element in current fib. | * Calls @wa_f function for each element in current fib. | ||||
* If af is not AF_UNSPEC, iterates over fibs in particular | * If af is not AF_UNSPEC, iterates over fibs in particular | ||||
* address family. | * address family. | ||||
*/ | */ | ||||
void | void | ||||
rib_foreach_table_walk(int family, bool wlock, rib_walktree_f_t *wa_f, | rib_foreach_table_walk(int family, bool wlock, rib_walktree_f_t *wa_f, | ||||
▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines |
That's a bad name for a read-lock.