syncookies: avoid unneeded tcp header flag double check
authorFlorian Westphal <fw@strlen.de>
Thu, 3 Jun 2010 00:43:44 +0000 (00:43 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 5 Jun 2010 09:23:14 +0000 (02:23 -0700)
caller: if (!th->rst && !th->syn && th->ack)
callee: if (!th->ack)

make the caller only check for !syn (common for 3whs), and move
the !rst / ack test to the callee.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/syncookies.c
net/ipv4/tcp_ipv4.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c

index 5c24db4a3c91a54d7d6b3b86e8d4d906999d7d76..c9dac8615958457869f867f3aa51a690ab98d818 100644 (file)
@@ -266,7 +266,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
        struct rtable *rt;
        __u8 rcv_wscale;
 
-       if (!sysctl_tcp_syncookies || !th->ack)
+       if (!sysctl_tcp_syncookies || !th->ack || th->rst)
                goto out;
 
        if (tcp_synq_no_recent_overflow(sk) ||
index a13f881e50377bd04c3989dd3c1ac02fbbf785ac..6558dfd899da0f148833fbc9b144b0b8d3acfedb 100644 (file)
@@ -1506,7 +1506,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
        }
 
 #ifdef CONFIG_SYN_COOKIES
-       if (!th->rst && !th->syn && th->ack)
+       if (!th->syn)
                sk = cookie_v4_check(sk, skb, &(IPCB(skb)->opt));
 #endif
        return sk;
index 12383705dbad6c155ea978c41ccefd1df39fe283..9fcb3ec7c838b1a8bb1eaff0755736597238b9f1 100644 (file)
@@ -174,7 +174,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
        struct dst_entry *dst;
        __u8 rcv_wscale;
 
-       if (!sysctl_tcp_syncookies || !th->ack)
+       if (!sysctl_tcp_syncookies || !th->ack || th->rst)
                goto out;
 
        if (tcp_synq_no_recent_overflow(sk) ||
index e487080d02dbe96ac2355bb1a8a42a3eb1b423f4..5887141ad6417f4c0018faccda97d2cb5e489c16 100644 (file)
@@ -1157,7 +1157,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
        }
 
 #ifdef CONFIG_SYN_COOKIES
-       if (!th->rst && !th->syn && th->ack)
+       if (!th->syn)
                sk = cookie_v6_check(sk, skb);
 #endif
        return sk;