Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/route.c
Show First 20 Lines • Show All 739 Lines • ▼ Show 20 Lines | case AF_INET: | ||||
break; | break; | ||||
case AF_INET6: | case AF_INET6: | ||||
if (IN6_IS_ADDR_UNSPECIFIED(&satosin6(rt_key(rt))->sin6_addr)) | if (IN6_IS_ADDR_UNSPECIFIED(&satosin6(rt_key(rt))->sin6_addr)) | ||||
not_found = 1; | not_found = 1; | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
if (!not_found && rt->rt_ifa != NULL) { | if (!not_found && rt->rt_nhop->nh_ifa != NULL) { | ||||
ifa = rt->rt_ifa; | ifa = rt->rt_nhop->nh_ifa; | ||||
} | } | ||||
RT_REMREF(rt); | RT_REMREF(rt); | ||||
RT_UNLOCK(rt); | RT_UNLOCK(rt); | ||||
if (not_found || ifa == NULL) | if (not_found || ifa == NULL) | ||||
goto out; | goto out; | ||||
} | } | ||||
if (ifa->ifa_addr->sa_family != dst->sa_family) { | if (ifa->ifa_addr->sa_family != dst->sa_family) { | ||||
struct ifaddr *oifa = ifa; | struct ifaddr *oifa = ifa; | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | rib_lookup_info(uint32_t fibnum, const struct sockaddr *dst, uint32_t flags, | ||||
if (rh == NULL) | if (rh == NULL) | ||||
return (ENOENT); | return (ENOENT); | ||||
RIB_RLOCK(rh); | RIB_RLOCK(rh); | ||||
rn = rh->rnh_matchaddr(__DECONST(void *, dst), &rh->head); | rn = rh->rnh_matchaddr(__DECONST(void *, dst), &rh->head); | ||||
if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { | if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { | ||||
rt = RNTORT(rn); | rt = RNTORT(rn); | ||||
/* Ensure route & ifp is UP */ | /* 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; | flags = (flags & NHR_REF) | NHR_COPY; | ||||
error = rt_exportinfo(rt, info, flags); | error = rt_exportinfo(rt, info, flags); | ||||
RIB_RUNLOCK(rh); | RIB_RUNLOCK(rh); | ||||
return (error); | return (error); | ||||
} | } | ||||
} | } | ||||
RIB_RUNLOCK(rh); | RIB_RUNLOCK(rh); | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | while (di.head != NULL) { | ||||
/* TODO std rt -> rt_addrinfo export */ | /* TODO std rt -> rt_addrinfo export */ | ||||
di.info.rti_info[RTAX_DST] = rt_key(rt); | di.info.rti_info[RTAX_DST] = rt_key(rt); | ||||
di.info.rti_info[RTAX_NETMASK] = rt_mask(rt); | di.info.rti_info[RTAX_NETMASK] = rt_mask(rt); | ||||
rt_notifydelete(rt, &di.info); | rt_notifydelete(rt, &di.info); | ||||
if (report) | 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); | RTFREE_LOCKED(rt); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Iterates over all existing fibs in system and deletes each element | * Iterates over all existing fibs in system and deletes each element | ||||
* for which @filter_f function returns non-zero value. | * for which @filter_f function returns non-zero value. | ||||
* If @family is not AF_UNSPEC, iterates over fibs in particular | * If @family is not AF_UNSPEC, iterates over fibs in particular | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
rt_notifydelete(struct rtentry *rt, struct rt_addrinfo *info) | rt_notifydelete(struct rtentry *rt, struct rt_addrinfo *info) | ||||
{ | { | ||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
/* | /* | ||||
* give the protocol a chance to keep things in sync. | * 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) | if (ifa != NULL && ifa->ifa_rtrequest != NULL) | ||||
ifa->ifa_rtrequest(RTM_DELETE, rt, rt->rt_nhop, info); | ifa->ifa_rtrequest(RTM_DELETE, rt, rt->rt_nhop, info); | ||||
/* | /* | ||||
* One more rtentry floating around that is not | * One more rtentry floating around that is not | ||||
* linked to the routing table. rttrash will be decremented | * linked to the routing table. rttrash will be decremented | ||||
* when RTFREE(rt) is eventually called. | * when RTFREE(rt) is eventually called. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 609 Lines • ▼ Show 20 Lines | #endif | ||||
* New gateway could require new ifaddr, ifp; | * New gateway could require new ifaddr, ifp; | ||||
* flags may also be different; ifp may be specified | * flags may also be different; ifp may be specified | ||||
* by ll sockaddr when protocol address is ambiguous | * by ll sockaddr when protocol address is ambiguous | ||||
*/ | */ | ||||
if (((rt->rt_flags & RTF_GATEWAY) && | if (((rt->rt_flags & RTF_GATEWAY) && | ||||
info->rti_info[RTAX_GATEWAY] != NULL) || | info->rti_info[RTAX_GATEWAY] != NULL) || | ||||
info->rti_info[RTAX_IFP] != NULL || | info->rti_info[RTAX_IFP] != NULL || | ||||
(info->rti_info[RTAX_IFA] != 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 | * XXX: Temporarily set RTF_RNH_LOCKED flag in the rti_flags | ||||
* to avoid rlock in the ifa_ifwithroute(). | * to avoid rlock in the ifa_ifwithroute(). | ||||
*/ | */ | ||||
info->rti_flags |= RTF_RNH_LOCKED; | info->rti_flags |= RTF_RNH_LOCKED; | ||||
error = rt_getifa_fib(info, rnh->rib_fibnum); | error = rt_getifa_fib(info, rnh->rib_fibnum); | ||||
info->rti_flags &= ~RTF_RNH_LOCKED; | info->rti_flags &= ~RTF_RNH_LOCKED; | ||||
if (info->rti_ifa != NULL) | if (info->rti_ifa != NULL) | ||||
▲ Show 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | #ifdef RADIX_MPATH | ||||
ifa->ifa_addr); | ifa->ifa_addr); | ||||
if (rt == NULL) | if (rt == NULL) | ||||
error = ESRCH; | error = ESRCH; | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
error = (rn == NULL || | error = (rn == NULL || | ||||
(rn->rn_flags & RNF_ROOT) || | (rn->rn_flags & RNF_ROOT) || | ||||
RNTORT(rn)->rt_ifa != ifa); | RNTORT(rn)->rt_nhop->nh_ifa != ifa); | ||||
RIB_RUNLOCK(rnh); | RIB_RUNLOCK(rnh); | ||||
if (error) { | if (error) { | ||||
/* this is only an error if bad on ALL tables */ | /* this is only an error if bad on ALL tables */ | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Do the actual request | * Do the actual request | ||||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |