Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/nhop_var.h
| Show All 31 Lines | |||||
| * | * | ||||
| * Header is not intended to be included by the code external to the | * Header is not intended to be included by the code external to the | ||||
| * routing subsystem. | * routing subsystem. | ||||
| */ | */ | ||||
| #ifndef _NET_ROUTE_NHOP_VAR_H_ | #ifndef _NET_ROUTE_NHOP_VAR_H_ | ||||
| #define _NET_ROUTE_NHOP_VAR_H_ | #define _NET_ROUTE_NHOP_VAR_H_ | ||||
| MALLOC_DECLARE(M_NHOP); | |||||
| /* define nhop hash table */ | /* define nhop hash table */ | ||||
| struct nhop_priv; | struct nhop_priv; | ||||
| CHT_SLIST_DEFINE(nhops, struct nhop_priv); | CHT_SLIST_DEFINE(nhops, struct nhop_priv); | ||||
| /* produce hash value for an object */ | /* produce hash value for an object */ | ||||
| #define nhops_hash_obj(_obj) hash_priv(_obj) | #define nhops_hash_obj(_obj) hash_priv(_obj) | ||||
| /* compare two objects */ | /* compare two objects */ | ||||
| #define nhops_cmp(_one, _two) cmp_priv(_one, _two) | #define nhops_cmp(_one, _two) cmp_priv(_one, _two) | ||||
| /* next object accessor */ | /* next object accessor */ | ||||
| #define nhops_next(_obj) (_obj)->nh_next | #define nhops_next(_obj) (_obj)->nh_next | ||||
| /* define multipath hash table */ | |||||
| struct nhgrp_priv; | |||||
| CHT_SLIST_DEFINE(nhgroups, struct nhgrp_priv); | |||||
| struct nh_control { | struct nh_control { | ||||
| struct nhops_head nh_head; /* hash table head */ | struct nhops_head nh_head; /* hash table head */ | ||||
| struct bitmask_head nh_idx_head; /* nhop index head */ | struct bitmask_head nh_idx_head; /* nhop index head */ | ||||
| struct nhgroups_head gr_head; /* nhgrp hash table head */ | |||||
| struct bitmask_head gr_idx_head; /* nhgrp index head */ | |||||
| struct rwlock ctl_lock; /* overall ctl lock */ | struct rwlock ctl_lock; /* overall ctl lock */ | ||||
| struct rib_head *ctl_rh; /* pointer back to rnh */ | struct rib_head *ctl_rh; /* pointer back to rnh */ | ||||
| struct epoch_context ctl_epoch_ctx; /* epoch ctl helper */ | struct epoch_context ctl_epoch_ctx; /* epoch ctl helper */ | ||||
| }; | }; | ||||
| #define NHOPS_WLOCK(ctl) rw_wlock(&(ctl)->ctl_lock) | #define NHOPS_WLOCK(ctl) rw_wlock(&(ctl)->ctl_lock) | ||||
| #define NHOPS_RLOCK(ctl) rw_rlock(&(ctl)->ctl_lock) | #define NHOPS_RLOCK(ctl) rw_rlock(&(ctl)->ctl_lock) | ||||
| #define NHOPS_WUNLOCK(ctl) rw_wunlock(&(ctl)->ctl_lock) | #define NHOPS_WUNLOCK(ctl) rw_wunlock(&(ctl)->ctl_lock) | ||||
| Show All 14 Lines | struct nhop_priv { | ||||
| int rt_flags; /* routing flags for the control plane */ | int rt_flags; /* routing flags for the control plane */ | ||||
| struct nhop_object *nh; /* backreference to the dataplane nhop */ | struct nhop_object *nh; /* backreference to the dataplane nhop */ | ||||
| struct nh_control *nh_control; /* backreference to the rnh */ | struct nh_control *nh_control; /* backreference to the rnh */ | ||||
| struct nhop_priv *nh_next; /* hash table membership */ | struct nhop_priv *nh_next; /* hash table membership */ | ||||
| struct vnet *nh_vnet; /* vnet nhop belongs to */ | struct vnet *nh_vnet; /* vnet nhop belongs to */ | ||||
| struct epoch_context nh_epoch_ctx; /* epoch data for nhop */ | struct epoch_context nh_epoch_ctx; /* epoch data for nhop */ | ||||
| }; | }; | ||||
| #define NH_IS_PINNED(_nh) ((_nh)->nh_priv->rt_flags & RTF_PINNED) | #define NH_IS_PINNED(_nh) ((!NH_IS_NHGRP(_nh)) && \ | ||||
| ((_nh)->nh_priv->rt_flags & RTF_PINNED)) | |||||
| /* nhop.c */ | /* nhop.c */ | ||||
| struct nhop_priv *find_nhop(struct nh_control *ctl, | struct nhop_priv *find_nhop(struct nh_control *ctl, | ||||
| const struct nhop_priv *nh_priv); | const struct nhop_priv *nh_priv); | ||||
| int link_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv); | int link_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv); | ||||
| struct nhop_priv *unlink_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv); | struct nhop_priv *unlink_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv); | ||||
| /* nhop_ctl.c */ | /* nhop_ctl.c */ | ||||
| int cmp_priv(const struct nhop_priv *_one, const struct nhop_priv *_two); | int cmp_priv(const struct nhop_priv *_one, const struct nhop_priv *_two); | ||||
| #endif | #endif | ||||