From: Robert Dobrowolski <robert.dobrowolski@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: robert.dobrowolski@linux.intel.com, stable@vger.kernel.org,
oliver@neukum.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Rafal Redzimski <rafal.f.redzimski@intel.com>
Subject: [PATCH net,stable v2] net: cdc_ncm: update datagram size after changing mtu
Date: Thu, 19 May 2016 11:56:09 +0200 [thread overview]
Message-ID: <1463651769-27513-1-git-send-email-robert.dobrowolski@linux.intel.com> (raw)
From: Rafal Redzimski <rafal.f.redzimski@intel.com>
Current implementation updates the mtu size and notify cdc_ncm
device using USB_CDC_SET_MAX_DATAGRAM_SIZE request about datagram
size change instead of changing rx_urb_size.
Whenever mtu is being changed, datagram size should also be
updated. Also updating maxmtu formula so it takes max_datagram_size with
use of cdc_ncm_max_dgram_size() and not ctx.
Signed-off-by: Robert Dobrowolski <robert.dobrowolski@linux.intel.com>
Signed-off-by: Rafal Redzimski <rafal.f.redzimski@intel.com>
---
Changes in v2:
- Changed the way maxmtu is being calculated. Its now based
on cdc_ncm_max_dgram_size and not on ctx->max_datagram_size.
New datagram size is calculated correctly.
drivers/net/usb/cdc_ncm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 2fb31ed..53759c3 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -740,12 +740,14 @@ static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
int cdc_ncm_change_mtu(struct net_device *net, int new_mtu)
{
struct usbnet *dev = netdev_priv(net);
- struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
- int maxmtu = ctx->max_datagram_size - cdc_ncm_eth_hlen(dev);
+ int maxmtu = cdc_ncm_max_dgram_size(dev) - cdc_ncm_eth_hlen(dev);
if (new_mtu <= 0 || new_mtu > maxmtu)
return -EINVAL;
+
net->mtu = new_mtu;
+ cdc_ncm_set_dgram_size(dev, new_mtu + cdc_ncm_eth_hlen(dev));
+
return 0;
}
EXPORT_SYMBOL_GPL(cdc_ncm_change_mtu);
--
1.9.1
next reply other threads:[~2016-05-19 9:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 9:56 Robert Dobrowolski [this message]
2016-05-19 18:22 ` [PATCH net,stable v2] net: cdc_ncm: update datagram size after changing mtu Bjørn Mork
2016-05-20 23:32 ` David Miller
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=1463651769-27513-1-git-send-email-robert.dobrowolski@linux.intel.com \
--to=robert.dobrowolski@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oliver@neukum.org \
--cc=rafal.f.redzimski@intel.com \
--cc=stable@vger.kernel.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).