Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_input.c
Show All 33 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_bootp.h" | #include "opt_bootp.h" | ||||
#include "opt_ipstealth.h" | #include "opt_ipstealth.h" | ||||
#include "opt_ipsec.h" | #include "opt_ipsec.h" | ||||
#include "opt_route.h" | #include "opt_route.h" | ||||
#include "opt_rss.h" | #include "opt_rss.h" | ||||
#include "opt_inet6.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/hhook.h> | #include <sys/hhook.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/domain.h> | #include <sys/domain.h> | ||||
#include <sys/protosw.h> | #include <sys/protosw.h> | ||||
▲ Show 20 Lines • Show All 998 Lines • ▼ Show 20 Lines | if (!srcrt && V_ipsendredirects && | ||||
rt = ro.ro_rt; | rt = ro.ro_rt; | ||||
if (rt && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 && | if (rt && (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 && | ||||
satosin(rt_key(rt))->sin_addr.s_addr != 0) { | satosin(rt_key(rt))->sin_addr.s_addr != 0) { | ||||
#define RTA(rt) ((struct in_ifaddr *)(rt->rt_ifa)) | #define RTA(rt) ((struct in_ifaddr *)(rt->rt_ifa)) | ||||
u_long src = ntohl(ip->ip_src.s_addr); | u_long src = ntohl(ip->ip_src.s_addr); | ||||
if (RTA(rt) && | if (RTA(rt) && (src & RTA(rt)->ia_subnetmask) == | ||||
(src & RTA(rt)->ia_subnetmask) == RTA(rt)->ia_subnet) { | RTA(rt)->ia_subnet | ||||
if (rt->rt_flags & RTF_GATEWAY) | #ifdef INET6 | ||||
dest.s_addr = satosin(rt->rt_gateway)->sin_addr.s_addr; | && ((rt->rt_flags & RTF_GATEWAY) == 0 || | ||||
else | rt->rt_gateway->sa_family == AF_INET) | ||||
dest.s_addr = ip->ip_dst.s_addr; | #endif /* INET6 */ | ||||
) { | |||||
dest = (rt->rt_flags & RTF_GATEWAY) ? | |||||
satosin(rt->rt_gateway)->sin_addr : | |||||
ip->ip_dst; | |||||
/* 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; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL); | error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL); | ||||
▲ Show 20 Lines • Show All 361 Lines • Show Last 20 Lines |