From owner-dev-commits-src-all@freebsd.org Fri Apr 23 09:58:04 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B41A95EBD1B; Fri, 23 Apr 2021 09:58:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FRV8r4krxz4SDd; Fri, 23 Apr 2021 09:58:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 94CCB2D6D; Fri, 23 Apr 2021 09:58:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 13N9w4bx005048; Fri, 23 Apr 2021 09:58:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13N9w4Jf005047; Fri, 23 Apr 2021 09:58:04 GMT (envelope-from git) Date: Fri, 23 Apr 2021 09:58:04 GMT Message-Id: <202104230958.13N9w4Jf005047@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: 3183d0b68072 - main - iflib: initialize LRO unconditionally MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3183d0b68072dda0e80bb6e03c970625f2823e97 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Apr 2021 09:58:04 -0000 The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=3183d0b68072dda0e80bb6e03c970625f2823e97 commit 3183d0b68072dda0e80bb6e03c970625f2823e97 Author: Andrew Gallatin AuthorDate: 2021-04-23 09:51:22 +0000 Commit: Andrew Gallatin CommitDate: 2021-04-23 09:55:20 +0000 iflib: initialize LRO unconditionally Changes to the LRO code have exposed a bug in iflib where devices which are not capable of doing LRO are still calling tcp_lro_flush_all(), even when they have not initialized the LRO context. This used to be mostly harmless, but the LRO code now sets the VNET based on the ifp in the lro context and will try to access it through a NULL ifp resulting in a panic at boot. To fix this, we unconditionally initializes LRO so that we have a valid LRO context when calling tcp_lro_flush_all(). One alternative is to check the device capabilities before calling tcp_lro_flush_all() or adding a new state flag in the ctx. However, it seems unwise to add an extra, mostly useless test for higher performance devices when we can just initialize LRO for all devices. Reviewed by: erj, hselasky, markj, olivier Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29928 --- sys/net/iflib.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 6dbaff556a15..fc0814d0fc19 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -5891,15 +5891,13 @@ iflib_rx_structures_setup(if_ctx_t ctx) for (q = 0; q < ctx->ifc_softc_ctx.isc_nrxqsets; q++, rxq++) { #if defined(INET6) || defined(INET) - if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO) { - err = tcp_lro_init_args(&rxq->ifr_lc, ctx->ifc_ifp, - TCP_LRO_ENTRIES, min(1024, - ctx->ifc_softc_ctx.isc_nrxd[rxq->ifr_fl_offset])); - if (err != 0) { - device_printf(ctx->ifc_dev, - "LRO Initialization failed!\n"); - goto fail; - } + err = tcp_lro_init_args(&rxq->ifr_lc, ctx->ifc_ifp, + TCP_LRO_ENTRIES, min(1024, + ctx->ifc_softc_ctx.isc_nrxd[rxq->ifr_fl_offset])); + if (err != 0) { + device_printf(ctx->ifc_dev, + "LRO Initialization failed!\n"); + goto fail; } #endif IFDI_RXQ_SETUP(ctx, rxq->ifr_id); @@ -5914,8 +5912,7 @@ fail: */ rxq = ctx->ifc_rxqs; for (i = 0; i < q; ++i, rxq++) { - if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO) - tcp_lro_free(&rxq->ifr_lc); + tcp_lro_free(&rxq->ifr_lc); } return (err); #endif @@ -5938,8 +5935,7 @@ iflib_rx_structures_free(if_ctx_t ctx) iflib_dma_free(&rxq->ifr_ifdi[j]); iflib_rx_sds_free(rxq); #if defined(INET6) || defined(INET) - if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO) - tcp_lro_free(&rxq->ifr_lc); + tcp_lro_free(&rxq->ifr_lc); #endif } free(ctx->ifc_rxqs, M_IFLIB);