syncookies: avoid unneeded tcp header flag double check
Subsystems (3)
PATCH 1/1 syncookies: avoid unneeded tcp header flag double check
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 <[email protected]>
--- net/ipv4/syncookies.c | 2 +- net/ipv4/tcp_ipv4.c | 2 +- net/ipv6/syncookies.c | 2 +- net/ipv6/tcp_ipv6.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
net/ipv4/syncookies.c +1 -1
@@ -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) ||
net/ipv4/tcp_ipv4.c +1 -1
@@ -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;
net/ipv6/syncookies.c +1 -1
@@ -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) ||
net/ipv6/tcp_ipv6.c +1 -1
@@ -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;
Signature · 1 line
1.6.4.4
From: Florian Westphal <[email protected]>
Date: Thu, 3 Jun 2010 12:43:44 +0200
Quoted 7 lines
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 <[email protected]>
Applied.