Hi,

Instead of doing the the if_get() dance for rt_missmsg(), change the
function to take an interface index.

ok?

bluhm

Index: net/route.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.c,v
retrieving revision 1.260
diff -u -p -r1.260 route.c
--- net/route.c 24 Oct 2015 11:58:46 -0000      1.260
+++ net/route.c 24 Oct 2015 16:55:36 -0000
@@ -235,7 +235,7 @@ rtalloc(struct sockaddr *dst, int flags,
                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, 
                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 
        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 
                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 ta
 {
        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 ta
        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);
 }
 
Index: net/route.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/route.h,v
retrieving revision 1.116
diff -u -p -r1.116 route.h
--- net/route.h 24 Oct 2015 11:47:07 -0000      1.116
+++ net/route.h 24 Oct 2015 16:38:15 -0000
@@ -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 **);
Index: net/rtsock.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/net/rtsock.c,v
retrieving revision 1.176
diff -u -p -r1.176 rtsock.c
--- net/rtsock.c        24 Oct 2015 11:58:47 -0000      1.176
+++ net/rtsock.c        24 Oct 2015 16:37:27 -0000
@@ -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 
        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
Index: netinet/in_pcb.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.c,v
retrieving revision 1.186
diff -u -p -r1.186 in_pcb.c
--- netinet/in_pcb.c    23 Oct 2015 13:26:07 -0000      1.186
+++ netinet/in_pcb.c    24 Oct 2015 16:38:59 -0000
@@ -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,

Reply via email to