Skip to content

Commit

Permalink
try putting the random delay here instead
Browse files Browse the repository at this point in the history
  • Loading branch information
brucespang committed Jun 3, 2019
1 parent 5ce8f58 commit 433cea3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 0 additions & 3 deletions include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <linux/cryptohash.h>
#include <linux/kref.h>
#include <linux/ktime.h>
#include <linux/random.h>

#include <net/inet_connection_sock.h>
#include <net/inet_timewait_sock.h>
Expand Down Expand Up @@ -1255,8 +1254,6 @@ static inline unsigned long tcp_pacing_delay(const struct sock *sk,
pacing_delay -= tcp_sk(sk)->tcp_clock_cache;

if (pacing_delay > 0) {
pacing_delay = (s64)((((u64)prandom_u32() << 32) | prandom_u32()) % (2*(u64)pacing_delay));

return nsecs_to_jiffies(pacing_delay);
} else {
return 0;
Expand Down
4 changes: 4 additions & 0 deletions net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <linux/gfp.h>
#include <linux/module.h>
#include <linux/static_key.h>
#include <linux/random.h>

#include <trace/events/tcp.h>

Expand Down Expand Up @@ -992,6 +993,9 @@ static void tcp_update_skb_after_send(struct sock *sk, struct sk_buff *skb,
*/
if (rate != ~0UL && rate && tp->data_segs_out >= 10) {
u64 len_ns = div64_ul((u64)skb->len * NSEC_PER_SEC, rate);

len_ns = (u64)((((u64)prandom_u32() << 32) | prandom_u32()) % (2*(u64)len_ns));

u64 credit = tp->tcp_wstamp_ns - prior_wstamp;

/* take into account OS jitter */
Expand Down

0 comments on commit 433cea3

Please sign in to comment.