summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r--sys/netinet/ip_input.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 17e3103..475b837 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -219,7 +219,6 @@ static struct mbuf *ip_reass __P((struct mbuf *, struct ipqhead *, struct ipq *,
#else
static struct mbuf *ip_reass __P((struct mbuf *, struct ipqhead *, struct ipq *));
#endif
-static struct in_ifaddr *ip_rtaddr __P((struct in_addr));
static void ipintr __P((void));
/*
@@ -1273,7 +1272,7 @@ nosourcerouting:
if ((ia = (INA)ifa_ifwithdstaddr((SA)&ipaddr)) == 0)
ia = (INA)ifa_ifwithnet((SA)&ipaddr);
} else
- ia = ip_rtaddr(ipaddr.sin_addr);
+ ia = ip_rtaddr(ipaddr.sin_addr, &ipforward_rt);
if (ia == 0) {
type = ICMP_UNREACH;
code = ICMP_UNREACH_SRCFAIL;
@@ -1311,7 +1310,8 @@ nosourcerouting:
* use the incoming interface (should be same).
*/
if ((ia = (INA)ifa_ifwithaddr((SA)&ipaddr)) == 0 &&
- (ia = ip_rtaddr(ipaddr.sin_addr)) == 0) {
+ (ia = ip_rtaddr(ipaddr.sin_addr,
+ &ipforward_rt)) == 0) {
type = ICMP_UNREACH;
code = ICMP_UNREACH_HOST;
goto bad;
@@ -1399,30 +1399,31 @@ bad:
* Given address of next destination (final or next hop),
* return internet address info of interface to be used to get there.
*/
-static struct in_ifaddr *
-ip_rtaddr(dst)
- struct in_addr dst;
+struct in_ifaddr *
+ip_rtaddr(dst, rt)
+ struct in_addr dst;
+ struct route *rt;
{
register struct sockaddr_in *sin;
- sin = (struct sockaddr_in *) &ipforward_rt.ro_dst;
+ sin = (struct sockaddr_in *)&rt->ro_dst;
- if (ipforward_rt.ro_rt == 0 ||
- !(ipforward_rt.ro_rt->rt_flags & RTF_UP) ||
+ if (rt->ro_rt == 0 ||
+ !(rt->ro_rt->rt_flags & RTF_UP) ||
dst.s_addr != sin->sin_addr.s_addr) {
- if (ipforward_rt.ro_rt) {
- RTFREE(ipforward_rt.ro_rt);
- ipforward_rt.ro_rt = 0;
+ if (rt->ro_rt) {
+ RTFREE(rt->ro_rt);
+ rt->ro_rt = 0;
}
sin->sin_family = AF_INET;
sin->sin_len = sizeof(*sin);
sin->sin_addr = dst;
- rtalloc_ign(&ipforward_rt, RTF_PRCLONING);
+ rtalloc_ign(rt, RTF_PRCLONING);
}
- if (ipforward_rt.ro_rt == 0)
+ if (rt->ro_rt == 0)
return ((struct in_ifaddr *)0);
- return (ifatoia(ipforward_rt.ro_rt->rt_ifa));
+ return (ifatoia(rt->ro_rt->rt_ifa));
}
/*
@@ -1608,7 +1609,7 @@ ip_forward(m, srcrt)
}
#endif
- if (ip_rtaddr(ip->ip_dst) == 0) {
+ if (ip_rtaddr(ip->ip_dst, &ipforward_rt) == 0) {
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0);
return;
} else
OpenPOWER on IntegriCloud