From: mpi Date: Fri, 25 Apr 2014 10:41:09 +0000 (+0000) Subject: Remove rti_ifp from rt_addrinfo, one less ifp pointer, say yay! X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ba9697f9bec1b4c3ccad5535f7c4cd32deaae9ec;p=openbsd Remove rti_ifp from rt_addrinfo, one less ifp pointer, say yay! This pointer was only needed by rt_getifa() to find an address, so turn it into a local variable. ok henning@, bluhm@ --- diff --git a/sys/net/route.c b/sys/net/route.c index 49f73e5afd8..ca23aa83e04 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -691,16 +691,17 @@ int 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) @@ -713,8 +714,8 @@ rt_getifa(struct rt_addrinfo *info, u_int rtid) 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, @@ -729,9 +730,6 @@ rt_getifa(struct rt_addrinfo *info, u_int rtid) if ((ifa = info->rti_ifa) == NULL) return (ENETUNREACH); - if (info->rti_ifp == NULL) - info->rti_ifp = ifa->ifa_ifp; - return (0); } @@ -828,8 +826,10 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio, 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. @@ -837,7 +837,6 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio, 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; diff --git a/sys/net/route.h b/sys/net/route.h index 499d8d15bc6..988b8742c9d 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.91 2014/04/10 13:47:21 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.92 2014/04/25 10:41:09 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -299,7 +299,6 @@ struct rt_addrinfo { struct sockaddr *rti_info[RTAX_MAX]; int rti_flags; struct ifaddr *rti_ifa; - struct ifnet *rti_ifp; struct rt_msghdr *rti_rtm; u_char rti_mpls; }; diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 98e2cc93235..4178fe6aa22 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -768,7 +768,7 @@ report: 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(