Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/route_var.h
Show All 29 Lines | |||||
*/ | */ | ||||
#ifndef _NET_ROUTE_VAR_H_ | #ifndef _NET_ROUTE_VAR_H_ | ||||
#define _NET_ROUTE_VAR_H_ | #define _NET_ROUTE_VAR_H_ | ||||
#ifndef RNF_NORMAL | #ifndef RNF_NORMAL | ||||
#include <net/radix.h> | #include <net/radix.h> | ||||
#endif | #endif | ||||
#include <netinet/in.h> /* struct sockaddr_in */ | |||||
#include <sys/counter.h> | #include <sys/counter.h> | ||||
struct nh_control; | struct nh_control; | ||||
typedef int rnh_preadd_entry_f_t(u_int fibnum, const struct sockaddr *addr, | typedef int rnh_preadd_entry_f_t(u_int fibnum, const struct sockaddr *addr, | ||||
const struct sockaddr *mask, struct nhop_object *nh); | const struct sockaddr *mask, struct nhop_object *nh); | ||||
struct rib_head { | struct rib_head { | ||||
struct radix_head head; | struct radix_head head; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | struct rtentry { | ||||
* XXX struct rtentry must begin with a struct radix_node (or two!) | * XXX struct rtentry must begin with a struct radix_node (or two!) | ||||
* because the code does some casts of a 'struct radix_node *' | * because the code does some casts of a 'struct radix_node *' | ||||
* to a 'struct rtentry *' | * to a 'struct rtentry *' | ||||
*/ | */ | ||||
#define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key))) | #define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key))) | ||||
#define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask))) | #define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask))) | ||||
#define rt_key_const(r) (*((const struct sockaddr * const *)(&(r)->rt_nodes->rn_key))) | #define rt_key_const(r) (*((const struct sockaddr * const *)(&(r)->rt_nodes->rn_key))) | ||||
#define rt_mask_const(r) (*((const struct sockaddr * const *)(&(r)->rt_nodes->rn_mask))) | #define rt_mask_const(r) (*((const struct sockaddr * const *)(&(r)->rt_nodes->rn_mask))) | ||||
/* | |||||
* 2 radix_node structurs above consists of 2x6 pointers, leaving | |||||
* 4 pointers (32 bytes) of the second cache line on amd64. | |||||
* | |||||
*/ | |||||
struct nhop_object *rt_nhop; /* nexthop data */ | struct nhop_object *rt_nhop; /* nexthop data */ | ||||
union { | |||||
/* | |||||
* Destination address storage. | |||||
* sizeof(struct sockaddr_in6) == 28, however | |||||
* the dataplane-relevant part (e.g. address) lies | |||||
* at offset 8..24, making the address not crossing | |||||
* cacheline boundary. | |||||
*/ | |||||
struct sockaddr_in rt_dst4; | |||||
struct sockaddr_in6 rt_dst6; | |||||
struct sockaddr rt_dst; | |||||
char rt_dstb[28]; | |||||
}; | |||||
int rt_flags; /* up/down?, host/net */ | int rt_flags; /* up/down?, host/net */ | ||||
int rt_refcnt; /* # held references */ | int rt_refcnt; /* # held references */ | ||||
u_int rt_fibnum; /* which FIB */ | u_int rt_fibnum; /* which FIB */ | ||||
u_long rt_weight; /* absolute weight */ | u_long rt_weight; /* absolute weight */ | ||||
u_long rt_expire; /* lifetime for route, e.g. redirect */ | u_long rt_expire; /* lifetime for route, e.g. redirect */ | ||||
#define rt_endzero rt_pksent | #define rt_endzero rt_mtx | ||||
counter_u64_t rt_pksent; /* packets sent using this route */ | |||||
struct mtx rt_mtx; /* mutex for routing entry */ | struct mtx rt_mtx; /* mutex for routing entry */ | ||||
struct rtentry *rt_chain; /* pointer to next rtentry to delete */ | struct rtentry *rt_chain; /* pointer to next rtentry to delete */ | ||||
}; | }; | ||||
#define RT_LOCK_INIT(_rt) \ | #define RT_LOCK_INIT(_rt) \ | ||||
mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK | MTX_NEW) | mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK | MTX_NEW) | ||||
#define RT_LOCK(_rt) mtx_lock(&(_rt)->rt_mtx) | #define RT_LOCK(_rt) mtx_lock(&(_rt)->rt_mtx) | ||||
#define RT_UNLOCK(_rt) mtx_unlock(&(_rt)->rt_mtx) | #define RT_UNLOCK(_rt) mtx_unlock(&(_rt)->rt_mtx) | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |