diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-10-13 10:29:17 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-10-13 10:29:17 +0000 |
commit | 9d528f9d0d4617335a5b7ba7e66b66b76b4a2650 (patch) | |
tree | a9b196a8fd348ea4c4794abdfeae3362cf5056ca | |
parent | 06d3df2be1bc50a846a38f4f248c9b16718bc1e8 (diff) |
Make use of rtisvalid(9) to check if local route entries match existing
configured addressses.
ok mikeb@
-rw-r--r-- | sys/netinet/ip_input.c | 12 | ||||
-rw-r--r-- | sys/netinet6/ip6_input.c | 4 |
2 files changed, 6 insertions, 10 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index b630e798a3d..2d8cc521d8d 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.256 2015/09/25 09:51:20 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.257 2015/10/13 10:29:16 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -671,13 +671,9 @@ in_ouraddr(struct mbuf *m, struct ifnet *ifp, struct in_addr ina) sin.sin_family = AF_INET; sin.sin_addr = ina; rt = rtalloc(sintosa(&sin), 0, m->m_pkthdr.ph_rtableid); - if (rt != NULL) { - /* only use non-stale local address, check before route free */ - if ((rt->rt_flags & (RTF_LOCAL|RTF_BROADCAST)) && - rt->rt_ifa != NULL && rt->rt_ifa->ifa_ifp != NULL) - ia = ifatoia(rt->rt_ifa); - rtfree(rt); - } + if (rtisvalid(rt) && ISSET(rt->rt_flags, RTF_LOCAL|RTF_BROADCAST)) + ia = ifatoia(rt->rt_ifa); + rtfree(rt); if (ia == NULL) { struct ifaddr *ifa; diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index b5fd24a3e96..e1d5ea58707 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.146 2015/09/11 09:54:46 claudio Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.147 2015/10/13 10:29:16 mpi Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -445,7 +445,7 @@ ip6_input(struct mbuf *m) * Accept the packet if the route to the destination is marked * as local. */ - if (ip6_forward_rt.ro_rt && + if (rtisvalid(ip6_forward_rt.ro_rt) && ISSET(ip6_forward_rt.ro_rt->rt_flags, RTF_LOCAL)) { struct in6_ifaddr *ia6 = ifatoia6(ip6_forward_rt.ro_rt->rt_ifa); |