public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH v2] inetpeer: fix token initialization
Date: Thu, 27 Sep 2012 16:18:36 +0200	[thread overview]
Message-ID: <1348755516.5093.1326.camel@edumazet-glaptop> (raw)
In-Reply-To: <1348755060-3737-1-git-send-email-nicolas.dichtel@6wind.com>

On Thu, 2012-09-27 at 16:11 +0200, Nicolas Dichtel wrote:
> When jiffies wraps around (for example, 5 minutes after the boot, see
> INITIAL_JIFFIES) and peer has just been created, now - peer->rate_last can be
> < XRLIM_BURST_FACTOR * timeout, so token is not set to the maximum value, thus
> some icmp packets can be unexpectedly dropped.
> 
> Fix this case by initializing last_rate to 60 seconds in the past.
> 
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
> v2: fix initialization of peer instead of adding some tests in
>     inet_peer_xrlim_allow()
> 
>  net/ipv4/inetpeer.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
> index e1e0a4e..c7527f6 100644
> --- a/net/ipv4/inetpeer.c
> +++ b/net/ipv4/inetpeer.c
> @@ -510,7 +510,10 @@ relookup:
>  					secure_ipv6_id(daddr->addr.a6));
>  		p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
>  		p->rate_tokens = 0;
> -		p->rate_last = 0;
> +		/* 60*HZ is arbitrary, but chosen enough high so that the first
> +		 * calculation of tokens is at its maximum.
> +		 */
> +		p->rate_last = jiffies - 60*HZ;
>  		INIT_LIST_HEAD(&p->gc_list);
>  
>  		/* Link the node. */

Signed-off-by: Eric Dumazet <edumazet@google.com>

Thanks !

  reply	other threads:[~2012-09-27 14:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 12:33 [PATCH] inetpeer: ensure to set the maximum tokens the first time Nicolas Dichtel
2012-09-27 12:53 ` Eric Dumazet
2012-09-27 13:21   ` Nicolas Dichtel
2012-09-27 13:30     ` Eric Dumazet
2012-09-27 13:34       ` Eric Dumazet
2012-09-27 13:39         ` Nicolas Dichtel
2012-09-27 14:11         ` [PATCH v2] inetpeer: fix token initialization Nicolas Dichtel
2012-09-27 14:18           ` Eric Dumazet [this message]
2012-09-27 23:28             ` 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=1348755516.5093.1326.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.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