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: 20289 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2627227wru; Tue, 15 Nov 2022 02:14:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ip2QQ1PUloy2eWZ5+ojQanPtDXTG8eb5FL0ZapnpPFvLT1PVrIjWfwEoxECkRdYtEb5Cs X-Received: by 2002:a17:90a:4f81:b0:213:1fcb:3ce1 with SMTP id q1-20020a17090a4f8100b002131fcb3ce1mr1492258pjh.58.1668507253272; Tue, 15 Nov 2022 02:14:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668507253; cv=none; d=google.com; s=arc-20160816; b=yWd5OirNbq3JQvT+EBitoVRcCQEtxouYH7o3G4k4Ag+wRRJsGMGkwx4pXcAQ/O2QIj 2UsaOxf+VfGuTRcgLOCZ5z3DW8mq9nX+PL6SJ8vxMRqVXYm87yc7I++ULbkVZy2y//lW MskfMhEMm3wB1G0olW8u6iCIZnU+zViSLpgan/CdsUiixcOyB/96b0k+MZ9MzlN2xM/Q aJb9+uEgxCRLINbMNUTj2yFf2TwLd2OtLW/VfY/1cuApbEd6cis6Sosf88IP0w3X39wy WkjH9MMwHmfRNLXKAo/7qTeC2jUYu2JnBL4biwCtBzqTP/znZLk95nX/8f3a7jKyAQBS TT/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=OLY5vsYaseHs5dsWYEBKr66v8ZTEUvv4FHZuzVimlE8=; b=yFHBh0HfKyoVqerUAxpVT/BnZJSh3XWYoLPalZYIaXzXekSGQ+uPdUktPfXbJrw3lB qOf78Ounaif0T27j1ZEEGh4Pf7XUEgA24j2VZ4eq9ThBBNPxYIUE4i/dn0qgiOGaqn64 l1FjUK/pr4M8PWv0WBqIqjrvv5JsfoVUOXTKOLhiGdnGR2G0Q8GiciA6f6ZsUc/NL/OI MX2EcF3LsbLL06KNxLdz8nVxwEfVLzltzH7hmJbEvk1pRWVbEfRGqG2pLD0MFc5lOEvV 2B5hSonmgoRNhO3rR9wW91qzjFaEyRVTLcOF2rML90nqt4YxdRe33AjxWfKsEpggOyF0 0bzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 73-20020a63004c000000b004403ddda6e6si11564768pga.847.2022.11.15.02.13.59; Tue, 15 Nov 2022 02:14:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238442AbiKOKNa (ORCPT + 99 others); Tue, 15 Nov 2022 05:13:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238384AbiKOKMj (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 2251025E81 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 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749556661952155429?= X-GMAIL-MSGID: =?utf-8?q?1749556661952155429?= 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);