提交 af9b4738 编写于 作者: F Florian Westphal 提交者: David S. Miller

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: NFlorian Westphal <fw@strlen.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2a1d4bd4
...@@ -266,7 +266,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, ...@@ -266,7 +266,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
struct rtable *rt; struct rtable *rt;
__u8 rcv_wscale; __u8 rcv_wscale;
if (!sysctl_tcp_syncookies || !th->ack) if (!sysctl_tcp_syncookies || !th->ack || th->rst)
goto out; goto out;
if (tcp_synq_no_recent_overflow(sk) || if (tcp_synq_no_recent_overflow(sk) ||
......
...@@ -1506,7 +1506,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) ...@@ -1506,7 +1506,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
} }
#ifdef CONFIG_SYN_COOKIES #ifdef CONFIG_SYN_COOKIES
if (!th->rst && !th->syn && th->ack) if (!th->syn)
sk = cookie_v4_check(sk, skb, &(IPCB(skb)->opt)); sk = cookie_v4_check(sk, skb, &(IPCB(skb)->opt));
#endif #endif
return sk; return sk;
......
...@@ -174,7 +174,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) ...@@ -174,7 +174,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
struct dst_entry *dst; struct dst_entry *dst;
__u8 rcv_wscale; __u8 rcv_wscale;
if (!sysctl_tcp_syncookies || !th->ack) if (!sysctl_tcp_syncookies || !th->ack || th->rst)
goto out; goto out;
if (tcp_synq_no_recent_overflow(sk) || if (tcp_synq_no_recent_overflow(sk) ||
......
...@@ -1157,7 +1157,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) ...@@ -1157,7 +1157,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
} }
#ifdef CONFIG_SYN_COOKIES #ifdef CONFIG_SYN_COOKIES
if (!th->rst && !th->syn && th->ack) if (!th->syn)
sk = cookie_v6_check(sk, skb); sk = cookie_v6_check(sk, skb);
#endif #endif
return sk; return sk;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册