From owner-dev-commits-src-all@freebsd.org Wed Apr 28 23:41:49 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 0D8BC6254D2; Wed, 28 Apr 2021 23:41:49 +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 4FVwC071B8z3hK5; Wed, 28 Apr 2021 23:41:48 +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 E3C1B1648A; Wed, 28 Apr 2021 23:41:48 +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 13SNfmBN091921; Wed, 28 Apr 2021 23:41:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13SNfm6I091920; Wed, 28 Apr 2021 23:41:48 GMT (envelope-from git) Date: Wed, 28 Apr 2021 23:41:48 GMT Message-Id: <202104282341.13SNfm6I091920@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Navdeep Parhar Subject: git: b9820bca183a - main - cxgbe(4): Do not panic when tx is called with invalid checksum requests. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: np X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b9820bca183aba6c0c03a8b717bedd24da7428da 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: Wed, 28 Apr 2021 23:41:49 -0000 The branch main has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=b9820bca183aba6c0c03a8b717bedd24da7428da commit b9820bca183aba6c0c03a8b717bedd24da7428da Author: Navdeep Parhar AuthorDate: 2021-04-28 20:45:58 +0000 Commit: Navdeep Parhar CommitDate: 2021-04-28 21:04:53 +0000 cxgbe(4): Do not panic when tx is called with invalid checksum requests. There is no need to panic in if_transmit if the checksums requested are inconsistent with the frame being transmitted. This typically indicates that the kernel and driver were built with different INET/INET6 options, or there is some other kernel bug. The driver should just throw away the requests that it doesn't understand and move on. MFC after: 1 week Sponsored by: Chelsio Communications --- sys/dev/cxgbe/t4_sge.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 93e19f43d2bc..2f6c7e2e7914 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -2652,6 +2652,9 @@ max_nsegs_allowed(struct mbuf *m, bool vm_wr) return (TX_SGL_SEGS); } +static struct timeval txerr_ratecheck = {0}; +static const struct timeval txerr_interval = {3, 0}; + /* * Analyze the mbuf to determine its tx needs. The mbuf passed in may change: * a) caller can assume it's been freed if this function returns with an error. @@ -2803,9 +2806,14 @@ restart: } #endif default: - panic("%s: ethertype 0x%04x unknown. if_cxgbe must be compiled" - " with the same INET/INET6 options as the kernel.", - __func__, eh_type); + if (ratecheck(&txerr_ratecheck, &txerr_interval)) { + log(LOG_ERR, "%s: ethertype 0x%04x unknown. " + "if_cxgbe must be compiled with the same " + "INET/INET6 options as the kernel.\n", __func__, + eh_type); + } + rc = EINVAL; + goto fail; } if (needs_vxlan_csum(m0)) { @@ -2841,10 +2849,15 @@ restart: } #endif default: - panic("%s: VXLAN hw offload requested with unknown " - "ethertype 0x%04x. if_cxgbe must be compiled" - " with the same INET/INET6 options as the kernel.", - __func__, eh_type); + if (ratecheck(&txerr_ratecheck, &txerr_interval)) { + log(LOG_ERR, "%s: VXLAN hw offload requested" + "with unknown ethertype 0x%04x. if_cxgbe " + "must be compiled with the same INET/INET6 " + "options as the kernel.\n", __func__, + eh_type); + } + rc = EINVAL; + goto fail; } #if defined(INET) || defined(INET6) if (needs_inner_tcp_csum(m0)) {