[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1607017240-10582-1-git-send-email-loic.poulain@linaro.org>
Date: Thu, 3 Dec 2020 18:40:40 +0100
From: Loic Poulain <loic.poulain@...aro.org>
To: subashab@...eaurora.org, stranche@...eaurora.org
Cc: netdev@...r.kernel.org, kuba@...nel.org,
Loic Poulain <loic.poulain@...aro.org>
Subject: [PATCH] net: rmnet: Adjust virtual device MTU on real device capability
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 <loic.poulain@...aro.org>
---
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;
--
2.7.4
Powered by blists - more mailing lists