Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/nhop.h
| Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | |||||
| * | * | ||||
| * 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_MULTIPATH(_nh) ((_nh)->nh_flags & NHF_MULTIPATH) | #define NH_IS_NHGRP(_nh) ((_nh)->nh_flags & NHF_MULTIPATH) | ||||
| #define RT_GATEWAY(_rt) ((struct sockaddr *)&(_rt)->rt_nhop->gw4_sa) | #define RT_GATEWAY(_rt) ((struct sockaddr *)&(_rt)->rt_nhop->gw4_sa) | ||||
| #define RT_GATEWAY_CONST(_rt) ((const struct sockaddr *)&(_rt)->rt_nhop->gw4_sa) | #define RT_GATEWAY_CONST(_rt) ((const struct sockaddr *)&(_rt)->rt_nhop->gw4_sa) | ||||
| #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) | ||||
| struct weightened_nhop { | |||||
| struct nhop_object *nh; | |||||
| 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); | ||||
| Show All 27 Lines | |||||
| }; | }; | ||||
| struct nhop_addrs { | struct nhop_addrs { | ||||
| uint32_t na_len; /* length of the datastructure */ | uint32_t na_len; /* length of the datastructure */ | ||||
| uint16_t gw_sa_off; /* offset of gateway SA */ | uint16_t gw_sa_off; /* offset of gateway SA */ | ||||
| uint16_t src_sa_off; /* offset of src address SA */ | uint16_t src_sa_off; /* offset of src address SA */ | ||||
| }; | }; | ||||
| struct mpath_nhop_external { | #define NHG_C_TYPE_CNHOPS 0x1 /* Control plane nhops list */ | ||||
| #define NHG_C_TYPE_DNHOPS 0x2 /* Dataplane nhops list */ | |||||
| struct nhgrp_container { | |||||
| uint32_t nhgc_len; /* container length */ | |||||
| uint16_t nhgc_count; /* number of items */ | |||||
| uint8_t nhgc_type; /* container type */ | |||||
| uint8_t nhgc_subtype; /* container subtype */ | |||||
| }; | |||||
| struct nhgrp_nhop_external { | |||||
| uint32_t nh_idx; | uint32_t nh_idx; | ||||
| uint32_t nh_weight; | uint32_t nh_weight; | ||||
| }; | }; | ||||
| struct mpath_external { | /* | ||||
| uint32_t mp_idx; | * Layout: | ||||
| uint32_t mp_refcount; | * - nhgrp_external | ||||
| uint32_t mp_nh_count; | * - nhgrp_container (control plane nhops list) | ||||
| uint32_t mp_group_size; | * - nhgrp_nhop_external | ||||
| * - nhgrp_nhop_external | |||||
| * .. | |||||
| * - nhgrp_container (dataplane nhops list) | |||||
| * - nhgrp_nhop_external | |||||
| * - nhgrp_nhop_external | |||||
| */ | |||||
| struct nhgrp_external { | |||||
| uint32_t nhg_idx; /* Nexthop group index */ | |||||
| uint32_t nhg_refcount; /* number of references */ | |||||
| }; | }; | ||||
| #endif | #endif | ||||