Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_input.c
Show First 20 Lines • Show All 1,059 Lines • ▼ Show 20 Lines | if (!srcrt && V_ipsendredirects && | ||||
nh = ro.ro_nh; | nh = ro.ro_nh; | ||||
if (nh != NULL && ((nh->nh_flags & (NHF_REDIRECT|NHF_DEFAULT)) == 0)) { | if (nh != NULL && ((nh->nh_flags & (NHF_REDIRECT|NHF_DEFAULT)) == 0)) { | ||||
struct in_ifaddr *nh_ia = (struct in_ifaddr *)(nh->nh_ifa); | struct in_ifaddr *nh_ia = (struct in_ifaddr *)(nh->nh_ifa); | ||||
u_long src = ntohl(ip->ip_src.s_addr); | u_long src = ntohl(ip->ip_src.s_addr); | ||||
if (nh_ia != NULL && | if (nh_ia != NULL && | ||||
(src & nh_ia->ia_subnetmask) == nh_ia->ia_subnet) { | (src & nh_ia->ia_subnetmask) == nh_ia->ia_subnet) { | ||||
if (nh->nh_flags & NHF_GATEWAY) | |||||
dest.s_addr = nh->gw4_sa.sin_addr.s_addr; | |||||
else | |||||
dest.s_addr = ip->ip_dst.s_addr; | |||||
/* Router requirements says to only send host redirects */ | /* Router requirements says to only send host redirects */ | ||||
type = ICMP_REDIRECT; | type = ICMP_REDIRECT; | ||||
code = ICMP_REDIRECT_HOST; | code = ICMP_REDIRECT_HOST; | ||||
if (nh->nh_flags & NHF_GATEWAY) { | |||||
if (nh->gw_sa.sa_family == AF_INET) | |||||
dest.s_addr = nh->gw4_sa.sin_addr.s_addr; | |||||
else /* Do not redirect in case gw is AF_INET6 */ | |||||
type = 0; | |||||
} else | |||||
dest.s_addr = ip->ip_dst.s_addr; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL); | error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL); | ||||
if (error == EMSGSIZE && ro.ro_nh) | if (error == EMSGSIZE && ro.ro_nh) | ||||
mtu = ro.ro_nh->nh_mtu; | mtu = ro.ro_nh->nh_mtu; | ||||
▲ Show 20 Lines • Show All 354 Lines • Show Last 20 Lines |