Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/route.c
Show First 20 Lines • Show All 452 Lines • ▼ Show 20 Lines | |||||
rib_free_info(struct rt_addrinfo *info) | rib_free_info(struct rt_addrinfo *info) | ||||
{ | { | ||||
ifa_free(info->rti_ifa); | ifa_free(info->rti_ifa); | ||||
if_rele(info->rti_ifp); | if_rele(info->rti_ifp); | ||||
} | } | ||||
/* | /* | ||||
* Iterates over all existing fibs in system calling | |||||
* @setwa_f function prior to traversing each fib. | |||||
* Calls @wa_f function for each element in current fib. | |||||
* If af is not AF_UNSPEC, iterates over fibs in particular | |||||
* address family. | |||||
*/ | |||||
void | |||||
rt_foreach_fib_walk(int af, rt_setwarg_t *setwa_f, rt_walktree_f_t *wa_f, | |||||
void *arg) | |||||
{ | |||||
struct rib_head *rnh; | |||||
uint32_t fibnum; | |||||
int i; | |||||
for (fibnum = 0; fibnum < rt_numfibs; fibnum++) { | |||||
/* Do we want some specific family? */ | |||||
if (af != AF_UNSPEC) { | |||||
rnh = rt_tables_get_rnh(fibnum, af); | |||||
if (rnh == NULL) | |||||
continue; | |||||
if (setwa_f != NULL) | |||||
setwa_f(rnh, fibnum, af, arg); | |||||
RIB_WLOCK(rnh); | |||||
rnh->rnh_walktree(&rnh->head, (walktree_f_t *)wa_f,arg); | |||||
RIB_WUNLOCK(rnh); | |||||
continue; | |||||
} | |||||
for (i = 1; i <= AF_MAX; i++) { | |||||
rnh = rt_tables_get_rnh(fibnum, i); | |||||
if (rnh == NULL) | |||||
continue; | |||||
if (setwa_f != NULL) | |||||
setwa_f(rnh, fibnum, i, arg); | |||||
RIB_WLOCK(rnh); | |||||
rnh->rnh_walktree(&rnh->head, (walktree_f_t *)wa_f,arg); | |||||
RIB_WUNLOCK(rnh); | |||||
} | |||||
} | |||||
} | |||||
/* | |||||
* Iterates over all existing fibs in system and deletes each element | |||||
* for which @filter_f function returns non-zero value. | |||||
* If @family is not AF_UNSPEC, iterates over fibs in particular | |||||
* address family. | |||||
*/ | |||||
void | |||||
rt_foreach_fib_walk_del(int family, rt_filter_f_t *filter_f, void *arg) | |||||
{ | |||||
u_int fibnum; | |||||
int i, start, end; | |||||
for (fibnum = 0; fibnum < rt_numfibs; fibnum++) { | |||||
/* Do we want some specific family? */ | |||||
if (family != AF_UNSPEC) { | |||||
start = family; | |||||
end = family; | |||||
} else { | |||||
start = 1; | |||||
end = AF_MAX; | |||||
} | |||||
for (i = start; i <= end; i++) { | |||||
if (rt_tables_get_rnh(fibnum, i) == NULL) | |||||
continue; | |||||
rib_walk_del(fibnum, i, filter_f, arg, 0); | |||||
} | |||||
} | |||||
} | |||||
/* | |||||
* Delete Routes for a Network Interface | * Delete Routes for a Network Interface | ||||
* | * | ||||
* Called for each routing entry via the rnh->rnh_walktree() call above | * Called for each routing entry via the rnh->rnh_walktree() call above | ||||
* to delete all route entries referencing a detaching network interface. | * to delete all route entries referencing a detaching network interface. | ||||
* | * | ||||
* Arguments: | * Arguments: | ||||
* rt pointer to rtentry | * rt pointer to rtentry | ||||
* nh pointer to nhop | * nh pointer to nhop | ||||
Show All 28 Lines | |||||
* to this interface...oh well... | * to this interface...oh well... | ||||
*/ | */ | ||||
void | void | ||||
rt_flushifroutes_af(struct ifnet *ifp, int af) | rt_flushifroutes_af(struct ifnet *ifp, int af) | ||||
{ | { | ||||
KASSERT((af >= 1 && af <= AF_MAX), ("%s: af %d not >= 1 and <= %d", | KASSERT((af >= 1 && af <= AF_MAX), ("%s: af %d not >= 1 and <= %d", | ||||
__func__, af, AF_MAX)); | __func__, af, AF_MAX)); | ||||
rt_foreach_fib_walk_del(af, rt_ifdelroute, ifp); | rib_foreach_table_walk_del(af, rt_ifdelroute, ifp); | ||||
} | } | ||||
void | void | ||||
rt_flushifroutes(struct ifnet *ifp) | rt_flushifroutes(struct ifnet *ifp) | ||||
{ | { | ||||
rt_foreach_fib_walk_del(AF_UNSPEC, rt_ifdelroute, ifp); | rib_foreach_table_walk_del(AF_UNSPEC, rt_ifdelroute, ifp); | ||||
} | } | ||||
/* | /* | ||||
* Look up rt_addrinfo for a specific fib. Note that if rti_ifa is defined, | * Look up rt_addrinfo for a specific fib. Note that if rti_ifa is defined, | ||||
* it will be referenced so the caller must free it. | * it will be referenced so the caller must free it. | ||||
* | * | ||||
* Assume basic consistency checks are executed by callers: | * Assume basic consistency checks are executed by callers: | ||||
* RTAX_DST exists, if RTF_GATEWAY is set, RTAX_GATEWAY exists as well. | * RTAX_DST exists, if RTF_GATEWAY is set, RTAX_GATEWAY exists as well. | ||||
▲ Show 20 Lines • Show All 347 Lines • Show Last 20 Lines |