All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usbnet: fix oops in usbnet_start_xmit
@ 2011-11-06 19:33 Konstantin Khlebnikov
  2011-11-07 13:29 ` Michael Riesch
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Konstantin Khlebnikov @ 2011-11-06 19:33 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: netdev, David S. Miller, devel, Michael Riesch

This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
SKB can be NULL at this point, at least for cdc-ncm.
Let's call skb_tx_timestamp() after driver specific tx-fixup hacks.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
 drivers/net/usb/usbnet.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 7d60821..485be70 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1057,8 +1057,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
 	unsigned long		flags;
 	int retval;
 
-	skb_tx_timestamp(skb);
-
 	// some devices want funky USB-level framing, for
 	// win32 driver (usually) and/or hardware quirks
 	if (info->tx_fixup) {
@@ -1075,6 +1073,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
 	}
 	length = skb->len;
 
+	skb_tx_timestamp(skb);
+
 	if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
 		netif_dbg(dev, tx_err, dev->net, "no urb\n");
 		goto drop;

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

* Re: [PATCH] usbnet: fix oops in usbnet_start_xmit
  2011-11-06 19:33 [PATCH] usbnet: fix oops in usbnet_start_xmit Konstantin Khlebnikov
@ 2011-11-07 13:29 ` Michael Riesch
  2011-11-07 13:33 ` Richard Cochran
  2011-11-07 15:54 ` [PATCH v2] " Konstantin Khlebnikov
  2 siblings, 0 replies; 8+ messages in thread
From: Michael Riesch @ 2011-11-07 13:29 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: Oliver Neukum, netdev, David S. Miller, devel


On Sun, 2011-11-06 at 22:33 +0300, Konstantin Khlebnikov wrote:
> This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
> SKB can be NULL at this point, at least for cdc-ncm.

OK, I didn't think of that, but...

> Let's call skb_tx_timestamp() after driver specific tx-fixup hacks.

... the reason I put the skb_tx_timestamp() call before the tx_fixup is
that these hacks often perform skb_push/skb_pull or any other kind of
framing. This may result (at least in the case of the asix drivers) in
perfectly correct PTP packets being not recognized as such by the packet
filter.

Can we do a check like this:
	if(skb) skb_tx_timestamp()
	tx_fixup()
?

Regards, Michael

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

* Re: [PATCH] usbnet: fix oops in usbnet_start_xmit
  2011-11-06 19:33 [PATCH] usbnet: fix oops in usbnet_start_xmit Konstantin Khlebnikov
  2011-11-07 13:29 ` Michael Riesch
@ 2011-11-07 13:33 ` Richard Cochran
  2011-11-07 14:05   ` Konstantin Khlebnikov
  2011-11-07 15:54 ` [PATCH v2] " Konstantin Khlebnikov
  2 siblings, 1 reply; 8+ messages in thread
From: Richard Cochran @ 2011-11-07 13:33 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Oliver Neukum, netdev, David S. Miller, devel, Michael Riesch

On Sun, Nov 06, 2011 at 10:33:37PM +0300, Konstantin Khlebnikov wrote:
> This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
> SKB can be NULL at this point, at least for cdc-ncm.

What? You mean .ndo_start_xmit is called with skb NULL?

> Let's call skb_tx_timestamp() after driver specific tx-fixup hacks.

No, that won't work.

That call is before the fixup on purpose, because some fixups add
padding in front of the Ethernet payload, and this will spoil the PTP
packet detection filter.

I don't know why the skb can be NULL here. If that is really the case,
then the correct fix is:

	if (skb)
		skb_tx_timestamp(skb);

Thanks,
Richard


> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> ---
>  drivers/net/usb/usbnet.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 7d60821..485be70 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -1057,8 +1057,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
>  	unsigned long		flags;
>  	int retval;
>  
> -	skb_tx_timestamp(skb);
> -
>  	// some devices want funky USB-level framing, for
>  	// win32 driver (usually) and/or hardware quirks
>  	if (info->tx_fixup) {
> @@ -1075,6 +1073,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
>  	}
>  	length = skb->len;
>  
> +	skb_tx_timestamp(skb);
> +
>  	if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
>  		netif_dbg(dev, tx_err, dev->net, "no urb\n");
>  		goto drop;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] usbnet: fix oops in usbnet_start_xmit
  2011-11-07 13:33 ` Richard Cochran
@ 2011-11-07 14:05   ` Konstantin Khlebnikov
  2011-11-07 14:42     ` Richard Cochran
  0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Khlebnikov @ 2011-11-07 14:05 UTC (permalink / raw)
  To: Richard Cochran
  Cc: Oliver Neukum, netdev, David S. Miller, devel, Michael Riesch

Richard Cochran wrote:
> On Sun, Nov 06, 2011 at 10:33:37PM +0300, Konstantin Khlebnikov wrote:
>> This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
>> SKB can be NULL at this point, at least for cdc-ncm.
>
> What? You mean .ndo_start_xmit is called with skb NULL?

no. cdc_ncm call usbnet_start_xmit with NULL skb from timer handler
and tx_fixup hook pickup skb from internal context. yeah, it really messy.

>
>> Let's call skb_tx_timestamp() after driver specific tx-fixup hacks.
>
> No, that won't work.
>
> That call is before the fixup on purpose, because some fixups add
> padding in front of the Ethernet payload, and this will spoil the PTP
> packet detection filter.
>
> I don't know why the skb can be NULL here. If that is really the case,
> then the correct fix is:
>
> 	if (skb)
> 		skb_tx_timestamp(skb);
>
> Thanks,
> Richard
>
>
>>
>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>> ---
>>   drivers/net/usb/usbnet.c |    4 ++--
>>   1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
>> index 7d60821..485be70 100644
>> --- a/drivers/net/usb/usbnet.c
>> +++ b/drivers/net/usb/usbnet.c
>> @@ -1057,8 +1057,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
>>   	unsigned long		flags;
>>   	int retval;
>>
>> -	skb_tx_timestamp(skb);
>> -
>>   	// some devices want funky USB-level framing, for
>>   	// win32 driver (usually) and/or hardware quirks
>>   	if (info->tx_fixup) {
>> @@ -1075,6 +1073,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
>>   	}
>>   	length = skb->len;
>>
>> +	skb_tx_timestamp(skb);
>> +
>>   	if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
>>   		netif_dbg(dev, tx_err, dev->net, "no urb\n");
>>   		goto drop;
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] usbnet: fix oops in usbnet_start_xmit
  2011-11-07 14:05   ` Konstantin Khlebnikov
@ 2011-11-07 14:42     ` Richard Cochran
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Cochran @ 2011-11-07 14:42 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Oliver Neukum, netdev, David S. Miller, devel, Michael Riesch

On Mon, Nov 07, 2011 at 06:05:22PM +0400, Konstantin Khlebnikov wrote:
> Richard Cochran wrote:
> >On Sun, Nov 06, 2011 at 10:33:37PM +0300, Konstantin Khlebnikov wrote:
> >>This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
> >>SKB can be NULL at this point, at least for cdc-ncm.
> >
> >What? You mean .ndo_start_xmit is called with skb NULL?
> 
> no. cdc_ncm call usbnet_start_xmit with NULL skb from timer handler
> and tx_fixup hook pickup skb from internal context. yeah, it really messy.

You said it.

Can you please submit the fix suggested by Michael and myself?

Thanks,
Richard

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

* [PATCH v2] usbnet: fix oops in usbnet_start_xmit
  2011-11-06 19:33 [PATCH] usbnet: fix oops in usbnet_start_xmit Konstantin Khlebnikov
  2011-11-07 13:29 ` Michael Riesch
  2011-11-07 13:33 ` Richard Cochran
@ 2011-11-07 15:54 ` Konstantin Khlebnikov
  2011-11-07 17:39   ` Richard Cochran
  2 siblings, 1 reply; 8+ messages in thread
From: Konstantin Khlebnikov @ 2011-11-07 15:54 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Michael Riesch, Alexey Orishko, netdev, Richard Cochran,
	David S. Miller, devel

This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
SKB can be NULL at this point, at least for cdc-ncm.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
 drivers/net/usb/usbnet.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 7d60821..fae0fbd 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1057,7 +1057,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
 	unsigned long		flags;
 	int retval;
 
-	skb_tx_timestamp(skb);
+	if (skb)
+		skb_tx_timestamp(skb);
 
 	// some devices want funky USB-level framing, for
 	// win32 driver (usually) and/or hardware quirks

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

* Re: [PATCH v2] usbnet: fix oops in usbnet_start_xmit
  2011-11-07 15:54 ` [PATCH v2] " Konstantin Khlebnikov
@ 2011-11-07 17:39   ` Richard Cochran
  2011-11-07 18:26     ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Cochran @ 2011-11-07 17:39 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Oliver Neukum, Michael Riesch, Alexey Orishko, netdev,
	David S. Miller, devel

On Mon, Nov 07, 2011 at 06:54:58PM +0300, Konstantin Khlebnikov wrote:
> This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
> SKB can be NULL at this point, at least for cdc-ncm.
> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>

Acked-by: Richard Cochran <richardcochran@gmail.com>

> ---
>  drivers/net/usb/usbnet.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index 7d60821..fae0fbd 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -1057,7 +1057,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
>  	unsigned long		flags;
>  	int retval;
>  
> -	skb_tx_timestamp(skb);
> +	if (skb)
> +		skb_tx_timestamp(skb);
>  
>  	// some devices want funky USB-level framing, for
>  	// win32 driver (usually) and/or hardware quirks
> 

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

* Re: [PATCH v2] usbnet: fix oops in usbnet_start_xmit
  2011-11-07 17:39   ` Richard Cochran
@ 2011-11-07 18:26     ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2011-11-07 18:26 UTC (permalink / raw)
  To: richardcochran
  Cc: khlebnikov, oneukum, michael, alexey.orishko, netdev, devel

From: Richard Cochran <richardcochran@gmail.com>
Date: Mon, 7 Nov 2011 18:39:19 +0100

> On Mon, Nov 07, 2011 at 06:54:58PM +0300, Konstantin Khlebnikov wrote:
>> This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e
>> SKB can be NULL at this point, at least for cdc-ncm.
>> 
>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> 
> Acked-by: Richard Cochran <richardcochran@gmail.com>

Applied, but the overall logic in the usbnet transmit path definitely
could use a good reconsideration and cleanup.

I'm even open to having generic support at the generic net device TX
level to fixup the segmentation layout of the SKB so that it meets
the device's requirements.  We can do it more efficiently there too.

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

end of thread, other threads:[~2011-11-07 18:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-06 19:33 [PATCH] usbnet: fix oops in usbnet_start_xmit Konstantin Khlebnikov
2011-11-07 13:29 ` Michael Riesch
2011-11-07 13:33 ` Richard Cochran
2011-11-07 14:05   ` Konstantin Khlebnikov
2011-11-07 14:42     ` Richard Cochran
2011-11-07 15:54 ` [PATCH v2] " Konstantin Khlebnikov
2011-11-07 17:39   ` Richard Cochran
2011-11-07 18:26     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.