Convert more rtentry field accesses into nhop fields accesses.
Continue routing subsystem conversion to nhop objects defined in r359823. Use fields from nhop structure instead of "struct rtentry" fields. This is one of the last changes prior to removing rt_ifp, rt_ifa, rt_gateway and rt_mtu from struct rtentry. Differential Revision: https://reviews.freebsd.org/D24609
This commit is contained in:
parent
f8d5656acd
commit
57588206fe
@ -183,6 +183,7 @@ rt_mpath_conflict(struct rib_head *rnh, struct rtentry *rt,
|
||||
struct sockaddr *netmask)
|
||||
{
|
||||
struct radix_node *rn, *rn1;
|
||||
struct nhop_object *nh, *nh1;
|
||||
struct rtentry *rt1;
|
||||
|
||||
rn = (struct radix_node *)rt;
|
||||
@ -198,15 +199,17 @@ rt_mpath_conflict(struct rib_head *rnh, struct rtentry *rt,
|
||||
if (rn1 == rn)
|
||||
continue;
|
||||
|
||||
if (rt1->rt_gateway->sa_family == AF_LINK) {
|
||||
if (rt1->rt_ifa->ifa_addr->sa_len != rt->rt_ifa->ifa_addr->sa_len ||
|
||||
bcmp(rt1->rt_ifa->ifa_addr, rt->rt_ifa->ifa_addr,
|
||||
rt1->rt_ifa->ifa_addr->sa_len))
|
||||
nh = rt->rt_nhop;
|
||||
nh1 = rt1->rt_nhop;
|
||||
|
||||
if (nh1->gw_sa.sa_family == AF_LINK) {
|
||||
if (nh1->nh_ifa->ifa_addr->sa_len != nh->nh_ifa->ifa_addr->sa_len ||
|
||||
bcmp(nh1->nh_ifa->ifa_addr, nh->nh_ifa->ifa_addr,
|
||||
nh1->nh_ifa->ifa_addr->sa_len))
|
||||
continue;
|
||||
} else {
|
||||
if (rt1->rt_gateway->sa_len != rt->rt_gateway->sa_len ||
|
||||
bcmp(rt1->rt_gateway, rt->rt_gateway,
|
||||
rt1->rt_gateway->sa_len))
|
||||
if (nh1->gw_sa.sa_len != nh->gw_sa.sa_len ||
|
||||
bcmp(&nh1->gw_sa, &nh->gw_sa, nh1->gw_sa.sa_len))
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -745,8 +745,8 @@ ifa_ifwithroute(int flags, const struct sockaddr *dst, struct sockaddr *gateway,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!not_found && rt->rt_ifa != NULL) {
|
||||
ifa = rt->rt_ifa;
|
||||
if (!not_found && rt->rt_nhop->nh_ifa != NULL) {
|
||||
ifa = rt->rt_nhop->nh_ifa;
|
||||
}
|
||||
RT_REMREF(rt);
|
||||
RT_UNLOCK(rt);
|
||||
@ -909,7 +909,7 @@ rib_lookup_info(uint32_t fibnum, const struct sockaddr *dst, uint32_t flags,
|
||||
if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
|
||||
rt = RNTORT(rn);
|
||||
/* Ensure route & ifp is UP */
|
||||
if (RT_LINK_IS_UP(rt->rt_ifp)) {
|
||||
if (RT_LINK_IS_UP(rt->rt_nhop->nh_ifp)) {
|
||||
flags = (flags & NHR_REF) | NHR_COPY;
|
||||
error = rt_exportinfo(rt, info, flags);
|
||||
RIB_RUNLOCK(rh);
|
||||
@ -1064,7 +1064,8 @@ rib_walk_del(u_int fibnum, int family, rt_filter_f_t *filter_f, void *arg, bool
|
||||
rt_notifydelete(rt, &di.info);
|
||||
|
||||
if (report)
|
||||
rt_routemsg(RTM_DELETE, rt, rt->rt_ifp, 0, fibnum);
|
||||
rt_routemsg(RTM_DELETE, rt, rt->rt_nhop->nh_ifp, 0,
|
||||
fibnum);
|
||||
RTFREE_LOCKED(rt);
|
||||
}
|
||||
}
|
||||
@ -1237,7 +1238,7 @@ rt_notifydelete(struct rtentry *rt, struct rt_addrinfo *info)
|
||||
/*
|
||||
* give the protocol a chance to keep things in sync.
|
||||
*/
|
||||
ifa = rt->rt_ifa;
|
||||
ifa = rt->rt_nhop->nh_ifa;
|
||||
if (ifa != NULL && ifa->ifa_rtrequest != NULL)
|
||||
ifa->ifa_rtrequest(RTM_DELETE, rt, rt->rt_nhop, info);
|
||||
|
||||
@ -1863,7 +1864,7 @@ change_route(struct rib_head *rnh, struct rt_addrinfo *info,
|
||||
info->rti_info[RTAX_GATEWAY] != NULL) ||
|
||||
info->rti_info[RTAX_IFP] != NULL ||
|
||||
(info->rti_info[RTAX_IFA] != NULL &&
|
||||
!sa_equal(info->rti_info[RTAX_IFA], rt->rt_ifa->ifa_addr))) {
|
||||
!sa_equal(info->rti_info[RTAX_IFA], rt->rt_nhop->nh_ifa->ifa_addr))) {
|
||||
/*
|
||||
* XXX: Temporarily set RTF_RNH_LOCKED flag in the rti_flags
|
||||
* to avoid rlock in the ifa_ifwithroute().
|
||||
@ -2162,7 +2163,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
|
||||
#endif
|
||||
error = (rn == NULL ||
|
||||
(rn->rn_flags & RNF_ROOT) ||
|
||||
RNTORT(rn)->rt_ifa != ifa);
|
||||
RNTORT(rn)->rt_nhop->nh_ifa != ifa);
|
||||
RIB_RUNLOCK(rnh);
|
||||
if (error) {
|
||||
/* this is only an error if bad on ALL tables */
|
||||
|
@ -131,18 +131,20 @@ rt_dumpentry_ddb(struct radix_node *rn, void *arg __unused)
|
||||
{
|
||||
struct sockaddr_storage ss;
|
||||
struct rtentry *rt;
|
||||
struct nhop_object *nh;
|
||||
int flags, idx;
|
||||
|
||||
/* If RNTORT is important, put it in a header. */
|
||||
rt = (void *)rn;
|
||||
nh = (struct nhop_object *)rt->rt_nhop;
|
||||
|
||||
rt_dumpaddr_ddb("dst", rt_key(rt));
|
||||
rt_dumpaddr_ddb("gateway", &rt->rt_nhop->gw_sa);
|
||||
rt_dumpaddr_ddb("netmask", rtsock_fix_netmask(rt_key(rt), rt_mask(rt),
|
||||
&ss));
|
||||
if (rt->rt_ifp != NULL && (rt->rt_ifp->if_flags & IFF_DYING) == 0) {
|
||||
rt_dumpaddr_ddb("ifp", rt->rt_ifp->if_addr->ifa_addr);
|
||||
rt_dumpaddr_ddb("ifa", rt->rt_ifa->ifa_addr);
|
||||
if ((nh->nh_ifp->if_flags & IFF_DYING) == 0) {
|
||||
rt_dumpaddr_ddb("ifp", nh->nh_ifp->if_addr->ifa_addr);
|
||||
rt_dumpaddr_ddb("ifa", nh->nh_ifa->ifa_addr);
|
||||
}
|
||||
|
||||
db_printf("flags ");
|
||||
|
@ -929,7 +929,7 @@ route_output(struct mbuf *m, struct socket *so, ...)
|
||||
rti_need_deembed = (V_deembed_scopeid) ? 1 : 0;
|
||||
#endif
|
||||
RT_LOCK(saved_nrt);
|
||||
rtm->rtm_index = saved_nrt->rt_ifp->if_index;
|
||||
rtm->rtm_index = saved_nrt->rt_nhop->nh_ifp->if_index;
|
||||
RT_REMREF(saved_nrt);
|
||||
RT_UNLOCK(saved_nrt);
|
||||
}
|
||||
@ -1714,6 +1714,7 @@ sysctl_dumpentry(struct radix_node *rn, void *vw)
|
||||
{
|
||||
struct walkarg *w = vw;
|
||||
struct rtentry *rt = (struct rtentry *)rn;
|
||||
struct nhop_object *nh;
|
||||
int error = 0, size;
|
||||
struct rt_addrinfo info;
|
||||
struct sockaddr_storage ss;
|
||||
@ -1730,11 +1731,12 @@ sysctl_dumpentry(struct radix_node *rn, void *vw)
|
||||
info.rti_info[RTAX_NETMASK] = rtsock_fix_netmask(rt_key(rt),
|
||||
rt_mask(rt), &ss);
|
||||
info.rti_info[RTAX_GENMASK] = 0;
|
||||
if (rt->rt_ifp && !(rt->rt_ifp->if_flags & IFF_DYING)) {
|
||||
info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr;
|
||||
info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
|
||||
if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
|
||||
info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr;
|
||||
nh = rt->rt_nhop;
|
||||
if (nh->nh_ifp && !(nh->nh_ifp->if_flags & IFF_DYING)) {
|
||||
info.rti_info[RTAX_IFP] = nh->nh_ifp->if_addr->ifa_addr;
|
||||
info.rti_info[RTAX_IFA] = nh->nh_ifa->ifa_addr;
|
||||
if (nh->nh_ifp->if_flags & IFF_POINTOPOINT)
|
||||
info.rti_info[RTAX_BRD] = nh->nh_ifa->ifa_dstaddr;
|
||||
}
|
||||
if ((error = rtsock_msg_buffer(RTM_GET, &info, w, &size)) != 0)
|
||||
return (error);
|
||||
@ -1748,8 +1750,9 @@ sysctl_dumpentry(struct radix_node *rn, void *vw)
|
||||
(rt->rt_flags & ~RTF_GWFLAG_COMPAT);
|
||||
else
|
||||
rtm->rtm_flags = rt->rt_flags;
|
||||
rtm->rtm_flags |= nhop_get_rtflags(nh);
|
||||
rt_getmetrics(rt, &rtm->rtm_rmx);
|
||||
rtm->rtm_index = rt->rt_ifp->if_index;
|
||||
rtm->rtm_index = nh->nh_ifp->if_index;
|
||||
rtm->rtm_addrs = info.rti_addrs;
|
||||
error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size);
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user