git: 33557727b593 - stable/13 - ixv: Dynamically size the receive packet size
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 29 Oct 2024 00:31:25 UTC
The branch stable/13 has been updated by kbowling:
URL: https://cgit.FreeBSD.org/src/commit/?id=33557727b5936a235506b500a57ecf8239ffae4d
commit 33557727b5936a235506b500a57ecf8239ffae4d
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:31:00 +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 fe23ea226348..7535d8c15204 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 (ifp->if_mtu > 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