diff options
author | Kevin Bowling <kbowling@FreeBSD.org> | 2024-10-26 21:34:30 +0000 |
---|---|---|
committer | Kevin Bowling <kbowling@FreeBSD.org> | 2024-10-26 21:36:48 +0000 |
commit | cdbe3de5383706da0f6d3c29f1ec2dcfed366bf1 (patch) | |
tree | f593fe34e806b1a57ee60d3c278f10c790575f09 | |
parent | 5fa2e50ea4386bf277bb840e821c63f314c9a431 (diff) | |
download | src-cdbe3de53837.tar.gz src-cdbe3de53837.zip |
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>
MFC after: 3 days
Sponsored by: BBOX.io
-rw-r--r-- | sys/dev/ixgbe/if_ixv.c | 8 |
1 files 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 |