Message ID | tencent_29D7ABD1744417031AA1B52C914B61158E07@qq.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp516333wru; Thu, 10 Nov 2022 19:29:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iNhNyrV++c7ok3BiGY1Dx8Ma15nwVBU/8Acrtvgd7HUjMwk2fGiSq9QGWcdmOa5hge83r X-Received: by 2002:a17:902:e8ce:b0:188:a1eb:9a8a with SMTP id v14-20020a170902e8ce00b00188a1eb9a8amr527316plg.153.1668137357832; Thu, 10 Nov 2022 19:29:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668137357; cv=none; d=google.com; s=arc-20160816; b=P4ACV0Gby7DpbZSiIvDXXUxUcbqUQPLq/Y42Cuh+U72Gs8X3C/eYS5ZU+RWetoFduD seTIHtMHakCOqPKE2IxRAD/mzP66cWAzcQr7FF4bh/FFtHgcuvwZgGQ15um7SkdQGvNL pkEsPX8QIMHWyqqu+bZ+9fdy/oXGiDreRHR3BMGBXzLbrANWbQiibnGaYlQpLUomgCxo hXYQy/uronMitQOAGlf2/+xUQwJ+x4tF6Z6x+N+EVjkP0qzS4Bk25w6MhoN8WrIxPd/t KKZDSipTUIpOmlNOZs88yKRiARqpDzrEcbXWsdyLaAAiDvq3nn8BMzVLkgEG009HoB9v iDKA== 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:date :subject:cc:to:from:message-id:dkim-signature; bh=VG03AryjN1xYa93c1hmpENqh0pc82ZJb7GUcVRfapEg=; b=C2q9jTRgoVGmmd4OSyDm88IiiD6+9vERKPanmvqPQ/1ORDtNayKHCJLrN5J0KLUolN qrSikC3b7+4boptZ76ciQQNAuYyd+7cOVpIqQQNzKTqX1BHwIVhmuc4gr2MmShRKyKMS 94gVaB57zfCOHUcFVlASjAY/OfsMsQq1YFcO/bI7HRF2rf2fiZ+ixtGYbVH/uqeyWPMv YMEYLQ5LDxD7EGHhMQKwtXbBl1u+u0FZm1OTXFnGEi2lRjLxYxmWFZSr+DBij3uAsfyK rFrKnolo9wrSY7rMgC4BaR9Pukd8SJ6Y5v9WhbflCDWXoKLp02i9k5BGt/gOaib1Raex FxEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=jxpyxrMz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i129-20020a625487000000b005633c373dcbsi986768pfb.147.2022.11.10.19.29.04; Thu, 10 Nov 2022 19:29:17 -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; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=jxpyxrMz; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbiKKD1r (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 22:27:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232335AbiKKD13 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 22:27:29 -0500 Received: from out162-62-58-211.mail.qq.com (out162-62-58-211.mail.qq.com [162.62.58.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C916F68C5F for <linux-kernel@vger.kernel.org>; Thu, 10 Nov 2022 19:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1668137187; bh=VG03AryjN1xYa93c1hmpENqh0pc82ZJb7GUcVRfapEg=; h=From:To:Cc:Subject:Date; b=jxpyxrMzXu0S6nnjluXJY6+WLuU/FGUCfS4ZQWZemR8HF/hYMjCx7c7MdxBir5kFP 48pXosBCB/s22b5nLKAa40AwQ7mIhaVSnwd5Jd+FtXChZ3h2WqwTfoGBqplF7qPj9M /KYZfgMv9/h2i6jncEPn21EKkPXIcOhq0WCN6fis= Received: from localhost.localdomain ([111.199.191.46]) by newxmesmtplogicsvrszb6-0.qq.com (NewEsmtp) with SMTP id 695818DF; Fri, 11 Nov 2022 11:26:21 +0800 X-QQ-mid: xmsmtpt1668137181t31ricq3i Message-ID: <tencent_29D7ABD1744417031AA1B52C914B61158E07@qq.com> X-QQ-XMAILINFO: NhUkPfKlCtQwXEHQjVhadMlQmPdB09PSlN9uaDXEq28soLLj8jyChox9gJTCqR REubEYCYiEeRGIsZfrpDgCR2Mkm6LMvFNCkFWnzgkRTY70pR7Fqx47jRFUEZf2U9RU9TR3ROn4WC eVH7+y0yHhajHrr6DK2C6CYOtCzXZy0Jf+UhIRGQxYCq3BoADv7UNO4eeFJM1A36OBtQROfg7UKh z/t8VQZl+IWhQIAg3dR/qF/k7yxJTPxGL/Kp7PxU/2/oMFY2pOS4wWPr3sGLWdv57/s8ovIKBAzG 2zXL6l/qCbSGaZdJ1yugAaRJnWBM0p/WJQ61XXq0V0UVmlTbr82VfGfZOHKYUv2+JXbTZXnjyH7f T72i/gaUnVPR8AmdaxnuQVPciL6r4D45K0c7o4hQu7ch1tjXLGppqO69PpN11Lwrqpw1UIvsXt1U n/Xy79DcTZcDATllKcLuwmP+mlgaRTZTMOebLj4T3VKnbfbM/I3eH4J6PNbPZfwyshk8sCcuE1hi QGI+23clUYl01WwnwOF5ghgTN8bb3XpX0ENJr4LtQXae+oYXH+PHRGPEVN8BJ2gChzSPEJFCdFPN AiPxmjT8D6vxhU2NQGl25jUfqUrGc3f3a83naZ1GQANUS19HmCAGBlQC421IoLWIV7/DRX29Z1Ew ZtxrGPv+sNy6E5g3aPp5SJVJPGVk6t6QadoWeuZC8aapdjOb4OXckbDE1MoLGvYVA/vvbmZj94xE cyxs3zXk1WsXygJ9JvVo6OMP4ACWTeyVh1XE15T95MXpJQu+R4xOpnGBHBY5sDKyZBKWUp1iJLpW xu3/q3VEBQZoGHVl+KNuACyKzeK4id4/S2Yop2kgmElAZsjhNu2Cy1XJ0drEZ3Dd6WlCEnugAWoP YP7XD8enx0UrBs8gCsuMoqWNz4eb+yDE/RVbeOLXO1r7/7H8I5MiOOv4r8zE++f1fvib229+WYX4 Cn8KXKf5Pn2iwFP5tROOBbL9jhFHI890FEjwDMQ2bgRajRuH0v5CWAD3ubDVHt From: Rong Tao <rtoax@foxmail.com> To: ast@kernel.org Cc: Rong Tao <rongtao@cestc.cn>, kernel test robot <lkp@intel.com>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, Lorenzo Bianconi <lorenzo@kernel.org>, Daniel Xu <dxu@dxuuu.xyz>, bpf@vger.kernel.org (open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)), linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH bpf-next] selftests/bpf: Fix error undeclared identifier 'NF_NAT_MANIP_SRC' Date: Fri, 11 Nov 2022 11:26:11 +0800 X-OQ-MSGID: <20221111032613.31106-1-rtoax@foxmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749168797598519601?= X-GMAIL-MSGID: =?utf-8?q?1749168797598519601?= |
Series |
[bpf-next] selftests/bpf: Fix error undeclared identifier 'NF_NAT_MANIP_SRC'
|
|
Commit Message
Rong Tao
Nov. 11, 2022, 3:26 a.m. UTC
From: Rong Tao <rongtao@cestc.cn> commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple") introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h, and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum nf_nat_manip_type to test_bpf_nf.c fix this error. How to reproduce the error: $ make -C tools/testing/selftests/bpf/ ... CLNG-BPF [test_maps] test_bpf_nf.bpf.o error: use of undeclared identifier 'NF_NAT_MANIP_SRC' bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC); ^ error: use of undeclared identifier 'NF_NAT_MANIP_DST' bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST); ^ 2 errors generated. Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/ Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Rong Tao <rongtao@cestc.cn> --- tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++ 1 file changed, 5 insertions(+)
Comments
On 11/11, Rong Tao wrote: > From: Rong Tao <rongtao@cestc.cn> > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple") > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h, > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum > nf_nat_manip_type to test_bpf_nf.c fix this error. > How to reproduce the error: > $ make -C tools/testing/selftests/bpf/ > ... > CLNG-BPF [test_maps] test_bpf_nf.bpf.o > error: use of undeclared identifier 'NF_NAT_MANIP_SRC' > bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC); > ^ > error: use of undeclared identifier 'NF_NAT_MANIP_DST' > bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST); > ^ > 2 errors generated. $ grep NF_NAT_MANIP_SRC ./tools/testing/selftests/bpf/tools/include/vmlinux.h NF_NAT_MANIP_SRC = 0, Doesn't look like your kernel config compiles netfilter nat modules? > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/ > Reported-by: kernel test robot <lkp@intel.com> > Signed-off-by: Rong Tao <rongtao@cestc.cn> > --- > tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++ > 1 file changed, 5 insertions(+) > diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > index 227e85e85dda..307ca166ff34 100644 > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > @@ -3,6 +3,11 @@ > #include <bpf/bpf_helpers.h> > #include <bpf/bpf_endian.h> > +enum nf_nat_manip_type { > + NF_NAT_MANIP_SRC, > + NF_NAT_MANIP_DST > +}; > + > #define EAFNOSUPPORT 97 > #define EPROTO 71 > #define ENONET 64 > -- > 2.31.1
> On 11/11, Rong Tao wrote: > > From: Rong Tao <rongtao@cestc.cn> > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple") > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h, > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum > > nf_nat_manip_type to test_bpf_nf.c fix this error. > > > How to reproduce the error: > > > $ make -C tools/testing/selftests/bpf/ > > ... > > CLNG-BPF [test_maps] test_bpf_nf.bpf.o > > error: use of undeclared identifier 'NF_NAT_MANIP_SRC' > > bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC); > > ^ > > error: use of undeclared identifier 'NF_NAT_MANIP_DST' > > bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST); > > ^ > > 2 errors generated. > > $ grep NF_NAT_MANIP_SRC > ./tools/testing/selftests/bpf/tools/include/vmlinux.h > NF_NAT_MANIP_SRC = 0, > > Doesn't look like your kernel config compiles netfilter nat modules? yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat is compiled as built-in. This issue occurs just if it is compiled as module. Regards, Lorenzo > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/ > > Reported-by: kernel test robot <lkp@intel.com> > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > --- > > tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > index 227e85e85dda..307ca166ff34 100644 > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > @@ -3,6 +3,11 @@ > > #include <bpf/bpf_helpers.h> > > #include <bpf/bpf_endian.h> > > > +enum nf_nat_manip_type { > > + NF_NAT_MANIP_SRC, > > + NF_NAT_MANIP_DST > > +}; > > + > > #define EAFNOSUPPORT 97 > > #define EPROTO 71 > > #define ENONET 64 > > -- > > 2.31.1 >
On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote: > > > On 11/11, Rong Tao wrote: > > > From: Rong Tao <rongtao@cestc.cn> > > > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple") > > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h, > > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info > > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum > > > nf_nat_manip_type to test_bpf_nf.c fix this error. > > > > > How to reproduce the error: > > > > > $ make -C tools/testing/selftests/bpf/ > > > ... > > > CLNG-BPF [test_maps] test_bpf_nf.bpf.o > > > error: use of undeclared identifier 'NF_NAT_MANIP_SRC' > > > bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC); > > > ^ > > > error: use of undeclared identifier 'NF_NAT_MANIP_DST' > > > bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST); > > > ^ > > > 2 errors generated. > > > > $ grep NF_NAT_MANIP_SRC > > ./tools/testing/selftests/bpf/tools/include/vmlinux.h > > NF_NAT_MANIP_SRC = 0, > > > > Doesn't look like your kernel config compiles netfilter nat modules? > > yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat > is compiled as built-in. This issue occurs just if it is compiled as module. Right, but if we unconditionally define this enum, I think you'll break the case where it's compiled as a built-in? Since at least in my vmlinux.h I have all the defines and this test includes vmlinux.h... > Regards, > Lorenzo > > > > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/ > > > Reported-by: kernel test robot <lkp@intel.com> > > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > > --- > > > tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > index 227e85e85dda..307ca166ff34 100644 > > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > @@ -3,6 +3,11 @@ > > > #include <bpf/bpf_helpers.h> > > > #include <bpf/bpf_endian.h> > > > > > +enum nf_nat_manip_type { > > > + NF_NAT_MANIP_SRC, > > > + NF_NAT_MANIP_DST > > > +}; > > > + > > > #define EAFNOSUPPORT 97 > > > #define EPROTO 71 > > > #define ENONET 64 > > > -- > > > 2.31.1 > >
> On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote: > > > > > On 11/11, Rong Tao wrote: > > > > From: Rong Tao <rongtao@cestc.cn> > > > > > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple") > > > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h, > > > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info > > > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum > > > > nf_nat_manip_type to test_bpf_nf.c fix this error. > > > > > > > How to reproduce the error: > > > > > > > $ make -C tools/testing/selftests/bpf/ > > > > ... > > > > CLNG-BPF [test_maps] test_bpf_nf.bpf.o > > > > error: use of undeclared identifier 'NF_NAT_MANIP_SRC' > > > > bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC); > > > > ^ > > > > error: use of undeclared identifier 'NF_NAT_MANIP_DST' > > > > bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST); > > > > ^ > > > > 2 errors generated. > > > > > > $ grep NF_NAT_MANIP_SRC > > > ./tools/testing/selftests/bpf/tools/include/vmlinux.h > > > NF_NAT_MANIP_SRC = 0, > > > > > > Doesn't look like your kernel config compiles netfilter nat modules? > > > > yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat > > is compiled as built-in. This issue occurs just if it is compiled as module. > > Right, but if we unconditionally define this enum, I think you'll > break the case where it's compiled as a built-in? > Since at least in my vmlinux.h I have all the defines and this test > includes vmlinux.h... yes, it is correct. > > > Regards, > > Lorenzo > > > > > > > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/ > > > > Reported-by: kernel test robot <lkp@intel.com> > > > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > > > --- > > > > tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++ > > > > 1 file changed, 5 insertions(+) > > > > > > > diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > index 227e85e85dda..307ca166ff34 100644 > > > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > @@ -3,6 +3,11 @@ > > > > #include <bpf/bpf_helpers.h> > > > > #include <bpf/bpf_endian.h> > > > > > > > +enum nf_nat_manip_type { > > > > + NF_NAT_MANIP_SRC, > > > > + NF_NAT_MANIP_DST > > > > +}; > > > > + > > > > #define EAFNOSUPPORT 97 > > > > #define EPROTO 71 > > > > #define ENONET 64 > > > > -- > > > > 2.31.1 > > >
On Fri, Nov 11, 2022 at 10:12 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote: > > > On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote: > > > > > > > On 11/11, Rong Tao wrote: > > > > > From: Rong Tao <rongtao@cestc.cn> > > > > > > > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple") > > > > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h, > > > > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info > > > > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum > > > > > nf_nat_manip_type to test_bpf_nf.c fix this error. > > > > > > > > > How to reproduce the error: > > > > > > > > > $ make -C tools/testing/selftests/bpf/ > > > > > ... > > > > > CLNG-BPF [test_maps] test_bpf_nf.bpf.o > > > > > error: use of undeclared identifier 'NF_NAT_MANIP_SRC' > > > > > bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC); > > > > > ^ > > > > > error: use of undeclared identifier 'NF_NAT_MANIP_DST' > > > > > bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST); > > > > > ^ > > > > > 2 errors generated. > > > > > > > > $ grep NF_NAT_MANIP_SRC > > > > ./tools/testing/selftests/bpf/tools/include/vmlinux.h > > > > NF_NAT_MANIP_SRC = 0, > > > > > > > > Doesn't look like your kernel config compiles netfilter nat modules? > > > > > > yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat > > > is compiled as built-in. This issue occurs just if it is compiled as module. > > > > Right, but if we unconditionally define this enum, I think you'll > > break the case where it's compiled as a built-in? > > Since at least in my vmlinux.h I have all the defines and this test > > includes vmlinux.h... > > yes, it is correct. And it will break the CI: $ grep NETFILTER tools/testing/selftests/bpf/config CONFIG_NETFILTER=y So yeah, not sure what to do here. The selftests expect "sane" configs (see that bpf/config above) which is not what the bot seems to be doing... > > > Regards, > > > Lorenzo > > > > > > > > > > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/ > > > > > Reported-by: kernel test robot <lkp@intel.com> > > > > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > > > > --- > > > > > tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++ > > > > > 1 file changed, 5 insertions(+) > > > > > > > > > diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > index 227e85e85dda..307ca166ff34 100644 > > > > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > @@ -3,6 +3,11 @@ > > > > > #include <bpf/bpf_helpers.h> > > > > > #include <bpf/bpf_endian.h> > > > > > > > > > +enum nf_nat_manip_type { > > > > > + NF_NAT_MANIP_SRC, > > > > > + NF_NAT_MANIP_DST > > > > > +}; > > > > > + > > > > > #define EAFNOSUPPORT 97 > > > > > #define EPROTO 71 > > > > > #define ENONET 64 > > > > > -- > > > > > 2.31.1 > > > >
On Fri, Nov 11, 2022 at 10:55 AM Stanislav Fomichev <sdf@google.com> wrote: > > On Fri, Nov 11, 2022 at 10:12 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote: > > > > > On Fri, Nov 11, 2022 at 9:54 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote: > > > > > > > > > On 11/11, Rong Tao wrote: > > > > > > From: Rong Tao <rongtao@cestc.cn> > > > > > > > > > > > commit 472caa69183f("netfilter: nat: un-export nf_nat_used_tuple") > > > > > > introduce NF_NAT_MANIP_SRC/DST enum in include/net/netfilter/nf_nat.h, > > > > > > and commit b06b45e82b59("selftests/bpf: add tests for bpf_ct_set_nat_info > > > > > > kfunc") use NF_NAT_MANIP_SRC/DST in test_bpf_nf.c. We copy enum > > > > > > nf_nat_manip_type to test_bpf_nf.c fix this error. > > > > > > > > > > > How to reproduce the error: > > > > > > > > > > > $ make -C tools/testing/selftests/bpf/ > > > > > > ... > > > > > > CLNG-BPF [test_maps] test_bpf_nf.bpf.o > > > > > > error: use of undeclared identifier 'NF_NAT_MANIP_SRC' > > > > > > bpf_ct_set_nat_info(ct, &saddr, sport, NF_NAT_MANIP_SRC); > > > > > > ^ > > > > > > error: use of undeclared identifier 'NF_NAT_MANIP_DST' > > > > > > bpf_ct_set_nat_info(ct, &daddr, dport, NF_NAT_MANIP_DST); > > > > > > ^ > > > > > > 2 errors generated. > > > > > > > > > > $ grep NF_NAT_MANIP_SRC > > > > > ./tools/testing/selftests/bpf/tools/include/vmlinux.h > > > > > NF_NAT_MANIP_SRC = 0, > > > > > > > > > > Doesn't look like your kernel config compiles netfilter nat modules? > > > > > > > > yes, in bpf kself-test config (tools/testing/selftests/bpf/config) nf_nat > > > > is compiled as built-in. This issue occurs just if it is compiled as module. > > > > > > Right, but if we unconditionally define this enum, I think you'll > > > break the case where it's compiled as a built-in? > > > Since at least in my vmlinux.h I have all the defines and this test > > > includes vmlinux.h... > > > > yes, it is correct. > > And it will break the CI: > It does break CI ([0]). We could use BPF CO-RE and ___suffix rule to avoid this. But we can also say that selftests/bpf/config{,<arch>} has to be used by bots that want to build BPF selftests. [0] https://github.com/kernel-patches/bpf/actions/runs/3446651033/jobs/5752592868 > $ grep NETFILTER tools/testing/selftests/bpf/config > CONFIG_NETFILTER=y > > So yeah, not sure what to do here. The selftests expect "sane" configs > (see that bpf/config above) which is not what the bot seems to be > doing... > > > > > Regards, > > > > Lorenzo > > > > > > > > > > > > > > > Link: https://lore.kernel.org/lkml/202210280447.STsT1gvq-lkp@intel.com/ > > > > > > Reported-by: kernel test robot <lkp@intel.com> > > > > > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > > > > > --- > > > > > > tools/testing/selftests/bpf/progs/test_bpf_nf.c | 5 +++++ > > > > > > 1 file changed, 5 insertions(+) > > > > > > > > > > > diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > > b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > > index 227e85e85dda..307ca166ff34 100644 > > > > > > --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > > +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c > > > > > > @@ -3,6 +3,11 @@ > > > > > > #include <bpf/bpf_helpers.h> > > > > > > #include <bpf/bpf_endian.h> > > > > > > > > > > > +enum nf_nat_manip_type { > > > > > > + NF_NAT_MANIP_SRC, > > > > > > + NF_NAT_MANIP_DST > > > > > > +}; > > > > > > + > > > > > > #define EAFNOSUPPORT 97 > > > > > > #define EPROTO 71 > > > > > > #define ENONET 64 > > > > > > -- > > > > > > 2.31.1 > > > > >
First of all, thank you all for your suggestions on this compilation issue. > It does break CI ([0]). We could use BPF CO-RE and ___suffix rule to > avoid this. But we can also say that selftests/bpf/config{,<arch>} has > to be used by bots that want to build BPF selftests. > > [0] https://github.com/kernel-patches/bpf/actions/runs/3446651033/jobs/5752592868 I try to use bpf_core_enum_value_exists() and bpf_core_enum_value(), However, as far as my knowledge is concerned, I have to redefine a NF_NAT_MANIP_SRC enumeration, but this would conflict with the situation where there is no secondary compilation problem. How do I fix this with CO-RE, it seems that there is no similar CO-RE+ __suffix solution for enumerations in selftests. Can you give me some tips or help me?
diff --git a/tools/testing/selftests/bpf/progs/test_bpf_nf.c b/tools/testing/selftests/bpf/progs/test_bpf_nf.c index 227e85e85dda..307ca166ff34 100644 --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c @@ -3,6 +3,11 @@ #include <bpf/bpf_helpers.h> #include <bpf/bpf_endian.h> +enum nf_nat_manip_type { + NF_NAT_MANIP_SRC, + NF_NAT_MANIP_DST +}; + #define EAFNOSUPPORT 97 #define EPROTO 71 #define ENONET 64