Changeset View
Changeset View
Standalone View
Standalone View
sys/net/route.c
Show First 20 Lines • Show All 587 Lines • ▼ Show 20 Lines | rtredirect_fib(struct sockaddr *dst, | ||||
int flags, | int flags, | ||||
struct sockaddr *src, | struct sockaddr *src, | ||||
u_int fibnum) | u_int fibnum) | ||||
{ | { | ||||
struct rtentry *rt; | struct rtentry *rt; | ||||
int error = 0; | int error = 0; | ||||
short *stat = NULL; | short *stat = NULL; | ||||
struct rt_addrinfo info; | struct rt_addrinfo info; | ||||
struct epoch_tracker et; | |||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
struct rib_head *rnh; | struct rib_head *rnh; | ||||
NET_EPOCH_ASSERT(); | |||||
ifa = NULL; | ifa = NULL; | ||||
NET_EPOCH_ENTER(et); | |||||
rnh = rt_tables_get_rnh(fibnum, dst->sa_family); | rnh = rt_tables_get_rnh(fibnum, dst->sa_family); | ||||
if (rnh == NULL) { | if (rnh == NULL) { | ||||
error = EAFNOSUPPORT; | error = EAFNOSUPPORT; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* verify the gateway is directly reachable */ | /* verify the gateway is directly reachable */ | ||||
if ((ifa = ifa_ifwithnet(gateway, 0, fibnum)) == NULL) { | if ((ifa = ifa_ifwithnet(gateway, 0, fibnum)) == NULL) { | ||||
error = ENETUNREACH; | error = ENETUNREACH; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | create: | ||||
RIB_WUNLOCK(rnh); | RIB_WUNLOCK(rnh); | ||||
} | } | ||||
} else | } else | ||||
error = EHOSTUNREACH; | error = EHOSTUNREACH; | ||||
done: | done: | ||||
if (rt) | if (rt) | ||||
RTFREE_LOCKED(rt); | RTFREE_LOCKED(rt); | ||||
out: | out: | ||||
NET_EPOCH_EXIT(et); | |||||
if (error) | if (error) | ||||
V_rtstat.rts_badredirect++; | V_rtstat.rts_badredirect++; | ||||
else if (stat != NULL) | else if (stat != NULL) | ||||
(*stat)++; | (*stat)++; | ||||
bzero((caddr_t)&info, sizeof(info)); | bzero((caddr_t)&info, sizeof(info)); | ||||
info.rti_info[RTAX_DST] = dst; | info.rti_info[RTAX_DST] = dst; | ||||
info.rti_info[RTAX_GATEWAY] = gateway; | info.rti_info[RTAX_GATEWAY] = gateway; | ||||
info.rti_info[RTAX_NETMASK] = netmask; | info.rti_info[RTAX_NETMASK] = netmask; | ||||
▲ Show 20 Lines • Show All 1,564 Lines • Show Last 20 Lines |