From patchwork Thu Oct 1 01:02:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonghong Song X-Patchwork-Id: 259789 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 3E4B0C4363D for ; Thu, 1 Oct 2020 01:02:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0488720BED for ; Thu, 1 Oct 2020 01:02:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="ZRPL6J5t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732348AbgJABCc (ORCPT ); Wed, 30 Sep 2020 21:02:32 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:45572 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732343AbgJABCc (ORCPT ); Wed, 30 Sep 2020 21:02:32 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0910npRd003052 for ; Wed, 30 Sep 2020 18:02:30 -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=qJrmEVxrxATTzkrduJ0xSQtCg4/DepbYX9s91eJ1Y88=; b=ZRPL6J5tSIBGZxtoTBGLnBQZ1QN4wvPELQw+yI8rQXLAzf8gkNq5CJlMLhtmujHcJa68 FRU2KP1Rh6NTb7iu09oeoj7xsYrLo9YDsULQLoWG8MzCRbZQ8quTHwsMxEk2fynrh2GT mWIjekdHUPyd2NmjTCpPVcGZcJ1pKUvqcGk= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 33vvgrk0xe-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 30 Sep 2020 18:02:30 -0700 Received: from intmgw002.03.ash8.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 18:02:29 -0700 Received: by devbig003.ftw2.facebook.com (Postfix, from userid 128203) id 4C253370571E; Wed, 30 Sep 2020 18:02:24 -0700 (PDT) From: Yonghong Song To: , CC: Alexei Starovoitov , Daniel Borkmann , , Michal Kubecek Subject: [PATCH bpf v2] bpf: fix "unresolved symbol" build error with resolve_btfids Date: Wed, 30 Sep 2020 18:02:24 -0700 Message-ID: <20201001010224.1545722-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_13:2020-09-30,2020-09-30 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 priorityscore=1501 clxscore=1015 phishscore=0 mlxscore=0 bulkscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 mlxlogscore=999 suspectscore=8 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2010010004 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, for two timewait structures, if CONFIG_INET=n, use BTF_ID_UNUSED instead of BTF_ID to skip btf id generation in resolve_btfids. Fixes: fce557bcef11 ("bpf: Make btf_sock_ids global") Reported-by: Michal Kubecek Signed-off-by: Yonghong Song --- include/linux/btf_ids.h | 20 +++++++++++++++++--- net/core/filter.c | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) Changelog: v1 -> v2: . For unsupported socket times, using BTF_ID_UNUSED to keep the id as 0. (Martin) diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h index 4867d549e3c1..9c49bf89a9a7 100644 --- a/include/linux/btf_ids.h +++ b/include/linux/btf_ids.h @@ -102,23 +102,37 @@ 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) +#ifdef CONFIG_INET +#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) +#else +#define __BTF_SOCK_TW_TYPE_xxx \ + BTF_SOCK_TYPE_UNUSED(BTF_SOCK_TYPE_INET_TW) \ + BTF_SOCK_TYPE_UNUSED(BTF_SOCK_TYPE_TCP_TW) +#endif + +#define BTF_SOCK_TYPE_xxx \ + __BTF_SOCK_TYPE_xxx \ + __BTF_SOCK_TW_TYPE_xxx + enum { #define BTF_SOCK_TYPE(name, str) name, +#define BTF_SOCK_TYPE_UNUSED(name) name, BTF_SOCK_TYPE_xxx #undef BTF_SOCK_TYPE MAX_BTF_SOCK_TYPE, diff --git a/net/core/filter.c b/net/core/filter.c index 21eaf3b182f2..396fe928e202 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -9500,6 +9500,7 @@ void bpf_prog_change_xdp(struct bpf_prog *prev_prog, struct bpf_prog *prog) #ifdef CONFIG_DEBUG_INFO_BTF BTF_ID_LIST_GLOBAL(btf_sock_ids) #define BTF_SOCK_TYPE(name, type) BTF_ID(struct, type) +#define BTF_SOCK_TYPE_UNUSED(name) BTF_ID_UNUSED BTF_SOCK_TYPE_xxx #undef BTF_SOCK_TYPE #else