Re: [PATCH net-next v6 7/7] net: bcmgenet: reject MTU changes incompatible with XDP

Mohsin Bashir
2026-04-06T18:30:06Z

>
> +static int bcmgenet_change_mtu(struct net_device *dev, int new_mtu)
> +{
> + struct bcmgenet_priv *priv = netdev_priv(dev);
> +
> + if (priv->xdp_prog && new_mtu > PAGE_SIZE - GENET_RX_HEADROOM -
> + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) {
> + netdev_warn(dev, "MTU too large for single-page XDP buffer\n");
> + return -EINVAL;
> + }
> +
> + WRITE_ONCE(dev->mtu, new_mtu);
> + return 0;
> +}
> +
> static const struct net_device_ops bcmgenet_netdev_ops = {
> .ndo_open = bcmgenet_open,
> .ndo_stop = bcmgenet_close,
> @@ -4102,6 +4116,7 @@ static const struct net_device_ops bcmgenet_netdev_ops = {
> .ndo_eth_ioctl = phy_do_ioctl_running,
> .ndo_set_features = bcmgenet_set_features,
> .ndo_get_stats64 = bcmgenet_get_stats64,
> + .ndo_change_mtu = bcmgenet_change_mtu,
> .ndo_change_carrier = bcmgenet_change_carrier,
> .ndo_bpf = bcmgenet_xdp,
> .ndo_xdp_xmit = bcmgenet_xdp_xmit,

Reviewed-by: Mohsin Bashir <hmohsin@meta.com>