From owner-freebsd-bugs@FreeBSD.ORG Mon Jul 21 23:30:03 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03381106567A for ; Mon, 21 Jul 2008 23:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CC0558FC15 for ; Mon, 21 Jul 2008 23:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m6LNU23e000481 for ; Mon, 21 Jul 2008 23:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m6LNU2mR000473; Mon, 21 Jul 2008 23:30:02 GMT (envelope-from gnats) Resent-Date: Mon, 21 Jul 2008 23:30:02 GMT Resent-Message-Id: <200807212330.m6LNU2mR000473@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Navdeep Parhar Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 88AD31065670 for ; Mon, 21 Jul 2008 23:21:50 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 6F9098FC19 for ; Mon, 21 Jul 2008 23:21:50 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m6LNLo36019017 for ; Mon, 21 Jul 2008 23:21:50 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m6LNLobv019016; Mon, 21 Jul 2008 23:21:50 GMT (envelope-from nobody) Message-Id: <200807212321.m6LNLobv019016@www.freebsd.org> Date: Mon, 21 Jul 2008 23:21:50 GMT From: Navdeep Parhar To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/125845: tcp_lro_rx() should make use of hardware IP cksum assistance when available X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jul 2008 23:30:03 -0000 >Number: 125845 >Category: kern >Synopsis: tcp_lro_rx() should make use of hardware IP cksum assistance when available >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jul 21 23:30:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Navdeep Parhar >Release: HEAD 8-CURRENT >Organization: Chelsio Communications >Environment: FreeBSD pepper 8.0-CURRENT FreeBSD 8.0-CURRENT #29: Mon Jul 21 15:31:40 PDT 2008 root@pepper:/usr/obj/usr/src/sys/GENERIC amd64 >Description: tcp_lro_rx() in sys/netinet/tcp_lro.c calculates the IP checksum of all non-fragmented TCP packets while determining whether they can be queued for LRO. Some optimization is possible here if the hardware has already verified the IP checksum - just take CSUM_IP_CHECKED and CSUM_IP_VALID into account before doing the checksum in software. >How-To-Repeat: N/A. Problem was discovered while reading the code. >Fix: Patch attached. Patch attached with submission follows: diff -r cdbabca8841b sys/netinet/tcp_lro.c --- a/sys/netinet/tcp_lro.c Mon Jul 21 14:29:19 2008 -0700 +++ b/sys/netinet/tcp_lro.c Mon Jul 21 16:19:38 2008 -0700 @@ -186,6 +186,7 @@ int hlen, ip_len, tcp_hdr_len, tcp_data_len, tot_len; int opt_bytes, trim; uint32_t seq, tmp_csum, device_mtu; + int csum_flags; eh = mtod(m_head, struct ether_header *); @@ -204,10 +205,18 @@ return -1; /* verify that the IP header checksum is correct */ - tmp_csum = do_csum_data((uint16_t *)ip, sizeof (*ip)); - if (__predict_false((tmp_csum ^ 0xffff) != 0)) { - cntl->lro_bad_csum++; - return -1; + csum_flags = m_head->m_pkthdr.csum_flags; + if (csum_flags & CSUM_IP_CHECKED) { + if (__predict_false((csum_flags & CSUM_IP_VALID) == 0)) { + cntl->lro_bad_csum++; + return -1; + } + } else { + tmp_csum = do_csum_data((uint16_t *)ip, sizeof (*ip)); + if (__predict_false((tmp_csum ^ 0xffff) != 0)) { + cntl->lro_bad_csum++; + return -1; + } } /* find the TCP header */ >Release-Note: >Audit-Trail: >Unformatted: