-/* $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 $ */
/*
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;
-/* $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 $ */
/*
* 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);