summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-09-02 08:28:07 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-09-02 08:28:07 +0000
commitf5c94c5f2b93468668d421c38d5c16416b66a7ad (patch)
treec2f7e3084be96c432b498a2aeff27872231caa33
parent38f9f8c78cd1500c5b0964d109153fa256b6ddac (diff)
Revert the two uses of rtisvalid(9) for the moment, it breaks dhclient(8)
configured networks on RAMDISK kernels. The problem is that the default route installed by dhclient(8) does not have the RTF_UP flag in this environement and rtisvalid(9) doesn't allow you to use a RTF_DOWN route.
-rw-r--r--sys/netinet/ip_output.c28
-rw-r--r--sys/netinet6/in6_src.c14
2 files changed, 19 insertions, 23 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 68615e46ec8..986933deca4 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.288 2015/09/01 14:33:15 mpi Exp $ */
+/* $OpenBSD: ip_output.c,v 1.289 2015/09/02 08:28:06 mpi Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -168,13 +168,12 @@ 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 valid. If not, free
- * it and try again.
+ * 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 (!rtisvalid(ro->ro_rt) ||
+ if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
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;
}
@@ -196,9 +195,7 @@ 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 (!rtisvalid(ro->ro_rt)) {
- rtfree(ro->ro_rt);
- ro->ro_rt = NULL;
+ if (ro->ro_rt == NULL) {
ipstat.ips_noroute++;
error = EHOSTUNREACH;
goto bad;
@@ -299,13 +296,12 @@ reroute:
dst = satosin(&ro->ro_dst);
/*
- * 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 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 (!rtisvalid(ro->ro_rt) ||
+ if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
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;
}
@@ -327,9 +323,7 @@ reroute:
ro->ro_rt = rtalloc_mpath(&ro->ro_dst,
&ip->ip_src.s_addr, ro->ro_tableid);
- if (!rtisvalid(ro->ro_rt)) {
- rtfree(ro->ro_rt);
- ro->ro_rt = NULL;
+ if (ro->ro_rt == NULL) {
ipstat.ips_noroute++;
error = EHOSTUNREACH;
goto bad;
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index decbfce762e..9066cb37edd 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_src.c,v 1.52 2015/09/01 14:33:15 mpi Exp $ */
+/* $OpenBSD: in6_src.c,v 1.53 2015/09/02 08:28:06 mpi Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@@ -247,12 +247,13 @@ in6_selectsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock,
* our src addr is taken from the i/f, else punt.
*/
if (ro) {
- if (!rtisvalid(ro->ro_rt) ||
- !IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst)) {
+ if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
+ !IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst))) {
rtfree(ro->ro_rt);
ro->ro_rt = NULL;
}
- if (ro->ro_rt == NULL) {
+ if (ro->ro_rt == (struct rtentry *)0 ||
+ ro->ro_rt->rt_ifp == (struct ifnet *)0) {
struct sockaddr_in6 *sa6;
/* No route yet, so try to acquire one */
@@ -418,9 +419,10 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
* cached destination, in case of sharing the cache with IPv4.
*/
if (ro) {
- if (!rtisvalid(ro->ro_rt) ||
+ if (ro->ro_rt &&
+ (!(ro->ro_rt->rt_flags & RTF_UP) ||
sin6tosa(&ro->ro_dst)->sa_family != AF_INET6 ||
- !IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst)) {
+ !IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst))) {
rtfree(ro->ro_rt);
ro->ro_rt = NULL;
}