-/* $OpenBSD: route.c,v 1.316 2016/08/22 16:01:52 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.317 2016/08/22 16:53:59 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
ifa = ifaof_ifpforaddr(dst, ifp);
if_put(ifp);
} else {
- ifa = ifa_ifwithnet(gateway, rtableid);
- }
- }
- if (ifa == NULL) {
- struct rtentry *rt = rtalloc(gateway, 0, rtableid);
- /* The gateway must be local if the same address family. */
- if (!rtisvalid(rt) || ((rt->rt_flags & RTF_GATEWAY) &&
- rt_key(rt)->sa_family == dst->sa_family)) {
+ struct rtentry *rt;
+
+ rt = rtalloc(gateway, RT_RESOLVE, rtableid);
+ if (rt != NULL)
+ ifa = rt->rt_ifa;
rtfree(rt);
- return (NULL);
}
- ifa = rt->rt_ifa;
- rtfree(rt);
}
+ if (ifa == NULL)
+ return (NULL);
if (ifa->ifa_addr->sa_family != dst->sa_family) {
struct ifaddr *oifa = ifa;
ifa = ifaof_ifpforaddr(dst, ifa->ifa_ifp);