From owner-svn-src-all@freebsd.org Thu Apr 13 17:03:58 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DBDA0D3B0BE; Thu, 13 Apr 2017 17:03:58 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 92912C50; Thu, 13 Apr 2017 17:03:58 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3DH3ve2037563; Thu, 13 Apr 2017 17:03:57 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3DH3v4P037561; Thu, 13 Apr 2017 17:03:57 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201704131703.v3DH3v4P037561@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 13 Apr 2017 17:03:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316770 - in head/sys: netinet netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Apr 2017 17:03:59 -0000 Author: ae Date: Thu Apr 13 17:03:57 2017 New Revision: 316770 URL: https://svnweb.freebsd.org/changeset/base/316770 Log: Clear h/w csum flags on mbuf handled by UDP. When checksums of received IP and UDP header already checked, UDP uses sbappendaddr_locked() to pass received data to the socket. sbappendaddr_locked() uses given mbuf as is, and if NIC supports checksum offloading, mbuf contains csum_data and csum_flags that were calculated for already stripped headers. Some NICs support only limited checksums offloading and do not use CSUM_PSEUDO_HDR flag, and csum_data contains some value that UDP/TCP should use for pseudo header checksum calculation. When L2TP is used for tunneling with mpd5, ng_ksocket receives mbuf with filled csum_flags and csum_data, that were calculated for outer headers. When L2TP header is stripped, a packet that was tunneled goes to the IP layer and due to presence of csum_flags (without CSUM_PSEUDO_HDR) and csum_data, the UDP/TCP checksum check fails for this packet. Reported by: Irina Liakh Tested by: Irina Liakh MFC after: 1 week Modified: head/sys/netinet/udp_usrreq.c head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet/udp_usrreq.c ============================================================================== --- head/sys/netinet/udp_usrreq.c Thu Apr 13 16:57:02 2017 (r316769) +++ head/sys/netinet/udp_usrreq.c Thu Apr 13 17:03:57 2017 (r316770) @@ -372,6 +372,9 @@ udp_append(struct inpcb *inp, struct ip append_sa = (struct sockaddr *)&udp_in[0]; m_adj(n, off); + /* Clear any h/w csum flags as they are no longer valid. */ + n->m_pkthdr.csum_flags &= ~(CSUM_DATA_VALID | CSUM_IP_VALID); + so = inp->inp_socket; SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) { Modified: head/sys/netinet6/udp6_usrreq.c ============================================================================== --- head/sys/netinet6/udp6_usrreq.c Thu Apr 13 16:57:02 2017 (r316769) +++ head/sys/netinet6/udp6_usrreq.c Thu Apr 13 17:03:57 2017 (r316770) @@ -187,6 +187,9 @@ udp6_append(struct inpcb *inp, struct mb } m_adj(n, off + sizeof(struct udphdr)); + /* Clear any h/w csum flags as they are no longer valid. */ + n->m_pkthdr.csum_flags &= ~CSUM_DATA_VALID; + so = inp->inp_socket; SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)&fromsa[0], n,