Subject: Re: [PATCH] net: rmnet: Adjust virtual device MTU on real device capability

From: [email-masked]
Date: Fri, 04 Dec 2020 14:56:22 -0700

On 2020-12-03 10:40, Loic Poulain wrote:
> A submitted qmap/rmnet packet size can not be larger than the linked
> interface (real_dev) MTU. This patch ensures that the rmnet virtual
> iface MTU is configured according real device capability.
> 
> Signed-off-by: Loic Poulain <[email-masked]>
> ---
>  drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> index d58b51d..d1d7328 100644
> --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
> @@ -60,9 +60,14 @@ static netdev_tx_t rmnet_vnd_start_xmit(struct 
> sk_buff
> *skb,
> 
>  static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int
> new_mtu)
>  {
> +	struct rmnet_priv *priv = netdev_priv(rmnet_dev);
> +
>  	if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE)
>  		return -EINVAL;
> 
> +	if (priv->real_dev && (new_mtu + RMNET_NEEDED_HEADROOM) >
> priv->real_dev->mtu)
> +		return -EINVAL;
> +
>  	rmnet_dev->mtu = new_mtu;
>  	return 0;
>  }
> @@ -242,6 +247,9 @@ int rmnet_vnd_newlink(u8 id, struct net_device
> *rmnet_dev,
> 
>  	priv->real_dev = real_dev;
> 
> +	/* Align default MTU with real_dev MTU */
> +	rmnet_vnd_change_mtu(rmnet_dev, real_dev->mtu -
> RMNET_NEEDED_HEADROOM);
> +
>  	rc = register_netdevice(rmnet_dev);
>  	if (!rc) {
>  		ep->egress_dev = rmnet_dev;

This would need similar checks in the NETDEV_PRECHANGEMTU
netdev notifier.