aboutsummaryrefslogtreecommitdiff
path: root/sys/net/route/nhop_ctl.c
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2020-08-28 23:01:56 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2020-08-28 23:01:56 +0000
commit7c89a3b63f4a62e5230b483f0a41562de724a381 (patch)
tree2671335234b85499656aa17ecb4f63ffe0401b52 /sys/net/route/nhop_ctl.c
parenta624ca3dff0c2fa00728d5f50205f341554a0a10 (diff)
Notes
Diffstat (limited to 'sys/net/route/nhop_ctl.c')
-rw-r--r--sys/net/route/nhop_ctl.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/net/route/nhop_ctl.c b/sys/net/route/nhop_ctl.c
index 5d5f2f476e4b3..09365cc982387 100644
--- a/sys/net/route/nhop_ctl.c
+++ b/sys/net/route/nhop_ctl.c
@@ -244,6 +244,21 @@ set_nhop_gw_from_info(struct nhop_object *nh, struct rt_addrinfo *info)
return (0);
}
+static uint16_t
+convert_rt_to_nh_flags(int rt_flags)
+{
+ uint16_t res;
+
+ res = (rt_flags & RTF_REJECT) ? NHF_REJECT : 0;
+ res |= (rt_flags & RTF_HOST) ? NHF_HOST : 0;
+ res |= (rt_flags & RTF_BLACKHOLE) ? NHF_BLACKHOLE : 0;
+ res |= (rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) ? NHF_REDIRECT : 0;
+ res |= (rt_flags & RTF_BROADCAST) ? NHF_BROADCAST : 0;
+ res |= (rt_flags & RTF_GATEWAY) ? NHF_GATEWAY : 0;
+
+ return (res);
+}
+
static int
fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info)
{
@@ -258,7 +273,7 @@ fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info)
nh_priv->nh_family = info->rti_info[RTAX_DST]->sa_family;
nh_priv->nh_type = 0; // hook responsibility to set nhop type
- nh->nh_flags = fib_rte_to_nh_flags(rt_flags);
+ nh->nh_flags = convert_rt_to_nh_flags(rt_flags);
set_nhop_mtu_from_info(nh, info);
nh->nh_ifp = info->rti_ifa->ifa_ifp;
nh->nh_ifa = info->rti_ifa;
@@ -397,7 +412,7 @@ alter_nhop_from_info(struct nhop_object *nh, struct rt_addrinfo *info)
nh->nh_priv->rt_flags |= (RTF_GATEWAY & info->rti_flags);
}
/* Update datapath flags */
- nh->nh_flags = fib_rte_to_nh_flags(nh->nh_priv->rt_flags);
+ nh->nh_flags = convert_rt_to_nh_flags(nh->nh_priv->rt_flags);
if (info->rti_ifa != NULL)
nh->nh_ifa = info->rti_ifa;