linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] tuntap: purge socket error queue on detach
@ 2013-09-04  4:33 Jason Wang
  2013-09-04  4:33 ` [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp Jason Wang
  2013-09-04 15:56 ` [PATCH net-next 1/2] tuntap: purge socket error queue on detach Richard Cochran
  0 siblings, 2 replies; 6+ messages in thread
From: Jason Wang @ 2013-09-04  4:33 UTC (permalink / raw)
  To: davem, netdev, linux-kernel; +Cc: mst, Jason Wang, Richard Cochran

Commit eda297729171fe16bf34fe5b0419dfb69060f623
(tun: Support software transmit time stamping) will queue skbs into error queue
when tx stamping is enabled. But it forgets to purge the error queue during
detach. This patch fixes this.

Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/tun.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 60a1e93..2dddb1b 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -409,6 +409,12 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile)
 	return tun;
 }
 
+static void tun_queue_purge(struct tun_file *tfile)
+{
+	skb_queue_purge(&tfile->sk.sk_receive_queue);
+	skb_queue_purge(&tfile->sk.sk_error_queue);
+}
+
 static void __tun_detach(struct tun_file *tfile, bool clean)
 {
 	struct tun_file *ntfile;
@@ -435,7 +441,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
 		synchronize_net();
 		tun_flow_delete_by_queue(tun, tun->numqueues + 1);
 		/* Drop read queue */
-		skb_queue_purge(&tfile->sk.sk_receive_queue);
+		tun_queue_purge(tfile);
 		tun_set_real_num_queues(tun);
 	} else if (tfile->detached && clean) {
 		tun = tun_enable_queue(tfile);
@@ -487,12 +493,12 @@ static void tun_detach_all(struct net_device *dev)
 	for (i = 0; i < n; i++) {
 		tfile = rtnl_dereference(tun->tfiles[i]);
 		/* Drop read queue */
-		skb_queue_purge(&tfile->sk.sk_receive_queue);
+		tun_queue_purge(tfile);
 		sock_put(&tfile->sk);
 	}
 	list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) {
 		tun_enable_queue(tfile);
-		skb_queue_purge(&tfile->sk.sk_receive_queue);
+		tun_queue_purge(tfile);
 		sock_put(&tfile->sk);
 	}
 	BUG_ON(tun->numdisabled != 0);
-- 
1.7.1


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

* [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp
  2013-09-04  4:33 [PATCH net-next 1/2] tuntap: purge socket error queue on detach Jason Wang
@ 2013-09-04  4:33 ` Jason Wang
  2013-09-04 13:27   ` Sergei Shtylyov
  2013-09-04 15:57   ` Richard Cochran
  2013-09-04 15:56 ` [PATCH net-next 1/2] tuntap: purge socket error queue on detach Richard Cochran
  1 sibling, 2 replies; 6+ messages in thread
From: Jason Wang @ 2013-09-04  4:33 UTC (permalink / raw)
  To: davem, netdev, linux-kernel; +Cc: mst, Jason Wang, Richard Cochran

sock_tx_timestamp() will clear all zerocopy flags of skb which may lead the
frags never to be orphaned. This will break guest to guest traffic when zerocopy
is enabled. Fix this by orphaning the frags before trying to set tx time stamp.

The issue were introduced by commit eda297729171fe16bf34fe5b0419dfb69060f623
(tun: Support software transmit time stamping).

Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/tun.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 2dddb1b..af9a096 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -749,15 +749,16 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
 			  >= dev->tx_queue_len / tun->numqueues)
 		goto drop;
 
+	/* Orphan the skb - required as we might hang on to it
+	 * for indefinite time. */
+	if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
+		goto drop;
+
 	if (skb->sk) {
 		sock_tx_timestamp(skb->sk, &skb_shinfo(skb)->tx_flags);
 		sw_tx_timestamp(skb);
 	}
 
-	/* Orphan the skb - required as we might hang on to it
-	 * for indefinite time. */
-	if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
-		goto drop;
 	skb_orphan(skb);
 
 	nf_reset(skb);
-- 
1.7.1


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

* Re: [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp
  2013-09-04  4:33 ` [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp Jason Wang
@ 2013-09-04 13:27   ` Sergei Shtylyov
  2013-09-05  9:59     ` Jason Wang
  2013-09-04 15:57   ` Richard Cochran
  1 sibling, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2013-09-04 13:27 UTC (permalink / raw)
  To: Jason Wang; +Cc: davem, netdev, linux-kernel, mst, Richard Cochran

Hello.

On 04-09-2013 8:33, Jason Wang wrote:

> sock_tx_timestamp() will clear all zerocopy flags of skb which may lead the
> frags never to be orphaned. This will break guest to guest traffic when zerocopy
> is enabled. Fix this by orphaning the frags before trying to set tx time stamp.

> The issue were introduced by commit eda297729171fe16bf34fe5b0419dfb69060f623
> (tun: Support software transmit time stamping).

> Cc: Richard Cochran <richardcochran@gmail.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>   drivers/net/tun.c |    9 +++++----
>   1 files changed, 5 insertions(+), 4 deletions(-)

> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 2dddb1b..af9a096 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -749,15 +749,16 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
>   			  >= dev->tx_queue_len / tun->numqueues)
>   		goto drop;
>
> +	/* Orphan the skb - required as we might hang on to it
> +	 * for indefinite time. */

    You could fix the comment style to the networking code default, while at: it:

/* bla
  * bla
  */

> +	if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
> +		goto drop;
> +
>   	if (skb->sk) {
>   		sock_tx_timestamp(skb->sk, &skb_shinfo(skb)->tx_flags);
>   		sw_tx_timestamp(skb);
>   	}
>
> -	/* Orphan the skb - required as we might hang on to it
> -	 * for indefinite time. */
> -	if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
> -		goto drop;

WBR, Sergei




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

* Re: [PATCH net-next 1/2] tuntap: purge socket error queue on detach
  2013-09-04  4:33 [PATCH net-next 1/2] tuntap: purge socket error queue on detach Jason Wang
  2013-09-04  4:33 ` [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp Jason Wang
@ 2013-09-04 15:56 ` Richard Cochran
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Cochran @ 2013-09-04 15:56 UTC (permalink / raw)
  To: Jason Wang; +Cc: davem, netdev, linux-kernel, mst

On Wed, Sep 04, 2013 at 12:33:45PM +0800, Jason Wang wrote:
> Commit eda297729171fe16bf34fe5b0419dfb69060f623
> (tun: Support software transmit time stamping) will queue skbs into error queue
> when tx stamping is enabled. But it forgets to purge the error queue during
> detach. This patch fixes this.
> 
> Cc: Richard Cochran <richardcochran@gmail.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>

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

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

* Re: [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp
  2013-09-04  4:33 ` [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp Jason Wang
  2013-09-04 13:27   ` Sergei Shtylyov
@ 2013-09-04 15:57   ` Richard Cochran
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Cochran @ 2013-09-04 15:57 UTC (permalink / raw)
  To: Jason Wang; +Cc: davem, netdev, linux-kernel, mst

On Wed, Sep 04, 2013 at 12:33:46PM +0800, Jason Wang wrote:
> sock_tx_timestamp() will clear all zerocopy flags of skb which may lead the
> frags never to be orphaned. This will break guest to guest traffic when zerocopy
> is enabled. Fix this by orphaning the frags before trying to set tx time stamp.
> 
> The issue were introduced by commit eda297729171fe16bf34fe5b0419dfb69060f623
> (tun: Support software transmit time stamping).
> 
> Cc: Richard Cochran <richardcochran@gmail.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>

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

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

* Re: [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp
  2013-09-04 13:27   ` Sergei Shtylyov
@ 2013-09-05  9:59     ` Jason Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2013-09-05  9:59 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: davem, netdev, linux-kernel, mst, Richard Cochran

On 09/04/2013 09:27 PM, Sergei Shtylyov wrote:
> Hello.
>
> On 04-09-2013 8:33, Jason Wang wrote:
>
>> sock_tx_timestamp() will clear all zerocopy flags of skb which may
>> lead the
>> frags never to be orphaned. This will break guest to guest traffic
>> when zerocopy
>> is enabled. Fix this by orphaning the frags before trying to set tx
>> time stamp.
>
>> The issue were introduced by commit
>> eda297729171fe16bf34fe5b0419dfb69060f623
>> (tun: Support software transmit time stamping).
>
>> Cc: Richard Cochran <richardcochran@gmail.com>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>>   drivers/net/tun.c |    9 +++++----
>>   1 files changed, 5 insertions(+), 4 deletions(-)
>
>> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
>> index 2dddb1b..af9a096 100644
>> --- a/drivers/net/tun.c
>> +++ b/drivers/net/tun.c
>> @@ -749,15 +749,16 @@ static netdev_tx_t tun_net_xmit(struct sk_buff
>> *skb, struct net_device *dev)
>>                 >= dev->tx_queue_len / tun->numqueues)
>>           goto drop;
>>
>> +    /* Orphan the skb - required as we might hang on to it
>> +     * for indefinite time. */
>
>    You could fix the comment style to the networking code default,
> while at: it:
>
> /* bla
>  * bla
>  */
>
>> +    if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
>> +        goto drop;
>> +
>>       if (skb->sk) {
>>           sock_tx_timestamp(skb->sk, &skb_shinfo(skb)->tx_flags);
>>           sw_tx_timestamp(skb);
>>       }
>>
>> -    /* Orphan the skb - required as we might hang on to it
>> -     * for indefinite time. */
>> -    if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
>> -        goto drop;
>
> WBR, Sergei
>
>
>

Sure will post V2.

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

end of thread, other threads:[~2013-09-05  9:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-04  4:33 [PATCH net-next 1/2] tuntap: purge socket error queue on detach Jason Wang
2013-09-04  4:33 ` [PATCH net-next 2/2] tuntap: orphan frags before trying to set tx timestamp Jason Wang
2013-09-04 13:27   ` Sergei Shtylyov
2013-09-05  9:59     ` Jason Wang
2013-09-04 15:57   ` Richard Cochran
2013-09-04 15:56 ` [PATCH net-next 1/2] tuntap: purge socket error queue on detach Richard Cochran

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