Author: bz
Date: Fri May 25 02:19:17 2012
New Revision: 235959
URL: http://svn.freebsd.org/changeset/base/235959

Log:
  MFp4 bz_ipv6_fast:
  
    Defer checksum calulations on UDP6 output and respect the mbuf
    flags set by NICs having done checksum validation for us already,
    thus saving the computing time in the input path as well.
  
    Sponsored by:       The FreeBSD Foundation
    Sponsored by:       iXsystems
  
  Reviewed by:  gnn (as part of the whole)
  MFC After:    3 days

Modified:
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet6/udp6_usrreq.c
==============================================================================
--- head/sys/netinet6/udp6_usrreq.c     Fri May 25 02:17:16 2012        
(r235958)
+++ head/sys/netinet6/udp6_usrreq.c     Fri May 25 02:19:17 2012        
(r235959)
@@ -185,6 +185,7 @@ udp6_input(struct mbuf **mp, int *offp, 
 #ifdef IPFIREWALL_FORWARD
        struct m_tag *fwd_tag;
 #endif
+       uint16_t uh_sum;
 
        ifp = m->m_pkthdr.rcvif;
        ip6 = mtod(m, struct ip6_hdr *);
@@ -228,7 +229,18 @@ udp6_input(struct mbuf **mp, int *offp, 
                UDPSTAT_INC(udps_nosum);
                goto badunlocked;
        }
-       if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) {
+
+       if (m->m_pkthdr.csum_flags & CSUM_DATA_VALID) {
+               if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR)
+                       uh_sum = m->m_pkthdr.csum_data;
+               else
+                       uh_sum = in6_cksum_pseudo(ip6, ulen,
+                           IPPROTO_UDP, m->m_pkthdr.csum_data);
+               uh_sum ^= 0xffff;
+       } else
+               uh_sum = in6_cksum(m, IPPROTO_UDP, off, ulen);
+
+       if (uh_sum != 0) {
                UDPSTAT_INC(udps_badsum);
                goto badunlocked;
        }
@@ -771,10 +783,9 @@ udp6_output(struct inpcb *inp, struct mb
                ip6->ip6_src    = *laddr;
                ip6->ip6_dst    = *faddr;
 
-               if ((udp6->uh_sum = in6_cksum(m, IPPROTO_UDP,
-                               sizeof(struct ip6_hdr), plen)) == 0) {
-                       udp6->uh_sum = 0xffff;
-               }
+               udp6->uh_sum = in6_cksum_pseudo(ip6, plen, IPPROTO_UDP, 0);
+               m->m_pkthdr.csum_flags = CSUM_UDP;
+               m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum);
 
                flags = 0;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to