Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 135215
b: refs/heads/master
c: c887e6d
h: refs/heads/master
i:
  135213: d8ee521
  135211: c016b25
  135207: 4d8dd2d
  135199: 5eedcbf
v: v3
  • Loading branch information
Ilpo Järvinen authored and David S. Miller committed Mar 16, 2009
1 parent 16950e2 commit a5e3d0b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c43d558a5139a3b22dcac3f19f64ecb39130b02e
refs/heads/master: c887e6d2d9aee56ee7c9f2af4cec3a5efdcc4c72
18 changes: 14 additions & 4 deletions trunk/include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,21 @@ static inline int tcp_fin_time(const struct sock *sk)
return fin_timeout;
}

static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, int rst)
static inline int tcp_paws_check(const struct tcp_options_received *rx_opt,
int paws_win)
{
if ((s32)(rx_opt->rcv_tsval - rx_opt->ts_recent) >= 0)
return 0;
if (get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)
if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win)
return 1;
if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS))
return 1;

return 0;
}

static inline int tcp_paws_reject(const struct tcp_options_received *rx_opt,
int rst)
{
if (tcp_paws_check(rx_opt, 0))
return 0;

/* RST segments are not recommended to carry timestamp,
Expand Down
11 changes: 5 additions & 6 deletions trunk/net/ipv4/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -3883,8 +3883,7 @@ static inline void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq)
* Not only, also it occurs for expired timestamps.
*/

if ((s32)(tp->rx_opt.rcv_tsval - tp->rx_opt.ts_recent) >= 0 ||
get_seconds() >= tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS)
if (tcp_paws_check(&tp->rx_opt, 0))
tcp_store_ts_recent(tp);
}
}
Expand Down Expand Up @@ -3936,9 +3935,9 @@ static inline int tcp_paws_discard(const struct sock *sk,
const struct sk_buff *skb)
{
const struct tcp_sock *tp = tcp_sk(sk);
return ((s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) > TCP_PAWS_WINDOW &&
get_seconds() < tp->rx_opt.ts_recent_stamp + TCP_PAWS_24DAYS &&
!tcp_disordered_ack(sk, skb));

return !tcp_paws_check(&tp->rx_opt, TCP_PAWS_WINDOW) &&
!tcp_disordered_ack(sk, skb);
}

/* Check segment sequence number for validity.
Expand Down Expand Up @@ -5513,7 +5512,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,

/* PAWS check. */
if (tp->rx_opt.ts_recent_stamp && tp->rx_opt.saw_tstamp &&
tcp_paws_check(&tp->rx_opt, 0))
tcp_paws_reject(&tp->rx_opt, 0))
goto discard_and_undo;

if (th->syn) {
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/ipv4/tcp_minisocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
if (tmp_opt.saw_tstamp) {
tmp_opt.ts_recent = tcptw->tw_ts_recent;
tmp_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp;
paws_reject = tcp_paws_check(&tmp_opt, th->rst);
paws_reject = tcp_paws_reject(&tmp_opt, th->rst);
}
}

Expand Down Expand Up @@ -511,7 +511,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
* from another data.
*/
tmp_opt.ts_recent_stamp = get_seconds() - ((TCP_TIMEOUT_INIT/HZ)<<req->retrans);
paws_reject = tcp_paws_check(&tmp_opt, th->rst);
paws_reject = tcp_paws_reject(&tmp_opt, th->rst);
}
}

Expand Down

0 comments on commit a5e3d0b

Please sign in to comment.