Skip to content

Commit

Permalink
syncookies: only increment SYNCOOKIESFAILED on validation error
Browse files Browse the repository at this point in the history
Only count packets that failed cookie-authentication.
We can get SYNCOOKIESFAILED > 0 while we never even sent a single cookie.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Westphal authored and David S. Miller committed Oct 30, 2014
1 parent f5fbf11 commit 646697b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions net/ipv4/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,11 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
if (!sysctl_tcp_syncookies || !th->ack || th->rst)
goto out;

if (tcp_synq_no_recent_overflow(sk) ||
(mss = __cookie_v4_check(ip_hdr(skb), th, cookie)) == 0) {
if (tcp_synq_no_recent_overflow(sk))
goto out;

mss = __cookie_v4_check(ip_hdr(skb), th, cookie);
if (mss == 0) {
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESFAILED);
goto out;
}
Expand Down
7 changes: 5 additions & 2 deletions net/ipv6/syncookies.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
if (!sysctl_tcp_syncookies || !th->ack || th->rst)
goto out;

if (tcp_synq_no_recent_overflow(sk) ||
(mss = __cookie_v6_check(ipv6_hdr(skb), th, cookie)) == 0) {
if (tcp_synq_no_recent_overflow(sk))
goto out;

mss = __cookie_v6_check(ipv6_hdr(skb), th, cookie);
if (mss == 0) {
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESFAILED);
goto out;
}
Expand Down

0 comments on commit 646697b

Please sign in to comment.