diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-09-03 10:00:00 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-09-03 10:00:00 +0000 |
commit | a74e897a02e2e3476586867d206dce8090340029 (patch) | |
tree | 32012ad82f829c3908c0e72553e17966e972a2e4 /sys/netinet | |
parent | a9043049046af344a5f712e9c5884d60d0cb0e24 (diff) |
Convert ip{,6}_output() (cached) route entry checks to rtisvalid(9).
This introduces a behavior change as we now reject !RTF_UP routes to
output packets. This stricter check exposed a bug in the setup of
new routes and was the reason for the previous revert. This should
be now fixed by r1.229 of sys/net/route.c .
ok bluhm@
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_output.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 986933deca4..1436be3f2e5 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.289 2015/09/02 08:28:06 mpi Exp $ */ +/* $OpenBSD: ip_output.c,v 1.290 2015/09/03 09:59:59 mpi Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -168,12 +168,13 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags, dst = satosin(&ro->ro_dst); /* - * If there is a cached route, check that it is to the same - * destination and is still up. If not, free it and try again. + * If there is a cached route, check that it is to the + * same destination and is still valid. If not, free + * it and try again. */ - if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || + if (!rtisvalid(ro->ro_rt) || dst->sin_addr.s_addr != ip->ip_dst.s_addr || - ro->ro_tableid != m->m_pkthdr.ph_rtableid)) { + ro->ro_tableid != m->m_pkthdr.ph_rtableid) { rtfree(ro->ro_rt); ro->ro_rt = NULL; } @@ -195,7 +196,9 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags, ro->ro_rt = rtalloc_mpath(&ro->ro_dst, NULL, ro->ro_tableid); - if (ro->ro_rt == NULL) { + if (!rtisvalid(ro->ro_rt)) { + rtfree(ro->ro_rt); + ro->ro_rt = NULL; ipstat.ips_noroute++; error = EHOSTUNREACH; goto bad; @@ -296,12 +299,13 @@ reroute: dst = satosin(&ro->ro_dst); /* - * If there is a cached route, check that it is to the same - * destination and is still up. If not, free it and try again. + * If there is a cached route, check that it is to the + * same destination and is still valid. If not, free + * it and try again. */ - if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || + if (!rtisvalid(ro->ro_rt) || dst->sin_addr.s_addr != ip->ip_dst.s_addr || - ro->ro_tableid != m->m_pkthdr.ph_rtableid)) { + ro->ro_tableid != m->m_pkthdr.ph_rtableid) { rtfree(ro->ro_rt); ro->ro_rt = NULL; } @@ -323,7 +327,9 @@ reroute: ro->ro_rt = rtalloc_mpath(&ro->ro_dst, &ip->ip_src.s_addr, ro->ro_tableid); - if (ro->ro_rt == NULL) { + if (!rtisvalid(ro->ro_rt)) { + rtfree(ro->ro_rt); + ro->ro_rt = NULL; ipstat.ips_noroute++; error = EHOSTUNREACH; goto bad; |