Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc9259a

Browse files
NicolasDichteldavem330
authored andcommitted
inetpeer: fix token initialization
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 <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 68b3f28 commit bc9259a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/ipv4/inetpeer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,10 @@ struct inet_peer *inet_getpeer(struct inet_peer_base *base,
510510
secure_ipv6_id(daddr->addr.a6));
511511
p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
512512
p->rate_tokens = 0;
513-
p->rate_last = 0;
513+
/* 60*HZ is arbitrary, but chosen enough high so that the first
514+
* calculation of tokens is at its maximum.
515+
*/
516+
p->rate_last = jiffies - 60*HZ;
514517
INIT_LIST_HEAD(&p->gc_list);
515518

516519
/* Link the node. */

0 commit comments

Comments
 (0)