Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Oct 2024 00:29:29 GMT
From:      Kevin Bowling <kbowling@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 9679df8eea14 - stable/14 - ixv: Dynamically size the receive packet size
Message-ID:  <202410290029.49T0TTng073185@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kbowling:

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

commit 9679df8eea14a5f707aa870328d9bb211f12c570
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2024-10-26 21:34:30 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2024-10-29 00:29:03 +0000

    ixv: Dynamically size the receive packet size
    
    If MTU of the if_ixv VF driver is configured between 1501 and 2030, and
    if a peer box have bigger MTU and sends a packet bigger than MTU into
    this guest, kernel could crash.
    
    Dynamically calculate the receive packet size on rx_mbuf_sz as ix(4)
    does.
    
    PR:             268092
    Reported by:    Kumara Babu <nkumarababu@gmail.com>
    Sponsored by:   BBOX.io
    
    (cherry picked from commit cdbe3de5383706da0f6d3c29f1ec2dcfed366bf1)
---
 sys/dev/ixgbe/if_ixv.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c
index 66a1e4fe2df1..d5fe1a5c6b30 100644
--- a/sys/dev/ixgbe/if_ixv.c
+++ b/sys/dev/ixgbe/if_ixv.c
@@ -1363,7 +1363,7 @@ ixv_initialize_rss_mapping(struct ixgbe_softc *sc)
 	IXGBE_WRITE_REG(hw, IXGBE_VFMRQC, mrqc);
 } /* ixv_initialize_rss_mapping */
 
-
+#define BSIZEPKT_ROUNDUP ((1<<IXGBE_SRRCTL_BSIZEPKT_SHIFT)-1)
 /************************************************************************
  * ixv_initialize_receive_units - Setup receive registers and features.
  ************************************************************************/
@@ -1377,10 +1377,8 @@ ixv_initialize_receive_units(if_ctx_t ctx)
 	struct ix_rx_queue *que = sc->rx_queues;
 	u32                bufsz, psrtype;
 
-	if (if_getmtu(ifp) > ETHERMTU)
-		bufsz = 4096 >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
-	else
-		bufsz = 2048 >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
+	bufsz = (sc->rx_mbuf_sz + BSIZEPKT_ROUNDUP) >>
+	    IXGBE_SRRCTL_BSIZEPKT_SHIFT;
 
 	psrtype = IXGBE_PSRTYPE_TCPHDR
 	        | IXGBE_PSRTYPE_UDPHDR



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