Date: Mon, 21 Jul 2008 23:21:50 GMT From: Navdeep Parhar <nparhar@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/125845: tcp_lro_rx() should make use of hardware IP cksum assistance when available Message-ID: <200807212321.m6LNLobv019016@www.freebsd.org> Resent-Message-ID: <200807212330.m6LNU2mR000473@freefall.freebsd.org>
index | next in thread | raw e-mail
>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:
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807212321.m6LNLobv019016>
