Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/nhop.h
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | union { | ||||
struct sockaddr_in gw4_sa; /* GW accessor as IPv4 */ | struct sockaddr_in gw4_sa; /* GW accessor as IPv4 */ | ||||
struct sockaddr_in6 gw6_sa; /* GW accessor as IPv6 */ | struct sockaddr_in6 gw6_sa; /* GW accessor as IPv6 */ | ||||
struct sockaddr gw_sa; | struct sockaddr gw_sa; | ||||
struct sockaddr_dl_short gwl_sa; /* AF_LINK gw (compat) */ | struct sockaddr_dl_short gwl_sa; /* AF_LINK gw (compat) */ | ||||
char gw_buf[28]; | char gw_buf[28]; | ||||
}; | }; | ||||
struct ifnet *nh_ifp; /* Logical egress interface. Always != NULL */ | struct ifnet *nh_ifp; /* Logical egress interface. Always != NULL */ | ||||
struct ifaddr *nh_ifa; /* interface address to use. Always != NULL */ | struct ifaddr *nh_ifa; /* interface address to use. Always != NULL */ | ||||
struct ifnet *nh_aifp; /* ifnet of the source address. Always != NULL */ | void *nh_prepend_raw;/* PTR+len for nexthop prepend */ | ||||
counter_u64_t nh_pksent; /* packets sent using this nhop */ | counter_u64_t nh_pksent; /* packets sent using this nhop */ | ||||
/* 32 bytes + 4xPTR == 64(amd64) / 48(i386) */ | /* 32 bytes + 4xPTR == 64(amd64) / 48(i386) */ | ||||
uint8_t nh_prepend_len; /* length of prepend data */ | struct ifnet *nh_aifp; /* ifnet of the source address. Always != NULL */ | ||||
uint8_t spare[3]; | char nh_buffer[48]; /* Space for custom nhop data */ | ||||
uint32_t spare1; /* alignment */ | |||||
char nh_prepend[48]; /* L2 prepend */ | |||||
struct nhop_priv *nh_priv; /* control plane data */ | struct nhop_priv *nh_priv; /* control plane data */ | ||||
/* -- 128 bytes -- */ | /* -- 128 bytes -- */ | ||||
}; | }; | ||||
/* | /* | ||||
* Nhop validness. | * Nhop validness. | ||||
* | * | ||||
* Currently we verify whether link is up or not on every packet, which can be | * Currently we verify whether link is up or not on every packet, which can be | ||||
* quite costy. | * quite costy. | ||||
* TODO: subscribe for the interface notifications and update the nexthops | * TODO: subscribe for the interface notifications and update the nexthops | ||||
* with NHF_INVALID flag. | * with NHF_INVALID flag. | ||||
*/ | */ | ||||
#define NH_IS_VALID(_nh) RT_LINK_IS_UP((_nh)->nh_ifp) | #define NH_IS_VALID(_nh) RT_LINK_IS_UP((_nh)->nh_ifp) | ||||
#define NH_IS_NHGRP(_nh) ((_nh)->nh_flags & NHF_MULTIPATH) | #define NH_IS_NHGRP(_nh) ((_nh)->nh_flags & NHF_MULTIPATH) | ||||
#define NH_FREE(_nh) do { \ | #define NH_FREE(_nh) do { \ | ||||
nhop_free(_nh); \ | nhop_free(_nh); \ | ||||
/* guard against invalid refs */ \ | /* guard against invalid refs */ \ | ||||
_nh = NULL; \ | _nh = NULL; \ | ||||
} while (0) | } while (0) | ||||
/* | |||||
* L2 prepend infrastructure definitions | |||||
* Nexthop L2 rewrites may change during nextop lifetime when the neighbor | |||||
* changes its MAC. For the most common encapsulations - ethernet & IB, | |||||
* the maximum encap length is 24 (IPoIB) = LLE_MAX_LINKHDR. | |||||
* Leverage the fact that this value is < cache line size by embedding | |||||
* prepend length to the pointer data itself & requiring UMA to return | |||||
* CACHE_LINE_SIZE-aligned pointers. | |||||
*/ | |||||
#define L2_PREPEND_LEN_BITS CACHE_LINE_SHIFT | |||||
#define L2_PREPEND_LEN_MAX ((1 << L2_PREPEND_LEN_BITS) - sizeof(struct epoch_context)) | |||||
#define _NH_L2_PREPEND_MASK_PTR(_p) ((uintptr_t)(_p) & ~((1 << L2_PREPEND_LEN_BITS) - 1)) | |||||
#define NH_L2_PREPEND_GET_PTR(_p) ((void *)_NH_L2_PREPEND_MASK_PTR(_p)) | |||||
#define NH_L2_PREPEND_GET_LEN(_p) ((uintptr_t)(_p) & ((1 << L2_PREPEND_LEN_BITS) - 1)) | |||||
#define NH_L2_COMPILE_PREPEND_PTR(_p, _l) ((void *)((uintptr_t)(_p) | (_l))) | |||||
static inline void | |||||
route_set_prepend_nh(struct route *ro, const struct nhop_object *nh) | |||||
{ | |||||
void *ptr = nh->nh_prepend_raw; | |||||
ro->ro_prepend = (char *)NH_L2_PREPEND_GET_PTR(ptr); | |||||
ro->ro_plen = NH_L2_PREPEND_GET_LEN(ptr); | |||||
} | |||||
struct weightened_nhop { | struct weightened_nhop { | ||||
struct nhop_object *nh; | struct nhop_object *nh; | ||||
uint32_t weight; | uint32_t weight; | ||||
}; | }; | ||||
void nhop_free(struct nhop_object *nh); | void nhop_free(struct nhop_object *nh); | ||||
struct sysctl_req; | struct sysctl_req; | ||||
struct sockaddr_dl; | struct sockaddr_dl; | ||||
struct rib_head; | struct rib_head; | ||||
uint32_t nhop_get_idx(const struct nhop_object *nh); | uint32_t nhop_get_idx(const struct nhop_object *nh); | ||||
enum nhop_type nhop_get_type(const struct nhop_object *nh); | enum nhop_type nhop_get_type(const struct nhop_object *nh); | ||||
int nhop_get_rtflags(const struct nhop_object *nh); | int nhop_get_rtflags(const struct nhop_object *nh); | ||||
struct vnet *nhop_get_vnet(const struct nhop_object *nh); | struct vnet *nhop_get_vnet(const struct nhop_object *nh); | ||||
struct nhop_object *nhop_select_func(struct nhop_object *nh, uint32_t flowid); | struct nhop_object *nhop_select_func(struct nhop_object *nh, uint32_t flowid); | ||||
int nhop_get_upper_family(const struct nhop_object *nh); | int nhop_get_upper_family(const struct nhop_object *nh); | ||||
int nhop_get_neigh_family(const struct nhop_object *nh); | int nhop_get_neigh_family(const struct nhop_object *nh); | ||||
uint32_t nhop_get_fibnum(const struct nhop_object *nh); | uint32_t nhop_get_fibnum(const struct nhop_object *nh); | ||||
void *nhop_alloc_prepend(size_t size); | |||||
void nhop_free_prepend(void *prepend); | |||||
bool nhop_update_prepend(struct nhop_object *nh, void *prepend, size_t len); | |||||
void nhops_update_neigh(struct ifnet *ifp, int family, const struct llentry *lle); | |||||
void nhops_request_feedback(struct ifnet *ifp, int family, const struct llentry *lle); | |||||
void nhops_stop_feedback(struct ifnet *ifp, int family, const struct llentry *lle); | |||||
time_t nhops_get_hittime(struct ifnet *ifp, int family, const struct llentry *lle); | |||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
/* Kernel <> userland structures */ | /* Kernel <> userland structures */ | ||||
/* Structure usage and layout are described in dump_nhop_entry() */ | /* Structure usage and layout are described in dump_nhop_entry() */ | ||||
struct nhop_external { | struct nhop_external { | ||||
uint32_t nh_len; /* length of the datastructure */ | uint32_t nh_len; /* length of the datastructure */ | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |