-/* $OpenBSD: route.c,v 1.163 2014/04/23 09:30:57 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.164 2014/04/25 10:41:09 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
rt_getifa(struct rt_addrinfo *info, u_int rtid)
{
struct ifaddr *ifa;
+ struct ifnet *ifp = NULL;
/*
* ifp may be specified by sockaddr_dl when protocol address
* is ambiguous
*/
- if (info->rti_ifp == NULL && info->rti_info[RTAX_IFP] != NULL) {
+ if (info->rti_info[RTAX_IFP] != NULL) {
struct sockaddr_dl *sdl;
sdl = (struct sockaddr_dl *)info->rti_info[RTAX_IFP];
- info->rti_ifp = if_get(sdl->sdl_index);
+ ifp = if_get(sdl->sdl_index);
}
if (info->rti_ifa == NULL && info->rti_info[RTAX_IFA] != NULL)
if ((sa = info->rti_info[RTAX_GATEWAY]) == NULL)
sa = info->rti_info[RTAX_DST];
- if (sa != NULL && info->rti_ifp != NULL)
- info->rti_ifa = ifaof_ifpforaddr(sa, info->rti_ifp);
+ if (sa != NULL && ifp != NULL)
+ info->rti_ifa = ifaof_ifpforaddr(sa, ifp);
else if (info->rti_info[RTAX_DST] != NULL &&
info->rti_info[RTAX_GATEWAY] != NULL)
info->rti_ifa = ifa_ifwithroute(info->rti_flags,
if ((ifa = info->rti_ifa) == NULL)
return (ENETUNREACH);
- if (info->rti_ifp == NULL)
- info->rti_ifp = ifa->ifa_ifp;
-
return (0);
}
info->rti_ifa = rt->rt_ifa;
} else {
/*
- * The interface address at the cloning route
- * is not longer referenced by an interface.
+ * The address of the cloning route is not longer
+ * configured on an interface, but its descriptor
+ * is still there because of reference counting.
+ *
* Try to find a similar active address and use
* it for the cloned route. The cloning route
* will get the new address and interface later.
info->rti_ifa = NULL;
info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
}
- info->rti_ifp = rt->rt_ifp;
info->rti_flags = rt->rt_flags & ~(RTF_CLONING | RTF_STATIC);
info->rti_flags |= RTF_CLONED;
info->rti_info[RTAX_GATEWAY] = rt->rt_gateway;
-/* $OpenBSD: rtsock.c,v 1.142 2014/03/18 10:47:34 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.143 2014/04/25 10:41:09 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
ifafree(rt->rt_ifa);
rt->rt_ifa = ifa;
ifa->ifa_refcnt++;
- rt->rt_ifp = info.rti_ifp;
+ rt->rt_ifp = ifa->ifa_ifp;
#ifndef SMALL_KERNEL
/* recheck link state after ifp change*/
rt_if_linkstate_change(