public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] tcp: Add listening address to SYN flood message
@ 2022-11-14  1:00 Jamie Bainbridge
  2022-11-14 17:31 ` Eric Dumazet
  2022-11-15  5:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Jamie Bainbridge @ 2022-11-14  1:00 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 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.

For IPv6 use "[IP]:port" as per RFC-5952 and to provide ease of
copy-paste to "ss" filters. For IPv4 use "IP:port" to match.

Each protcol's "any" address and a host address now look like:

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

Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
---
v2: Place IS_ENABLED() inside if condition c/o Andrew Lunn.
    Change port printf to unsigned c/o Stephen Hemminger.
    Remove long and unhelpful "Check SNMP counters" c/o Stephen H.
v3: Use "IP:port" format c/o Eric Duamzet and Stephen H.
---
 net/ipv4/tcp_input.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0640453fce54b6daae0861d948f3db075830daf6..6e51d8eefe19075721ec6d31036ecae9b6e0d698 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6831,9 +6831,17 @@ 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) && sk->sk_family == AF_INET6) {
+			net_info_ratelimited("%s: Possible SYN flooding on port [%pI6c]:%u. %s.\n",
+					proto, &sk->sk_v6_rcv_saddr,
+					sk->sk_num, msg);
+		} else {
+			net_info_ratelimited("%s: Possible SYN flooding on port %pI4:%u. %s.\n",
+					proto, &sk->sk_rcv_saddr,
+					sk->sk_num, msg);
+		}
+	}
 
 	return want_cookie;
 }
-- 
2.38.1


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

* Re: [PATCH v3] tcp: Add listening address to SYN flood message
  2022-11-14  1:00 [PATCH v3] tcp: Add listening address to SYN flood message Jamie Bainbridge
@ 2022-11-14 17:31 ` Eric Dumazet
  2022-11-15  2:02   ` Stephen Hemminger
  2022-11-15  5:40 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2022-11-14 17:31 UTC (permalink / raw)
  To: Jamie Bainbridge
  Cc: David S. Miller, Hideaki YOSHIFUJI, David Ahern, Jakub Kicinski,
	Paolo Abeni, netdev, linux-kernel

On Sun, Nov 13, 2022 at 5:00 PM Jamie Bainbridge
<jamie.bainbridge@gmail.com> wrote:
>
> The SYN flood message prints the listening port number, but 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.
>
> For IPv6 use "[IP]:port" as per RFC-5952 and to provide ease of
> copy-paste to "ss" filters. For IPv4 use "IP:port" to match.
>
> Each protcol's "any" address and a host address now look like:
>
>  Possible SYN flooding on port 0.0.0.0:9001.
>  Possible SYN flooding on port 127.0.0.1:9001.
>  Possible SYN flooding on port [::]:9001.
>  Possible SYN flooding on port [fc00::1]:9001.
>
> Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH v3] tcp: Add listening address to SYN flood message
  2022-11-14 17:31 ` Eric Dumazet
@ 2022-11-15  2:02   ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2022-11-15  2:02 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Jamie Bainbridge, David S. Miller, Hideaki YOSHIFUJI, David Ahern,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel

On Mon, 14 Nov 2022 09:31:38 -0800
Eric Dumazet <edumazet@google.com> wrote:

> On Sun, Nov 13, 2022 at 5:00 PM Jamie Bainbridge
> <jamie.bainbridge@gmail.com> wrote:
> >
> > The SYN flood message prints the listening port number, but 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.
> >
> > For IPv6 use "[IP]:port" as per RFC-5952 and to provide ease of
> > copy-paste to "ss" filters. For IPv4 use "IP:port" to match.
> >
> > Each protcol's "any" address and a host address now look like:
> >
> >  Possible SYN flooding on port 0.0.0.0:9001.
> >  Possible SYN flooding on port 127.0.0.1:9001.
> >  Possible SYN flooding on port [::]:9001.
> >  Possible SYN flooding on port [fc00::1]:9001.
> >
> > Signed-off-by: Jamie Bainbridge <jamie.bainbridge@gmail.com>
> > ---  
> 
> Reviewed-by: Eric Dumazet <edumazet@google.com>

Thanks for cleaning this up.
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

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

* Re: [PATCH v3] tcp: Add listening address to SYN flood message
  2022-11-14  1:00 [PATCH v3] tcp: Add listening address to SYN flood message Jamie Bainbridge
  2022-11-14 17:31 ` Eric Dumazet
@ 2022-11-15  5:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-15  5:40 UTC (permalink / raw)
  To: Jamie Bainbridge
  Cc: edumazet, davem, yoshfuji, dsahern, kuba, pabeni, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 14 Nov 2022 12:00:08 +1100 you wrote:
> The SYN flood message prints the listening port number, but 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.
> 
> For IPv6 use "[IP]:port" as per RFC-5952 and to provide ease of
> copy-paste to "ss" filters. For IPv4 use "IP:port" to match.
> 
> [...]

Here is the summary with links:
  - [v3] tcp: Add listening address to SYN flood message
    https://git.kernel.org/netdev/net-next/c/d9282e48c608

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14  1:00 [PATCH v3] tcp: Add listening address to SYN flood message Jamie Bainbridge
2022-11-14 17:31 ` Eric Dumazet
2022-11-15  2:02   ` Stephen Hemminger
2022-11-15  5:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox