Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route/nhop_ctl.c
Show First 20 Lines • Show All 266 Lines • ▼ Show 20 Lines | convert_rt_to_nh_flags(int rt_flags) | ||||
res |= (rt_flags & RTF_BLACKHOLE) ? NHF_BLACKHOLE : 0; | res |= (rt_flags & RTF_BLACKHOLE) ? NHF_BLACKHOLE : 0; | ||||
res |= (rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) ? NHF_REDIRECT : 0; | res |= (rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) ? NHF_REDIRECT : 0; | ||||
res |= (rt_flags & RTF_BROADCAST) ? NHF_BROADCAST : 0; | res |= (rt_flags & RTF_BROADCAST) ? NHF_BROADCAST : 0; | ||||
res |= (rt_flags & RTF_GATEWAY) ? NHF_GATEWAY : 0; | res |= (rt_flags & RTF_GATEWAY) ? NHF_GATEWAY : 0; | ||||
return (res); | return (res); | ||||
} | } | ||||
static void | |||||
set_nhop_expire_from_info(struct nhop_object *nh, const struct rt_addrinfo *info) | |||||
{ | |||||
uint32_t nh_expire = 0; | |||||
/* Kernel -> userland timebase conversion. */ | |||||
if ((info->rti_mflags & RTV_EXPIRE) && (info->rti_rmx->rmx_expire > 0)) | |||||
nh_expire = info->rti_rmx->rmx_expire - time_second + time_uptime; | |||||
nhop_set_expire(nh, nh_expire); | |||||
} | |||||
static int | static int | ||||
fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info) | fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info) | ||||
{ | { | ||||
int error, rt_flags; | int error, rt_flags; | ||||
struct nhop_object *nh; | struct nhop_object *nh; | ||||
nh = nh_priv->nh; | nh = nh_priv->nh; | ||||
rt_flags = info->rti_flags & NHOP_RT_FLAG_MASK; | rt_flags = info->rti_flags & NHOP_RT_FLAG_MASK; | ||||
nh->nh_priv->rt_flags = rt_flags; | nh->nh_priv->rt_flags = rt_flags; | ||||
nh_priv->nh_upper_family = info->rti_info[RTAX_DST]->sa_family; | nh_priv->nh_upper_family = info->rti_info[RTAX_DST]->sa_family; | ||||
nh_priv->nh_type = 0; // hook responsibility to set nhop type | nh_priv->nh_type = 0; // hook responsibility to set nhop type | ||||
nh->nh_flags = convert_rt_to_nh_flags(rt_flags); | nh->nh_flags = convert_rt_to_nh_flags(rt_flags); | ||||
set_nhop_mtu_from_info(nh, info); | set_nhop_mtu_from_info(nh, info); | ||||
if ((error = set_nhop_gw_from_info(nh, info)) != 0) | if ((error = set_nhop_gw_from_info(nh, info)) != 0) | ||||
return (error); | return (error); | ||||
if (nh->gw_sa.sa_family == AF_LINK) | if (nh->gw_sa.sa_family == AF_LINK) | ||||
nh_priv->nh_neigh_family = nh_priv->nh_upper_family; | nh_priv->nh_neigh_family = nh_priv->nh_upper_family; | ||||
else | else | ||||
nh_priv->nh_neigh_family = nh->gw_sa.sa_family; | nh_priv->nh_neigh_family = nh->gw_sa.sa_family; | ||||
set_nhop_expire_from_info(nh, info); | |||||
nh->nh_ifp = (info->rti_ifp != NULL) ? info->rti_ifp : info->rti_ifa->ifa_ifp; | nh->nh_ifp = (info->rti_ifp != NULL) ? info->rti_ifp : info->rti_ifa->ifa_ifp; | ||||
nh->nh_ifa = info->rti_ifa; | nh->nh_ifa = info->rti_ifa; | ||||
/* depends on the gateway */ | /* depends on the gateway */ | ||||
nh->nh_aifp = get_aifp(nh); | nh->nh_aifp = get_aifp(nh); | ||||
/* | /* | ||||
* Note some of the remaining data is set by the | * Note some of the remaining data is set by the | ||||
▲ Show 20 Lines • Show All 490 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return (nh->nh_priv->nh_neigh_family); | return (nh->nh_priv->nh_neigh_family); | ||||
} | } | ||||
uint32_t | uint32_t | ||||
nhop_get_fibnum(const struct nhop_object *nh) | nhop_get_fibnum(const struct nhop_object *nh) | ||||
{ | { | ||||
return (nh->nh_priv->nh_fibnum); | return (nh->nh_priv->nh_fibnum); | ||||
} | |||||
uint32_t | |||||
nhop_get_expire(const struct nhop_object *nh) | |||||
{ | |||||
return (nh->nh_priv->nh_expire); | |||||
} | |||||
void | |||||
nhop_set_expire(struct nhop_object *nh, uint32_t expire) | |||||
{ | |||||
MPASS(!NH_IS_LINKED(nh)); | |||||
nh->nh_priv->nh_expire = expire; | |||||
} | } | ||||
void | void | ||||
nhops_update_ifmtu(struct rib_head *rh, struct ifnet *ifp, uint32_t mtu) | nhops_update_ifmtu(struct rib_head *rh, struct ifnet *ifp, uint32_t mtu) | ||||
{ | { | ||||
struct nh_control *ctl; | struct nh_control *ctl; | ||||
struct nhop_priv *nh_priv; | struct nhop_priv *nh_priv; | ||||
struct nhop_object *nh; | struct nhop_object *nh; | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |