Author: glebius
Date: Mon Jul  2 19:44:18 2012
New Revision: 238016
URL: http://svn.freebsd.org/changeset/base/238016

Log:
  Remove route caching from IP multicast routing code. There is no
  reason to do that, and also, cached route never got unreferenced,
  which meant a reference leak.
  
  Reviewed by:  bms

Modified:
  head/sys/netinet/ip_mroute.c
  head/sys/netinet/ip_mroute.h
  head/sys/netinet6/ip6_mroute.c
  head/sys/netinet6/ip6_mroute.h

Modified: head/sys/netinet/ip_mroute.c
==============================================================================
--- head/sys/netinet/ip_mroute.c        Mon Jul  2 19:35:56 2012        
(r238015)
+++ head/sys/netinet/ip_mroute.c        Mon Jul  2 19:44:18 2012        
(r238016)
@@ -924,7 +924,6 @@ add_vif(struct vifctl *vifcp)
     vifp->v_pkt_out   = 0;
     vifp->v_bytes_in  = 0;
     vifp->v_bytes_out = 0;
-    bzero(&vifp->v_route, sizeof(vifp->v_route));
 
     /* Adjust numvifs up if the vifi is higher than numvifs */
     if (V_numvifs <= vifcp->vifc_vifi)
@@ -1702,7 +1701,7 @@ send_packet(struct vif *vifp, struct mbu
         * should get rejected because they appear to come from
         * the loopback interface, thus preventing looping.
         */
-       error = ip_output(m, NULL, &vifp->v_route, IP_FORWARDING, &imo, NULL);
+       error = ip_output(m, NULL, NULL, IP_FORWARDING, &imo, NULL);
        CTR3(KTR_IPMF, "%s: vif %td err %d", __func__,
            (ptrdiff_t)(vifp - V_viftable), error);
 }

Modified: head/sys/netinet/ip_mroute.h
==============================================================================
--- head/sys/netinet/ip_mroute.h        Mon Jul  2 19:35:56 2012        
(r238015)
+++ head/sys/netinet/ip_mroute.h        Mon Jul  2 19:44:18 2012        
(r238016)
@@ -262,7 +262,6 @@ struct vif {
     u_long             v_pkt_out;      /* # pkts out on interface           */
     u_long             v_bytes_in;     /* # bytes in on interface           */
     u_long             v_bytes_out;    /* # bytes out on interface          */
-    struct route       v_route;        /* cached route */
 };
 
 #ifdef _KERNEL

Modified: head/sys/netinet6/ip6_mroute.c
==============================================================================
--- head/sys/netinet6/ip6_mroute.c      Mon Jul  2 19:35:56 2012        
(r238015)
+++ head/sys/netinet6/ip6_mroute.c      Mon Jul  2 19:44:18 2012        
(r238016)
@@ -717,7 +717,6 @@ add_m6if(struct mif6ctl *mifcp)
        mifp->m6_pkt_out   = 0;
        mifp->m6_bytes_in  = 0;
        mifp->m6_bytes_out = 0;
-       bzero(&mifp->m6_route, sizeof(mifp->m6_route));
 
        /* Adjust nummifs up if the mifi is higher than nummifs */
        if (nummifs <= mifcp->mif6c_mifi)
@@ -1576,11 +1575,8 @@ phyint_send(struct ip6_hdr *ip6, struct 
        struct mbuf *mb_copy;
        struct ifnet *ifp = mifp->m6_ifp;
        int error = 0;
-       struct sockaddr_in6 *dst6;
        u_long linkmtu;
 
-       dst6 = &mifp->m6_route.ro_dst;
-
        /*
         * Make a new reference to the packet; make sure that
         * the IPv6 header is actually copied, not just referenced,
@@ -1610,8 +1606,8 @@ phyint_send(struct ip6_hdr *ip6, struct 
                /* XXX: ip6_output will override ip6->ip6_hlim */
                im6o.im6o_multicast_hlim = ip6->ip6_hlim;
                im6o.im6o_multicast_loop = 1;
-               error = ip6_output(mb_copy, NULL, &mifp->m6_route,
-                                  IPV6_FORWARDING, &im6o, NULL, NULL);
+               error = ip6_output(mb_copy, NULL, NULL, IPV6_FORWARDING, &im6o,
+                   NULL, NULL);
 
 #ifdef MRT6DEBUG
                if (V_mrt6debug & DEBUG_XMIT)
@@ -1626,10 +1622,13 @@ phyint_send(struct ip6_hdr *ip6, struct 
         * loop back a copy now.
         */
        if (in6_mcast_loop) {
-               dst6->sin6_len = sizeof(struct sockaddr_in6);
-               dst6->sin6_family = AF_INET6;
-               dst6->sin6_addr = ip6->ip6_dst;
-               ip6_mloopback(ifp, m, &mifp->m6_route.ro_dst);
+               struct sockaddr_in6 dst6;
+
+               bzero(&dst6, sizeof(dst6));
+               dst6.sin6_len = sizeof(struct sockaddr_in6);
+               dst6.sin6_family = AF_INET6;
+               dst6.sin6_addr = ip6->ip6_dst;
+               ip6_mloopback(ifp, m, &dst6);
        }
 
        /*
@@ -1638,15 +1637,18 @@ phyint_send(struct ip6_hdr *ip6, struct 
         */
        linkmtu = IN6_LINKMTU(ifp);
        if (mb_copy->m_pkthdr.len <= linkmtu || linkmtu < IPV6_MMTU) {
-               dst6->sin6_len = sizeof(struct sockaddr_in6);
-               dst6->sin6_family = AF_INET6;
-               dst6->sin6_addr = ip6->ip6_dst;
+               struct sockaddr_in6 dst6;
+
+               bzero(&dst6, sizeof(dst6));
+               dst6.sin6_len = sizeof(struct sockaddr_in6);
+               dst6.sin6_family = AF_INET6;
+               dst6.sin6_addr = ip6->ip6_dst;
                /*
                 * We just call if_output instead of nd6_output here, since
                 * we need no ND for a multicast forwarded packet...right?
                 */
                error = (*ifp->if_output)(ifp, mb_copy,
-                   (struct sockaddr *)&mifp->m6_route.ro_dst, NULL);
+                   (struct sockaddr *)&dst6, NULL);
 #ifdef MRT6DEBUG
                if (V_mrt6debug & DEBUG_XMIT)
                        log(LOG_DEBUG, "phyint_send on mif %d err %d\n",

Modified: head/sys/netinet6/ip6_mroute.h
==============================================================================
--- head/sys/netinet6/ip6_mroute.h      Mon Jul  2 19:35:56 2012        
(r238015)
+++ head/sys/netinet6/ip6_mroute.h      Mon Jul  2 19:44:18 2012        
(r238016)
@@ -212,7 +212,6 @@ struct mif6 {
        u_quad_t        m6_pkt_out;     /* # pkts out on interface           */
        u_quad_t        m6_bytes_in;    /* # bytes in on interface           */
        u_quad_t        m6_bytes_out;   /* # bytes out on interface          */
-       struct route_in6 m6_route;      /* cached route */
 #ifdef notyet
        u_int           m6_rsvp_on;     /* RSVP listening on this vif */
        struct socket   *m6_rsvpd;      /* RSVP daemon socket */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to