From patchwork Wed Sep 30 16:41:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonghong Song X-Patchwork-Id: 289285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 728ECC4727C for ; Wed, 30 Sep 2020 16:41:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EBA320759 for ; Wed, 30 Sep 2020 16:41:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="LY0o0LhX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729434AbgI3QlW (ORCPT ); Wed, 30 Sep 2020 12:41:22 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:8602 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726476AbgI3QlV (ORCPT ); Wed, 30 Sep 2020 12:41:21 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.42/8.16.0.42) with SMTP id 08UGe2ub012922 for ; Wed, 30 Sep 2020 09:41:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=facebook; bh=p56H8tghV3X85ae/sR/7qYhH2tvH7PBI7nOCpK+zcy4=; b=LY0o0LhXJ+Xh04QzEwwEKfBYSGsxxyC8RF+ydAZf7AXgWL/Q3GnmBJM8AhF5ohp9rcFt iUgEuyXKKM6KKhTrFpUg4zIrQaK+QVW5pneKMiHWIuQh783xR2bgyS796z0JveGtiCgi perV/1BhpMkPZYrS5xJ7hx02Mn+dBg0/3is= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net with ESMTP id 33t14ymk3f-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 30 Sep 2020 09:41:21 -0700 Received: from intmgw004.08.frc2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Wed, 30 Sep 2020 09:41:17 -0700 Received: by devbig003.ftw2.facebook.com (Postfix, from userid 128203) id 294313704D00; Wed, 30 Sep 2020 09:41:09 -0700 (PDT) From: Yonghong Song To: , CC: Alexei Starovoitov , Daniel Borkmann , , Michal Kubecek Subject: [PATCH bpf] bpf: fix "unresolved symbol" build error with resolve_btfids Date: Wed, 30 Sep 2020 09:41:09 -0700 Message-ID: <20200930164109.2922412-1-yhs@fb.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-30_09:2020-09-30,2020-09-30 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 spamscore=0 adultscore=0 bulkscore=0 mlxscore=0 clxscore=1015 impostorscore=0 suspectscore=8 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009300130 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Michal reported a build failure likes below: BTFIDS vmlinux FAILED unresolved symbol tcp_timewait_sock make[1]: *** [/.../linux-5.9-rc7/Makefile:1176: vmlinux] Error 255 This error can be triggered when config has CONFIG_NET enabled but CONFIG_INET disabled. In this case, there is no user of structs inet_timewait_sock and tcp_timewait_sock and hence vmlinux BTF types are not generated for these two structures. To fix the problem, omit the above two types for BTF_SOCK_TYPE_xxx macro if CONFIG_INET is not defined. Fixes: fce557bcef11 ("bpf: Make btf_sock_ids global") Reported-by: Michal Kubecek Signed-off-by: Yonghong Song Acked-by: Andrii Nakryiko --- include/linux/btf_ids.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h index 4867d549e3c1..d9a1e18d0921 100644 --- a/include/linux/btf_ids.h +++ b/include/linux/btf_ids.h @@ -102,24 +102,36 @@ asm( \ * skc_to_*_sock() helpers. All these sockets should have * sock_common as the first argument in its memory layout. */ -#define BTF_SOCK_TYPE_xxx \ + +#define __BTF_SOCK_TYPE_xxx \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET, inet_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_CONN, inet_connection_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_REQ, inet_request_sock) \ - BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_REQ, request_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK, sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_SOCK_COMMON, sock_common) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP, tcp_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_REQ, tcp_request_sock) \ - BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP6, tcp6_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP, udp_sock) \ BTF_SOCK_TYPE(BTF_SOCK_TYPE_UDP6, udp6_sock) +#define __BTF_SOCK_TW_TYPE_xxx \ + BTF_SOCK_TYPE(BTF_SOCK_TYPE_INET_TW, inet_timewait_sock) \ + BTF_SOCK_TYPE(BTF_SOCK_TYPE_TCP_TW, tcp_timewait_sock) + +#ifdef CONFIG_INET +#define BTF_SOCK_TYPE_xxx \ + __BTF_SOCK_TYPE_xxx \ + __BTF_SOCK_TW_TYPE_xxx +#else +#define BTF_SOCK_TYPE_xxx __BTF_SOCK_TYPE_xxx +#endif + enum { #define BTF_SOCK_TYPE(name, str) name, -BTF_SOCK_TYPE_xxx +__BTF_SOCK_TYPE_xxx +__BTF_SOCK_TW_TYPE_xxx #undef BTF_SOCK_TYPE MAX_BTF_SOCK_TYPE, };