netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH] loopback: better handling of packet drops
Date: Fri, 17 Apr 2009 17:05:42 +0200	[thread overview]
Message-ID: <49E89AC6.80409@cosmosbay.com> (raw)
In-Reply-To: <20090417075801.2f9fe64e@nehalam>

Stephen Hemminger a écrit :
> On Fri, 17 Apr 2009 12:33:33 +0200
> Eric Dumazet <dada1@cosmosbay.com> wrote:
>>  static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
>>  {
>>  	struct pcpu_lstats *pcpu_lstats, *lb_stats;
>> +	int len;
>>  
>>  	skb_orphan(skb);
>>  
>> -	skb->protocol = eth_type_trans(skb,dev);
>> +	skb->protocol = eth_type_trans(skb, dev);
>>  
>>  	/* it's OK to use per_cpu_ptr() because BHs are off */
>>  	pcpu_lstats = dev->ml_priv;
>>  	lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
>> -	lb_stats->bytes += skb->len;
>> -	lb_stats->packets++;
>>  
>> -	netif_rx(skb);
>> +	len = skb->len;
>> +	if (likely(__netif_rx(skb) == NET_RX_SUCCESS)) {
>> +		lb_stats->bytes += len;
>> +		lb_stats->packets++;
>> +		return NETDEV_TX_OK;
>> +	}
>> +	lb_stats->drops++;
>>  
>> -	return 0;
>> +	return NETDEV_TX_BUSY;
>>  }
> 
> If you return NETDEV_TX_BUSY, then the xmit logic will retry
> so it is not really a drop but a stall. I think it is confusing
> to call this a packet loss.

Good point, thanks.
So we should not account this stall in dev stats ? Maybe in 'collisions' ?

I also discovered we had to do
skb_push(skb, ETH_HLEN); /* undo the skb_pull() done in eth_type_trans() */
before returning NETDEV_TX_BUSY;



  reply	other threads:[~2009-04-17 15:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-16 19:58 [PATCH 2.6.30] Network Drop Monitor: Make use of consume_skb() in af_can.c Oliver Hartkopp
2009-04-17  8:38 ` David Miller
2009-04-17  8:56   ` [PATCH] loopback: packet drops accounting Eric Dumazet
2009-04-17  8:59     ` David Miller
2009-04-17  9:27       ` Eric Dumazet
2009-04-17 10:06         ` [PATCH] loopback: better handling of packet drops Eric Dumazet
2009-04-17 10:33           ` Eric Dumazet
2009-04-17 10:51             ` David Miller
2009-04-17 12:22               ` Eric Dumazet
2009-04-17 14:58             ` Stephen Hemminger
2009-04-17 15:05               ` Eric Dumazet [this message]
2009-04-18  8:03         ` [PATCH] loopback: packet drops accounting Eric Dumazet
2009-04-20  9:26           ` 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=49E89AC6.80409@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /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).