Re: [PATCH 5/7] net/nfb: support setting Rx MTU

Stephen Hemminger
2026-02-18T18:21:04Z

On Fri, 6 Feb 2026 18:04:33 +0100
spinler@cesnet.cz wrote:

> +static int
> +nfb_eth_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
> +{
> + unsigned int i;
> + struct nc_rxmac_status status;
> + struct pmd_internals *intl = dev->process_private;
> + uint16_t frame_length_max_capable;
> +
> + mtu += RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
> +

Since mtu is 16 bit value, you need to use uint32_t to avoid
overflow.

Something like:
+ uint32_t frame_len = (uint32_t)mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+ if (frame_len > priv->frame_len_max_cap)
+ return -EINVAL;

+ for (i = 0; i < intl->max_rxmac; ++i)
+ nc_rxmac_set_frame_length(intl->rxmac[i], frame_len, RXMAC_FRAME_LENGTH_MAX);