From owner-svn-src-stable@FreeBSD.ORG Sun Jul 8 11:57:12 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5D5E8106568B; Sun, 8 Jul 2012 11:57:12 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 47EF28FC0C; Sun, 8 Jul 2012 11:57:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q68BvC1i049555; Sun, 8 Jul 2012 11:57:12 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q68BvCGX049553; Sun, 8 Jul 2012 11:57:12 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201207081157.q68BvCGX049553@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sun, 8 Jul 2012 11:57:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238235 - stable/9/sys/netinet6 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 11:57:12 -0000 Author: bz Date: Sun Jul 8 11:57:11 2012 New Revision: 238235 URL: http://svn.freebsd.org/changeset/base/238235 Log: MFC r235959: 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. Approved by: re Modified: stable/9/sys/netinet6/udp6_usrreq.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/udp6_usrreq.c ============================================================================== --- stable/9/sys/netinet6/udp6_usrreq.c Sun Jul 8 11:53:13 2012 (r238234) +++ stable/9/sys/netinet6/udp6_usrreq.c Sun Jul 8 11:57:11 2012 (r238235) @@ -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;