netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Loic Poulain <loic.poulain@linaro.org>
To: subashab@codeaurora.org, stranche@codeaurora.org
Cc: netdev@vger.kernel.org, kuba@kernel.org,
	Loic Poulain <loic.poulain@linaro.org>
Subject: [PATCH] net: rmnet: Adjust virtual device MTU on real device capability
Date: Thu,  3 Dec 2020 18:40:40 +0100	[thread overview]
Message-ID: <1607017240-10582-1-git-send-email-loic.poulain@linaro.org> (raw)

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@linaro.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


             reply	other threads:[~2020-12-03 17:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 17:40 Loic Poulain [this message]
2020-12-04 21:56 ` [PATCH] net: rmnet: Adjust virtual device MTU on real device capability subashab
2020-12-07 16:45   ` Loic Poulain
2020-12-07 20:16     ` Jakub Kicinski
2020-12-08  8:19       ` subashab
2020-12-08 14:50         ` Loic Poulain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1607017240-10582-1-git-send-email-loic.poulain@linaro.org \
    --to=loic.poulain@linaro.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stranche@codeaurora.org \
    --cc=subashab@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).