Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 149794
b: refs/heads/master
c: a0f82f6
h: refs/heads/master
v: v3
  • Loading branch information
Florian Westphal authored and David S. Miller committed Apr 20, 2009
1 parent 2d62311 commit d1cbf72
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 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: 7eebb0b28f755e297d355a205bb04945b256db6b
refs/heads/master: a0f82f64e26929776c58a5c93c2ecb38e3d82815
4 changes: 1 addition & 3 deletions trunk/include/linux/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ struct tcp_sock {
unsigned int keepalive_time; /* time before keep alive takes place */
unsigned int keepalive_intvl; /* time interval between keep alive probes */

unsigned long last_synq_overflow;
int linger2;

/* Receiver side RTT estimation */
struct {
Expand Down Expand Up @@ -406,8 +406,6 @@ struct tcp_sock {
/* TCP MD5 Signagure Option information */
struct tcp_md5sig_info *md5sig_info;
#endif

int linger2;
};

static inline struct tcp_sock *tcp_sk(const struct sock *sk)
Expand Down
13 changes: 13 additions & 0 deletions trunk/include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,19 @@ static inline int tcp_too_many_orphans(struct sock *sk, int num)
atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]);
}

/* syncookies: remember time of last synqueue overflow */
static inline void tcp_synq_overflow(struct sock *sk)
{
tcp_sk(sk)->rx_opt.ts_recent_stamp = jiffies;
}

/* syncookies: no recent synqueue overflow on this listening socket? */
static inline int tcp_synq_no_recent_overflow(const struct sock *sk)
{
unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp;
return time_after(jiffies, last_overflow + TCP_TIMEOUT_INIT);
}

extern struct proto tcp_prot;

#define TCP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.tcp_statistics, field)
Expand Down
5 changes: 2 additions & 3 deletions trunk/net/ipv4/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,12 @@ static __u16 const msstab[] = {
*/
__u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
{
struct tcp_sock *tp = tcp_sk(sk);
const struct iphdr *iph = ip_hdr(skb);
const struct tcphdr *th = tcp_hdr(skb);
int mssind;
const __u16 mss = *mssp;

tp->last_synq_overflow = jiffies;
tcp_synq_overflow(sk);

/* XXX sort msstab[] by probability? Binary search? */
for (mssind = 0; mss > msstab[mssind + 1]; mssind++)
Expand Down Expand Up @@ -268,7 +267,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
if (!sysctl_tcp_syncookies || !th->ack)
goto out;

if (time_after(jiffies, tp->last_synq_overflow + TCP_TIMEOUT_INIT) ||
if (tcp_synq_no_recent_overflow(sk) ||
(mss = cookie_check(skb, cookie)) == 0) {
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESFAILED);
goto out;
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 @@ -131,7 +131,7 @@ __u32 cookie_v6_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
int mssind;
const __u16 mss = *mssp;

tcp_sk(sk)->last_synq_overflow = jiffies;
tcp_synq_overflow(sk);

for (mssind = 0; mss > msstab[mssind + 1]; mssind++)
;
Expand Down Expand Up @@ -175,7 +175,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
if (!sysctl_tcp_syncookies || !th->ack)
goto out;

if (time_after(jiffies, tp->last_synq_overflow + TCP_TIMEOUT_INIT) ||
if (tcp_synq_no_recent_overflow(sk) ||
(mss = cookie_check(skb, cookie)) == 0) {
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESFAILED);
goto out;
Expand Down

0 comments on commit d1cbf72

Please sign in to comment.