Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route.h
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
/* | /* | ||||
* Struct route consiste of a destination address, | * Struct route consiste of a destination address, | ||||
* a route entry pointer, link-layer prepend data pointer along | * a route entry pointer, link-layer prepend data pointer along | ||||
* with its length. | * with its length. | ||||
*/ | */ | ||||
struct route { | struct route { | ||||
struct rtentry *ro_rt; | struct nhop_object *ro_nh; | ||||
struct llentry *ro_lle; | struct llentry *ro_lle; | ||||
/* | /* | ||||
* ro_prepend and ro_plen are only used for bpf to pass in a | * ro_prepend and ro_plen are only used for bpf to pass in a | ||||
* preformed header. They are not cacheable. | * preformed header. They are not cacheable. | ||||
*/ | */ | ||||
char *ro_prepend; | char *ro_prepend; | ||||
uint16_t ro_plen; | uint16_t ro_plen; | ||||
uint16_t ro_flags; | uint16_t ro_flags; | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
#define NHR_REF 0x02 /* For future use */ | #define NHR_REF 0x02 /* For future use */ | ||||
/* uRPF */ | /* uRPF */ | ||||
#define NHR_NODEFAULT 0x04 /* do not consider default route */ | #define NHR_NODEFAULT 0x04 /* do not consider default route */ | ||||
/* Control plane route request flags */ | /* Control plane route request flags */ | ||||
#define NHR_COPY 0x100 /* Copy rte data */ | #define NHR_COPY 0x100 /* Copy rte data */ | ||||
#ifdef _KERNEL | |||||
/* rte<>ro_flags translation */ | |||||
static inline void | |||||
rt_update_ro_flags(struct route *ro) | |||||
{ | |||||
int rt_flags = ro->ro_rt->rt_flags; | |||||
ro->ro_flags &= ~ (RT_REJECT|RT_BLACKHOLE|RT_HAS_GW); | |||||
ro->ro_flags |= (rt_flags & RTF_REJECT) ? RT_REJECT : 0; | |||||
ro->ro_flags |= (rt_flags & RTF_BLACKHOLE) ? RT_BLACKHOLE : 0; | |||||
ro->ro_flags |= (rt_flags & RTF_GATEWAY) ? RT_HAS_GW : 0; | |||||
} | |||||
#endif | |||||
/* | /* | ||||
* Routing statistics. | * Routing statistics. | ||||
*/ | */ | ||||
struct rtstat { | struct rtstat { | ||||
uint64_t rts_badredirect; /* bogus redirect calls */ | uint64_t rts_badredirect; /* bogus redirect calls */ | ||||
uint64_t rts_dynamic; /* routes created by redirects */ | uint64_t rts_dynamic; /* routes created by redirects */ | ||||
uint64_t rts_newgateway; /* routes modified by redirects */ | uint64_t rts_newgateway; /* routes modified by redirects */ | ||||
uint64_t rts_unreach; /* lookups which failed */ | uint64_t rts_unreach; /* lookups which failed */ | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | #define RTFREE(_rt) do { \ | ||||
RTFREE_LOCKED(_rt); \ | RTFREE_LOCKED(_rt); \ | ||||
} while (0) | } while (0) | ||||
#define RO_RTFREE(_ro) do { \ | #define RO_RTFREE(_ro) do { \ | ||||
if ((_ro)->ro_rt) \ | if ((_ro)->ro_rt) \ | ||||
RTFREE((_ro)->ro_rt); \ | RTFREE((_ro)->ro_rt); \ | ||||
} while (0) | } while (0) | ||||
#define RO_NHFREE(_ro) do { \ | |||||
if ((_ro)->ro_nh) { \ | |||||
NH_FREE((_ro)->ro_nh); \ | |||||
(_ro)->ro_nh = NULL; \ | |||||
} \ | |||||
} while (0) | |||||
#define RO_INVALIDATE_CACHE(ro) do { \ | #define RO_INVALIDATE_CACHE(ro) do { \ | ||||
RO_RTFREE(ro); \ | |||||
if ((ro)->ro_lle != NULL) { \ | if ((ro)->ro_lle != NULL) { \ | ||||
LLE_FREE((ro)->ro_lle); \ | LLE_FREE((ro)->ro_lle); \ | ||||
(ro)->ro_lle = NULL; \ | (ro)->ro_lle = NULL; \ | ||||
} \ | } \ | ||||
if ((ro)->ro_nh != NULL) { \ | |||||
NH_FREE((ro)->ro_nh); \ | |||||
(ro)->ro_nh = NULL; \ | |||||
} \ | |||||
} while (0) | } while (0) | ||||
/* | /* | ||||
* Validate a cached route based on a supplied cookie. If there is an | * Validate a cached route based on a supplied cookie. If there is an | ||||
* out-of-date cache, simply free it. Update the generation number | * out-of-date cache, simply free it. Update the generation number | ||||
* for the new allocation | * for the new allocation | ||||
*/ | */ | ||||
#define RT_VALIDATE(ro, cookiep, fibnum) do { \ | #define NH_VALIDATE(ro, cookiep, fibnum) do { \ | ||||
rt_gen_t cookie = RT_GEN(fibnum, (ro)->ro_dst.sa_family); \ | rt_gen_t cookie = RT_GEN(fibnum, (ro)->ro_dst.sa_family); \ | ||||
if (*(cookiep) != cookie) { \ | if (*(cookiep) != cookie) { \ | ||||
RO_INVALIDATE_CACHE(ro); \ | RO_INVALIDATE_CACHE(ro); \ | ||||
*(cookiep) = cookie; \ | *(cookiep) = cookie; \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
struct ifmultiaddr; | struct ifmultiaddr; | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |