diff options
author | 2015-09-03 09:59:59 +0000 | |
---|---|---|
committer | 2015-09-03 09:59:59 +0000 | |
commit | bcf8da7be3a24081c0ed67098f4ede5677b067dc (patch) | |
tree | ea933c55e9404226ebd89337cd646a9ae6ea4095 /sys/netinet/ip_output.c | |
parent | Unconditionally set the RTF_UP flags when adding a route to the table. (diff) | |
download | wireguard-openbsd-bcf8da7be3a24081c0ed67098f4ede5677b067dc.tar.xz wireguard-openbsd-bcf8da7be3a24081c0ed67098f4ede5677b067dc.zip |
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/ip_output.c')
-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; |