From patchwork Tue Nov 15 10:12:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13043416 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D85ACC433FE for ; Tue, 15 Nov 2022 10:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238386AbiKOKNa (ORCPT ); Tue, 15 Nov 2022 05:13:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238438AbiKOKMj (ORCPT ); Tue, 15 Nov 2022 05:12:39 -0500 Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2239E25C56 for ; Tue, 15 Nov 2022 02:12:22 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:8c33:62a1:bd29:7c58]) by xavier.telenet-ops.be with bizsmtp id kaCJ280030JF8f801aCJRV; Tue, 15 Nov 2022 11:12:21 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1ousvR-000Xyg-IX; Tue, 15 Nov 2022 11:12:17 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1ousvQ-005B9T-VS; Tue, 15 Nov 2022 11:12:16 +0100 From: Geert Uytterhoeven To: Jamie Bainbridge , Eric Dumazet , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , Chris Down , Stephen Hemminger Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH net-next] tcp: Fix tcp_syn_flood_action() if CONFIG_IPV6=n Date: Tue, 15 Nov 2022 11:12:16 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If CONFIG_IPV6=n: net/ipv4/tcp_input.c: In function ‘tcp_syn_flood_action’: include/net/sock.h:387:37: error: ‘const struct sock_common’ has no member named ‘skc_v6_rcv_saddr’; did you mean ‘skc_rcv_saddr’? 387 | #define sk_v6_rcv_saddr __sk_common.skc_v6_rcv_saddr | ^~~~~~~~~~~~~~~~ include/linux/printk.h:429:19: note: in definition of macro ‘printk_index_wrap’ 429 | _p_func(_fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~ include/linux/printk.h:530:2: note: in expansion of macro ‘printk’ 530 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~ include/linux/net.h:272:3: note: in expansion of macro ‘pr_info’ 272 | function(__VA_ARGS__); \ | ^~~~~~~~ include/linux/net.h:288:2: note: in expansion of macro ‘net_ratelimited_function’ 288 | net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~~~~~~ include/linux/net.h:288:43: note: in expansion of macro ‘sk_v6_rcv_saddr’ 288 | net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__) | ^~~~~~~~~~~ net/ipv4/tcp_input.c:6847:4: note: in expansion of macro ‘net_info_ratelimited’ 6847 | net_info_ratelimited("%s: Possible SYN flooding on port [%pI6c]:%u. %s.\n", | ^~~~~~~~~~~~~~~~~~~~ Fix this by using "#if" instead of "if", like is done for all other checks for CONFIG_IPV6. Fixes: d9282e48c6088105 ("tcp: Add listening address to SYN flood message") Signed-off-by: Geert Uytterhoeven Tested-by: Matthieu Baerts --- net/ipv4/tcp_input.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 94024fdc2da1b28a..e5d7a33fac6666bb 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6843,11 +6843,14 @@ static bool tcp_syn_flood_action(const struct sock *sk, const char *proto) if (!queue->synflood_warned && syncookies != 2 && xchg(&queue->synflood_warned, 1) == 0) { - if (IS_ENABLED(CONFIG_IPV6) && sk->sk_family == AF_INET6) { +#if IS_ENABLED(CONFIG_IPV6) + if (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 { + } else +#endif + { net_info_ratelimited("%s: Possible SYN flooding on port %pI4:%u. %s.\n", proto, &sk->sk_rcv_saddr, sk->sk_num, msg);