netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics
@ 2015-05-22 11:15 Bjørn Mork
  2015-05-22 17:22 ` Ben Hutchings
       [not found] ` <1432293322-11928-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Bjørn Mork @ 2015-05-22 11:15 UTC (permalink / raw)
  To: netdev
  Cc: Florian Bruhin, linux-usb, Oliver Neukum, Bjørn Mork,
	Ben Hutchings

The tx_curr_frame_payload field is u32. When we try to calculate a
small negative delta based on it, we end up with a positive integer
close to 2^32 instead.  So the tx_bytes pointer increases by about
2^32 for every transmitted frame.

Fix by calculating the delta as a signed long.

Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
Reported-by: Florian Bruhin <me@the-compiler.org>
Fixes: 7a1e890e2168 ("usbnet: Fix tx_bytes statistic running backward in cdc_ncm")
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
 drivers/net/usb/cdc_ncm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index c3e4da9e79ca..8067b8fbb0ee 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1182,7 +1182,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
 	 * payload data instead.
 	 */
 	usbnet_set_skb_tx_stats(skb_out, n,
-				ctx->tx_curr_frame_payload - skb_out->len);
+				(long)ctx->tx_curr_frame_payload - skb_out->len);
 
 	return skb_out;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics
  2015-05-22 11:15 [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics Bjørn Mork
@ 2015-05-22 17:22 ` Ben Hutchings
  2015-05-22 18:48   ` Bjørn Mork
       [not found] ` <1432293322-11928-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2015-05-22 17:22 UTC (permalink / raw)
  To: Bjørn Mork; +Cc: netdev, Florian Bruhin, linux-usb, Oliver Neukum

On Fri, 2015-05-22 at 13:15 +0200, Bjørn Mork wrote:
> The tx_curr_frame_payload field is u32. When we try to calculate a
> small negative delta based on it, we end up with a positive integer
> close to 2^32 instead.  So the tx_bytes pointer increases by about
> 2^32 for every transmitted frame.
> 
> Fix by calculating the delta as a signed long.

Told you I hadn't tested it.

Ben.

> Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
> Reported-by: Florian Bruhin <me@the-compiler.org>
> Fixes: 7a1e890e2168 ("usbnet: Fix tx_bytes statistic running backward in cdc_ncm")
> Signed-off-by: Bjørn Mork <bjorn@mork.no>
> ---
>  drivers/net/usb/cdc_ncm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index c3e4da9e79ca..8067b8fbb0ee 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -1182,7 +1182,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
>  	 * payload data instead.
>  	 */
>  	usbnet_set_skb_tx_stats(skb_out, n,
> -				ctx->tx_curr_frame_payload - skb_out->len);
> +				(long)ctx->tx_curr_frame_payload - skb_out->len);
>  
>  	return skb_out;
>  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics
       [not found] ` <1432293322-11928-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
@ 2015-05-22 18:34   ` David Miller
       [not found]     ` <20150522.143421.442426385899149301.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2015-05-22 18:34 UTC (permalink / raw)
  To: bjorn-yOkvZcmFvRU
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, me-J2duszcpOy900TDglC2tyg,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, oliver-GvhC2dPhHPQdnm+yROfE0A,
	ben.hutchings-4yDnlxn2s6sWdaTGBSpHTA

From: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
Date: Fri, 22 May 2015 13:15:22 +0200

> The tx_curr_frame_payload field is u32. When we try to calculate a
> small negative delta based on it, we end up with a positive integer
> close to 2^32 instead.  So the tx_bytes pointer increases by about
> 2^32 for every transmitted frame.
> 
> Fix by calculating the delta as a signed long.
> 
> Cc: Ben Hutchings <ben.hutchings-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
> Reported-by: Florian Bruhin <me-J2duszcpOy900TDglC2tyg@public.gmane.org>
> Fixes: 7a1e890e2168 ("usbnet: Fix tx_bytes statistic running backward in cdc_ncm")
> Signed-off-by: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>

Applied and queued up for -stable.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics
  2015-05-22 17:22 ` Ben Hutchings
@ 2015-05-22 18:48   ` Bjørn Mork
  0 siblings, 0 replies; 5+ messages in thread
From: Bjørn Mork @ 2015-05-22 18:48 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: netdev, Florian Bruhin, linux-usb, Oliver Neukum



On 22 May 2015 19:22:47 CEST, Ben Hutchings <ben.hutchings@codethink.co.uk> wrote:
>On Fri, 2015-05-22 at 13:15 +0200, Bjørn Mork wrote:
>> The tx_curr_frame_payload field is u32. When we try to calculate a
>> small negative delta based on it, we end up with a positive integer
>> close to 2^32 instead.  So the tx_bytes pointer increases by about
>> 2^32 for every transmitted frame.
>> 
>> Fix by calculating the delta as a signed long.
>
>Told you I hadn't tested it.


Yes, I know. This was all my bad. Sorry. Didn't mean to imply that you were to blame here. On the contrary. Thanks again for showing how to solve this.


Bjørn

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics
       [not found]     ` <20150522.143421.442426385899149301.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2015-05-23  9:27       ` Florian Bruhin
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Bruhin @ 2015-05-23  9:27 UTC (permalink / raw)
  To: David Miller
  Cc: bjorn-yOkvZcmFvRU, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA, oliver-GvhC2dPhHPQdnm+yROfE0A,
	ben.hutchings-4yDnlxn2s6sWdaTGBSpHTA

[-- Attachment #1: Type: text/plain, Size: 1147 bytes --]

* David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org> [2015-05-22 14:34:21 -0400]:
> From: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
> Date: Fri, 22 May 2015 13:15:22 +0200
> 
> > The tx_curr_frame_payload field is u32. When we try to calculate a
> > small negative delta based on it, we end up with a positive integer
> > close to 2^32 instead.  So the tx_bytes pointer increases by about
> > 2^32 for every transmitted frame.
> > 
> > Fix by calculating the delta as a signed long.
> > 
> > Cc: Ben Hutchings <ben.hutchings-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
> > Reported-by: Florian Bruhin <me-J2duszcpOy900TDglC2tyg@public.gmane.org>
> > Fixes: 7a1e890e2168 ("usbnet: Fix tx_bytes statistic running backward in cdc_ncm")
> > Signed-off-by: Bjørn Mork <bjorn-yOkvZcmFvRU@public.gmane.org>
> 
> Applied and queued up for -stable.

Thank you, and thanks Bjørn for the quick fix!

Florian

-- 
http://www.the-compiler.org | me-J2duszcpOy900TDglC2tyg@public.gmane.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-23  9:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 11:15 [PATCH net,stable-4.0] cdc_ncm: Fix tx_bytes statistics Bjørn Mork
2015-05-22 17:22 ` Ben Hutchings
2015-05-22 18:48   ` Bjørn Mork
     [not found] ` <1432293322-11928-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2015-05-22 18:34   ` David Miller
     [not found]     ` <20150522.143421.442426385899149301.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-05-23  9:27       ` Florian Bruhin

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).