git: a9b66dbd9169 - main - Allow the tcp_lro_flush_all() function to be called when the control structure is zeroed, by setting the VNET after checking the mbuf count for zero. It appears there are some cases with early interrupts on some network devices which still trigger page-faults on accessing a NULL "ifp" pointer before the TCP LRO control structure has been initialized. This basically preserves the old behaviour, prior to 9ca874cf740ee68c5742df8b5f9e20910085c011 .

Hans Petter Selasky hselasky at FreeBSD.org
Sat Apr 24 10:27:18 UTC 2021


The branch main has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=a9b66dbd9169f102dea92ad369a09c0d20cdb41f

commit a9b66dbd9169f102dea92ad369a09c0d20cdb41f
Author:     Hans Petter Selasky <hselasky at FreeBSD.org>
AuthorDate: 2021-04-24 10:20:33 +0000
Commit:     Hans Petter Selasky <hselasky at FreeBSD.org>
CommitDate: 2021-04-24 10:23:42 +0000

    Allow the tcp_lro_flush_all() function to be called when the control
    structure is zeroed, by setting the VNET after checking the mbuf count
    for zero. It appears there are some cases with early interrupts on some
    network devices which still trigger page-faults on accessing a NULL "ifp"
    pointer before the TCP LRO control structure has been initialized.
    This basically preserves the old behaviour, prior to
    9ca874cf740ee68c5742df8b5f9e20910085c011 .
    
    No functional change.
    
    Reported by:    rscheff@
    Differential Revision:  https://reviews.freebsd.org/D29564
    MFC after:      2 weeks
    Sponsored by:   Mellanox Technologies // NVIDIA Networking
---
 sys/netinet/tcp_lro.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/sys/netinet/tcp_lro.c b/sys/netinet/tcp_lro.c
index 61c6f218e513..09fc024c3d73 100644
--- a/sys/netinet/tcp_lro.c
+++ b/sys/netinet/tcp_lro.c
@@ -1439,12 +1439,12 @@ tcp_lro_flush_all(struct lro_ctrl *lc)
 	uint64_t nseq;
 	unsigned x;
 
-	CURVNET_SET(lc->ifp->if_vnet);
-
 	/* check if no mbufs to flush */
 	if (lc->lro_mbuf_count == 0)
 		goto done;
 
+	CURVNET_SET(lc->ifp->if_vnet);
+
 	/* get current time */
 	lc->lro_last_queue_time = getsbinuptime();
 
@@ -1478,13 +1478,12 @@ tcp_lro_flush_all(struct lro_ctrl *lc)
 			lc->lro_flushed++;
 		}
 	}
+	CURVNET_RESTORE();
 done:
 	/* flush active streams */
 	tcp_lro_rx_done(lc);
 
 	lc->lro_mbuf_count = 0;
-
-	CURVNET_RESTORE();
 }
 
 #ifdef TCPHPTS


More information about the dev-commits-src-all mailing list