From 11ad1eea802e0594318c456699776ce75c79c08e Mon Sep 17 00:00:00 2001 From: bluhm Date: Sun, 25 Oct 2015 10:05:09 +0000 Subject: [PATCH] Instead of doing the the if_get() dance for rt_missmsg(), change the function to take an interface index. discussed with mpi@; OK claudio@ --- sys/net/route.c | 19 +++++++++---------- sys/net/route.h | 5 ++--- sys/net/rtsock.c | 9 ++++----- sys/netinet/in_pcb.c | 4 ++-- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 5336736c6fb..804a33b4071 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.260 2015/10/24 11:58:46 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.261 2015/10/25 10:05:09 bluhm Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -235,7 +235,7 @@ rtalloc(struct sockaddr *dst, int flags, unsigned int tableid) rtstat.rts_unreach++; miss: if (ISSET(flags, RT_REPORT)) - rt_missmsg(RTM_MISS, &info, 0, NULL, error, tableid); + rt_missmsg(RTM_MISS, &info, 0, 0, error, tableid); } KERNEL_UNLOCK(); splx(s); @@ -398,7 +398,7 @@ rt_sendmsg(struct rtentry *rt, int cmd, u_int rtableid) info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } - rt_missmsg(cmd, &info, rt->rt_flags, ifp, 0, rtableid); + rt_missmsg(cmd, &info, rt->rt_flags, rt->rt_ifidx, 0, rtableid); if_put(ifp); } @@ -431,7 +431,7 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, u_int32_t *stat = NULL; struct rt_addrinfo info; struct ifaddr *ifa; - struct ifnet *ifp = NULL; + unsigned int ifidx; splsoftassert(IPL_SOFTNET); @@ -440,7 +440,7 @@ rtredirect(struct sockaddr *dst, struct sockaddr *gateway, error = ENETUNREACH; goto out; } - ifp = ifa->ifa_ifp; + ifidx = ifa->ifa_ifp->if_index; rt = rtalloc(dst, 0, rdomain); /* * If the redirect isn't from our current router for this dst, @@ -521,7 +521,7 @@ out: info.rti_info[RTAX_GATEWAY] = gateway; info.rti_info[RTAX_NETMASK] = netmask; info.rti_info[RTAX_AUTHOR] = src; - rt_missmsg(RTM_REDIRECT, &info, flags, ifp, error, rdomain); + rt_missmsg(RTM_REDIRECT, &info, flags, ifidx, error, rdomain); } /* @@ -532,7 +532,7 @@ rtdeletemsg(struct rtentry *rt, u_int tableid) { int error; struct rt_addrinfo info; - struct ifnet *ifp; + unsigned int ifidx; /* * Request the new route so that the entry is not actually @@ -544,12 +544,11 @@ rtdeletemsg(struct rtentry *rt, u_int tableid) info.rti_info[RTAX_NETMASK] = rt_mask(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; info.rti_flags = rt->rt_flags; - ifp = if_get(rt->rt_ifidx); + ifidx = rt->rt_ifidx; error = rtrequest1(RTM_DELETE, &info, rt->rt_priority, &rt, tableid); - rt_missmsg(RTM_DELETE, &info, info.rti_flags, ifp, error, tableid); + rt_missmsg(RTM_DELETE, &info, info.rti_flags, ifidx, error, tableid); if (error == 0) rtfree(rt); - if_put(ifp); return (error); } diff --git a/sys/net/route.h b/sys/net/route.h index b4bf7637a7f..de9ea49f758 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.116 2015/10/24 11:47:07 mpi Exp $ */ +/* $OpenBSD: route.h,v 1.117 2015/10/25 10:05:09 bluhm Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -357,8 +357,7 @@ void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *); void rt_sendmsg(struct rtentry *, int, u_int); void rt_sendaddrmsg(struct rtentry *, int); -void rt_missmsg(int, struct rt_addrinfo *, int, struct ifnet *, int, - u_int); +void rt_missmsg(int, struct rt_addrinfo *, int, u_int, int, u_int); int rt_setgate(struct rtentry *, struct sockaddr *, unsigned int); int rt_checkgate(struct ifnet *, struct rtentry *, struct sockaddr *, unsigned int, struct rtentry **); diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 49ce1bc47ca..79a09d8d152 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.176 2015/10/24 11:58:47 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.177 2015/10/25 10:05:09 bluhm Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -1075,8 +1075,8 @@ again: * destination. */ void -rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, - struct ifnet *ifp, int error, u_int tableid) +rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, u_int ifidx, + int error, u_int tableid) { struct rt_msghdr *rtm; struct mbuf *m; @@ -1092,8 +1092,7 @@ rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, rtm->rtm_errno = error; rtm->rtm_tableid = tableid; rtm->rtm_addrs = rtinfo->rti_addrs; - if (ifp != NULL) - rtm->rtm_index = ifp->if_index; + rtm->rtm_index = ifidx; if (sa == NULL) route_proto.sp_protocol = 0; else diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 477db52ba91..8930c49f74b 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.186 2015/10/23 13:26:07 mpi Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.187 2015/10/25 10:05:09 bluhm Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -635,7 +635,7 @@ in_losing(struct inpcb *inp) info.rti_info[RTAX_DST] = &inp->inp_route.ro_dst; info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; info.rti_info[RTAX_NETMASK] = rt_mask(rt); - rt_missmsg(RTM_LOSING, &info, rt->rt_flags, rt->rt_ifp, 0, + rt_missmsg(RTM_LOSING, &info, rt->rt_flags, rt->rt_ifidx, 0, inp->inp_rtableid); if (rt->rt_flags & RTF_DYNAMIC) (void)rtrequest1(RTM_DELETE, &info, rt->rt_priority, -- 2.20.1