kern/125845: tcp_lro_rx() should make use of hardware IP cksum
assistance when available
Navdeep Parhar
nparhar at gmail.com
Mon Jul 21 23:30:03 UTC 2008
>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 at 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:
More information about the freebsd-bugs
mailing list