Skip to contentSkip to conversation

syncookies: only increment SYNCOOKIESFAILED on validation error

PATCH Applied Florian Westphal 2 participants 2 messages Oct 30, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syncookies: only increment SYNCOOKIESFAILED on validation error

Only count packets that failed cookie-authentication.
We can get SYNCOOKIESFAILED > 0 while we never even sent a single cookie.

---
 net/ipv4/syncookies.c | 7 +++++--
 net/ipv6/syncookies.c | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)
net/ipv4/syncookies.c +5 -2
index 32b98d0..4ac7bca 100644
@@ -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;
 	}
net/ipv6/syncookies.c +5 -2
index 0e26e79..be291ba 100644
@@ -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;
 	}
Signature · 1 line
2.0.4