diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-04-25 12:33:49 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-04-25 12:33:49 +0000 |
commit | efedbfe92df8f2581b754ad54fbfc0f60d60dce1 (patch) | |
tree | 5db06a118728fafa959f473267201ea06c2b88b4 /sys/netinet | |
parent | 58edcb93c8caa9377c4fe07c35cac9a2172de9b2 (diff) |
Remove the single cache route for forwarding.
Testing help from Hrvoje Popovski.
ok mikeb@, henning@, claudio@
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_input.c | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 4da9325a738..42176532a11 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.273 2016/04/19 08:23:13 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.274 2016/04/25 12:33:48 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -197,8 +197,6 @@ ip_init(void) mq_init(&ipsend_mq, 64, IPL_SOFTNET); } -struct route ipforward_rt; - void ipintr(void) { @@ -972,10 +970,6 @@ ip_slowtimo(void) ip_freef(fp); } } - if (ipforward_rt.ro_rt) { - rtfree(ipforward_rt.ro_rt); - ipforward_rt.ro_rt = NULL; - } splx(s); } @@ -1399,8 +1393,8 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, int srcrt) struct ip *ip = mtod(m, struct ip *); struct sockaddr_in *sin; struct rtentry *rt; + struct route ro; int error, type = 0, code = 0, destmtu = 0, fake = 0, len; - u_int rtableid = 0; u_int32_t dest; dest = 0; @@ -1414,29 +1408,18 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, int srcrt) return; } - rtableid = m->m_pkthdr.ph_rtableid; - rt = ipforward_rt.ro_rt; - sin = satosin(&ipforward_rt.ro_dst); - if (rt == NULL || ISSET(rt->rt_flags, RTF_MPATH) || - ip->ip_dst.s_addr != sin->sin_addr.s_addr || - rtableid != ipforward_rt.ro_tableid) { - if (ipforward_rt.ro_rt) { - rtfree(ipforward_rt.ro_rt); - ipforward_rt.ro_rt = NULL; - } - sin->sin_family = AF_INET; - sin->sin_len = sizeof(*sin); - sin->sin_addr = ip->ip_dst; - ipforward_rt.ro_tableid = rtableid; - - ipforward_rt.ro_rt = rtalloc_mpath(&ipforward_rt.ro_dst, - &ip->ip_src.s_addr, ipforward_rt.ro_tableid); - if (ipforward_rt.ro_rt == 0) { - icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0); - return; - } - rt = ipforward_rt.ro_rt; + sin = satosin(&ro.ro_dst); + memset(sin, 0, sizeof(*sin)); + sin->sin_family = AF_INET; + sin->sin_len = sizeof(*sin); + sin->sin_addr = ip->ip_dst; + + rt = rtalloc_mpath(sintosa(sin), &ip->ip_src.s_addr, + m->m_pkthdr.ph_rtableid); + if (rt == NULL) { + icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0); + return; } /* @@ -1488,7 +1471,9 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, int srcrt) } } - error = ip_output(m, NULL, &ipforward_rt, + ro.ro_rt = rt; + ro.ro_tableid = m->m_pkthdr.ph_rtableid; + error = ip_output(m, NULL, &ro, (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), NULL, NULL, 0); if (error) @@ -1501,7 +1486,7 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, int srcrt) goto freecopy; } if (!fake) - return; + goto freecopy; switch (error) { @@ -1559,9 +1544,10 @@ ip_forward(struct mbuf *m, struct ifnet *ifp, int srcrt) if (mcopy) icmp_error(mcopy, type, code, dest, destmtu); - freecopy: +freecopy: if (fake) m_tag_delete_chain(&mfake); + rtfree(rt); } int |