diff options
author | Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> | 2009-03-14 10:23:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-15 23:09:52 -0400 |
commit | c887e6d2d9aee56ee7c9f2af4cec3a5efdcc4c72 (patch) | |
tree | ee267baadce309166ceea5649292f221cd9a6766 /include/net | |
parent | c43d558a5139a3b22dcac3f19f64ecb39130b02e (diff) |
tcp: consolidate paws check
Wow, it was quite tricky to merge that stream of negations
but I think I finally got it right:
check & replace_ts_recent:
(s32)(rcv_tsval - ts_recent) >= 0 => 0
(s32)(ts_recent - rcv_tsval) <= 0 => 0
discard:
(s32)(ts_recent - rcv_tsval) > TCP_PAWS_WINDOW => 1
(s32)(ts_recent - rcv_tsval) <= TCP_PAWS_WINDOW => 0
I toggled the return values of tcp_paws_check around since
the old encoding added yet-another negation making tracking
of truth-values really complicated.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/tcp.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index d74ac301e6bc..255ca35bea05 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -997,11 +997,21 @@ static inline int tcp_fin_time(const struct sock *sk) | |||
997 | return fin_timeout; | 997 | return fin_timeout; |
998 | } | 998 | } |
999 | 999 | ||
1000 | static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, int rst) | 1000 | static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, |
1001 | int paws_win) | ||
1001 | { | 1002 | { |
1002 | if ((s32)(rx_opt->rcv_tsval - rx_opt->ts_recent) >= 0) | 1003 | if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win) |
1003 | return 0; | 1004 | return 1; |
1004 | if (get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS) | 1005 | if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) |
1006 | return 1; | ||
1007 | |||
1008 | return 0; | ||
1009 | } | ||
1010 | |||
1011 | static inline int tcp_paws_reject(const struct tcp_options_received *rx_opt, | ||
1012 | int rst) | ||
1013 | { | ||
1014 | if (tcp_paws_check(rx_opt, 0)) | ||
1005 | return 0; | 1015 | return 0; |
1006 | 1016 | ||
1007 | /* RST segments are not recommended to carry timestamp, | 1017 | /* RST segments are not recommended to carry timestamp, |