summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_output.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-09-01 14:33:15 +0000
committermpi <mpi@openbsd.org>2015-09-01 14:33:15 +0000
commit127da855394128a7dab6cb73ac4c1b87876612b0 (patch)
tree65d0d7fb66dc9820466dc0a7bdf4eaf9852cb7d8 /sys/netinet/ip_output.c
parentspace between macro args and punctuation; (diff)
downloadwireguard-openbsd-127da855394128a7dab6cb73ac4c1b87876612b0.tar.xz
wireguard-openbsd-127da855394128a7dab6cb73ac4c1b87876612b0.zip
Convert ip{,6}_output() (cached) route entry checks to rtisvalid(9).
ok bluhm@
Diffstat (limited to 'sys/netinet/ip_output.c')
-rw-r--r--sys/netinet/ip_output.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 70c45917bc5..68615e46ec8 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.287 2015/08/31 07:17:12 mpi Exp $ */
+/* $OpenBSD: ip_output.c,v 1.288 2015/09/01 14:33:15 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;