Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202969
b: refs/heads/master
c: 8c76368
h: refs/heads/master
i:
  202967: cc16e17
v: v3
  • Loading branch information
Florian Westphal authored and David S. Miller committed Jun 16, 2010
1 parent d620f8e commit 6f55e0f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 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: 317fe0e6c5dc9448bcef41a2e31fecfd3dba7f55
refs/heads/master: 8c76368174ed2359739f1b7b8a9c042b1ef839c4
2 changes: 1 addition & 1 deletion trunk/include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb,
__u16 *mss);

extern __u32 cookie_init_timestamp(struct request_sock *req);
extern void cookie_check_timestamp(struct tcp_options_received *tcp_opt);
extern bool cookie_check_timestamp(struct tcp_options_received *tcp_opt);

/* From net/ipv6/syncookies.c */
extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb);
Expand Down
25 changes: 19 additions & 6 deletions trunk/net/ipv4/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,36 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
* The lowest 4 bits are for snd_wscale
* The next 4 lsb are for rcv_wscale
* The next lsb is for sack_ok
*
* return false if we decode an option that should not be.
*/
void cookie_check_timestamp(struct tcp_options_received *tcp_opt)
bool cookie_check_timestamp(struct tcp_options_received *tcp_opt)
{
/* echoed timestamp, 9 lowest bits contain options */
u32 options = tcp_opt->rcv_tsecr & TSMASK;

if (!tcp_opt->saw_tstamp) {
tcp_clear_options(tcp_opt);
return true;
}

if (!sysctl_tcp_timestamps)
return false;

tcp_opt->snd_wscale = options & 0xf;
options >>= 4;
tcp_opt->rcv_wscale = options & 0xf;

tcp_opt->sack_ok = (options >> 4) & 0x1;

if (tcp_opt->sack_ok)
tcp_sack_reset(tcp_opt);
if (tcp_opt->sack_ok && !sysctl_tcp_sack)
return false;

if (tcp_opt->snd_wscale || tcp_opt->rcv_wscale)
if (tcp_opt->snd_wscale || tcp_opt->rcv_wscale) {
tcp_opt->wscale_ok = 1;
return sysctl_tcp_window_scaling != 0;
}
return true;
}
EXPORT_SYMBOL(cookie_check_timestamp);

Expand Down Expand Up @@ -281,8 +294,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
memset(&tcp_opt, 0, sizeof(tcp_opt));
tcp_parse_options(skb, &tcp_opt, &hash_location, 0);

if (tcp_opt.saw_tstamp)
cookie_check_timestamp(&tcp_opt);
if (!cookie_check_timestamp(&tcp_opt))
goto out;

ret = NULL;
req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/ipv6/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
memset(&tcp_opt, 0, sizeof(tcp_opt));
tcp_parse_options(skb, &tcp_opt, &hash_location, 0);

if (tcp_opt.saw_tstamp)
cookie_check_timestamp(&tcp_opt);
if (!cookie_check_timestamp(&tcp_opt))
goto out;

ret = NULL;
req = inet6_reqsk_alloc(&tcp6_request_sock_ops);
Expand Down

0 comments on commit 6f55e0f

Please sign in to comment.