Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 May 2015 06:48:37 +0000 (UTC)
From:      Andrew Rybchenko <arybchik@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r282940 - head/sys/dev/sfxge
Message-ID:  <201505150648.t4F6mbtN042682@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arybchik
Date: Fri May 15 06:48:36 2015
New Revision: 282940
URL: https://svnweb.freebsd.org/changeset/base/282940

Log:
  sfxge: LRO may be done only if checksums are OK
  
  Also it is cheaper to check Rx descriptor flags than TCP protocol in IP
  header.
  
  Reviewed by:    gnn
  Sponsored by:   Solarflare Communications, Inc.
  MFC after:      2 days
  Differential Revision: https://reviews.freebsd.org/D2542

Modified:
  head/sys/dev/sfxge/sfxge_rx.c

Modified: head/sys/dev/sfxge/sfxge_rx.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_rx.c	Fri May 15 06:11:47 2015	(r282939)
+++ head/sys/dev/sfxge/sfxge_rx.c	Fri May 15 06:48:36 2015	(r282940)
@@ -688,15 +688,18 @@ sfxge_lro(struct sfxge_rxq *rxq, struct 
 	 */
 	if (l3_proto == htons(ETHERTYPE_IP)) {
 		struct ip *iph = nh;
-		if ((iph->ip_p - IPPROTO_TCP) |
-		    (iph->ip_hl - (sizeof(*iph) >> 2u)) |
+
+		KASSERT(iph->ip_p == IPPROTO_TCP,
+		    ("IPv4 protocol is not TCP, but packet marker is set"));
+		if ((iph->ip_hl - (sizeof(*iph) >> 2u)) |
 		    (iph->ip_off & htons(IP_MF | IP_OFFMASK)))
 			goto deliver_now;
 		th = (struct tcphdr *)(iph + 1);
 	} else if (l3_proto == htons(ETHERTYPE_IPV6)) {
 		struct ip6_hdr *iph = nh;
-		if (iph->ip6_nxt != IPPROTO_TCP)
-			goto deliver_now;
+
+		KASSERT(iph->ip6_nxt == IPPROTO_TCP,
+		    ("IPv6 next header is not TCP, but packet marker is set"));
 		l2_id |= SFXGE_LRO_L2_ID_IPV6;
 		th = (struct tcphdr *)(iph + 1);
 	} else {
@@ -841,7 +844,9 @@ sfxge_rx_qcomplete(struct sfxge_rxq *rxq
 
 		/* Pass packet up the stack or into LRO (pipelined) */
 		if (prev != NULL) {
-			if (lro_enabled)
+			if (lro_enabled &&
+			    ((prev->flags & (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)) ==
+			     (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)))
 				sfxge_lro(rxq, prev);
 			else
 				sfxge_rx_deliver(sc, prev);
@@ -860,7 +865,9 @@ discard:
 
 	/* Pass last packet up the stack or into LRO */
 	if (prev != NULL) {
-		if (lro_enabled)
+		if (lro_enabled &&
+		    ((prev->flags & (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)) ==
+		     (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)))
 			sfxge_lro(rxq, prev);
 		else
 			sfxge_rx_deliver(sc, prev);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505150648.t4F6mbtN042682>