git: 8f7d9587664a - stable/13 - cxgbe(4): Do not panic when tx is called with invalid checksum requests.

Navdeep Parhar np at FreeBSD.org
Sun May 16 03:45:44 UTC 2021


The branch stable/13 has been updated by np:

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

commit 8f7d9587664af630fedc1a3b91f8ca22dd55f51b
Author:     Navdeep Parhar <np at FreeBSD.org>
AuthorDate: 2021-04-28 20:45:58 +0000
Commit:     Navdeep Parhar <np at FreeBSD.org>
CommitDate: 2021-05-16 03:44:46 +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.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit b9820bca183aba6c0c03a8b717bedd24da7428da)
---
 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 68b5ed812096..c09ba29213a1 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -2712,6 +2712,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.
@@ -2863,9 +2866,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)) {
@@ -2901,10 +2909,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)) {


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