All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: Add listening address to SYN flood message
@ 2022-11-10 10:21 Jamie Bainbridge
  2022-11-10 13:51 ` Andrew Lunn
  2022-11-10 23:39 ` Stephen Hemminger
  0 siblings, 2 replies; 8+ messages in thread
From: Jamie Bainbridge @ 2022-11-10 10:21 UTC (permalink / raw)
  To: Eric Dumazet, David S. Miller, Hideaki YOSHIFUJI, David Ahern,
	Jakub Kicinski, Paolo Abeni
  Cc: Jamie Bainbridge, netdev, linux-kernel

The SYN flood message prints the listening port number, but on a system
with many processes bound to the same port on different IPs, it's
impossible to tell which socket is the problem.

Add the listen IP address to the SYN flood message. It might have been
nicer to print the address first, but decades of monitoring tools are
watching for the string "SYN flooding on port" so don't break that.

Tested with each protcol's "any" address and a host address:

 Possible SYN flooding on port 9001. IP 0.0.0.0.
 Possible SYN flooding on port 9001. IP 127.0.0.1.
 Possible SYN flooding on port 9001. IP ::.
 Possible SYN flooding on port 9001. IP fc00::1.

Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
---
 net/ipv4/tcp_input.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0640453fce54b6daae0861d948f3db075830daf6..fb86056732266fedc8ad574bbf799dbdd7a425a3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6831,9 +6831,19 @@ static bool tcp_syn_flood_action(const struct sock *sk, const char *proto)
 		__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP);
 
 	if (!queue->synflood_warned && syncookies != 2 &&
-	    xchg(&queue->synflood_warned, 1) == 0)
-		net_info_ratelimited("%s: Possible SYN flooding on port %d. %s.  Check SNMP counters.\n",
-				     proto, sk->sk_num, msg);
+	    xchg(&queue->synflood_warned, 1) == 0) {
+#if IS_ENABLED(CONFIG_IPV6)
+		if (sk->sk_family == AF_INET6) {
+			net_info_ratelimited("%s: Possible SYN flooding on port %d. IP %pI6c. %s.  Check SNMP counters.\n",
+					proto, sk->sk_num,
+					&sk->sk_v6_rcv_saddr, msg);
+		} else
+#endif
+		{
+			net_info_ratelimited("%s: Possible SYN flooding on port %d. IP %pI4. %s.  Check SNMP counters.\n",
+					proto, sk->sk_num, &sk->sk_rcv_saddr, msg);
+		}
+	}
 
 	return want_cookie;
 }
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-11-15 10:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-10 10:21 [PATCH] tcp: Add listening address to SYN flood message Jamie Bainbridge
2022-11-10 13:51 ` Andrew Lunn
2022-11-10 21:20   ` Jamie Bainbridge
2022-11-10 22:30     ` Andrew Lunn
2022-11-15 10:29       ` Geert Uytterhoeven
2022-11-10 23:39 ` Stephen Hemminger
2022-11-10 23:46   ` Eric Dumazet
2022-11-11  0:38   ` Jamie Bainbridge

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.