From patchwork Wed Nov 30 14:42:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 13059998 X-Patchwork-Delegate: bpf@iogearbox.net 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 81902C4332F for ; Wed, 30 Nov 2022 14:43:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiK3Ono (ORCPT ); Wed, 30 Nov 2022 09:43:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbiK3Onm (ORCPT ); Wed, 30 Nov 2022 09:43:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33B4DBE12 for ; Wed, 30 Nov 2022 06:42:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669819366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PCyIoMGSiGDdstVNqCLmro74t1BNkUezYoweJpKNg/Q=; b=YZkLv6ln/nxREmhdhElreBFGYjRNwsVLagrJV4C5vV6XrCdfFzOTRp0gI/rAnnRbkM7/1+ /MyBNuWQlDDjd7i8X2eYn7f8waOzp01eu7kSBbrL23BrWAMMGVSZ3PIrjGyGoyR8lZtZTW IWiuLT9y3AuFwsyNGJNhslXwvi1H7p0= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-587-d-tfSih1PdWY3Tu4eq2xjg-1; Wed, 30 Nov 2022 09:42:44 -0500 X-MC-Unique: d-tfSih1PdWY3Tu4eq2xjg-1 Received: by mail-ed1-f71.google.com with SMTP id z3-20020a056402274300b0046b14f99390so5501760edd.9 for ; Wed, 30 Nov 2022 06:42:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PCyIoMGSiGDdstVNqCLmro74t1BNkUezYoweJpKNg/Q=; b=u2BFF7tt2doE3RTbUzRd1t02gjXYaKn9vqEeq4QJtXVxtwy53ocH+LrgnKSWA73nUb 65H6cd9FuPv7bO1JUgxbhz+wXfnhas19qmUdLJhTkTSbUMTdxEiQ6Mldvc26Gla4qE7O BqauzCKewD63qNau4N9GZqCS7biAoqqaX9nJiUu8k9Wc9jFoYZAQEnLfmgKxd/Oq+5N6 p/5wiRj7a+IXWqa2gGUH4Lht9LbxoNiBzDffBYgcX7Lv65EOChIrA3jgMzN5+/b8qXPu R14CRkhAT9L4mHtiPzVqlvnJlvFqMTJawE9Hb26qy/mHU+cx0LcdNBys0ioo96yvojiZ fe8g== X-Gm-Message-State: ANoB5pmV2G1a4Lw7X3EajfTns1Lstv177bXwcazF2Iz/L1YCJopS2oM1 C1aXrj5Dy3pIRL9h6L3zqzSiGpYSwWITI0+QLurVeHlFKUkATnfbQYgDlSq3bIcUVWsVZpUmB1Q mmbqqjs/03xDj X-Received: by 2002:a05:6402:189:b0:469:85d:2663 with SMTP id r9-20020a056402018900b00469085d2663mr53175115edv.56.1669819363123; Wed, 30 Nov 2022 06:42:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nznHyB26L9ozlWiRnu8euu+cP/TnaBByZcaYk6rRCEggUn6PevCLSEkOytUzStyKrRrbLcw== X-Received: by 2002:a05:6402:189:b0:469:85d:2663 with SMTP id r9-20020a056402018900b00469085d2663mr53175087edv.56.1669819362784; Wed, 30 Nov 2022 06:42:42 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id q25-20020a17090676d900b007803083a36asm707204ejn.115.2022.11.30.06.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 06:42:42 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 90A8C80ADF5; Wed, 30 Nov 2022 15:42:41 +0100 (CET) From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: Alexei Starovoitov , Lorenzo Bianconi Cc: Kumar Kartikeya Dwivedi , Jiri Benc , =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org Subject: [PATCH bpf 2/2] selftests/bpf: Add local definition of enum nf_nat_manip_type to bpf_nf test Date: Wed, 30 Nov 2022 15:42:40 +0100 Message-Id: <20221130144240.603803-2-toke@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221130144240.603803-1-toke@redhat.com> References: <20221130144240.603803-1-toke@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net The bpf_nf selftest calls the bpf_ct_set_nat_info() kfunc, which takes a parameter of type enum nf_nat_manip_type. However, if the nf_nat code is compiled as a module, that enum is not defined in vmlinux BTF, and compilation of the selftest fails. A previous patch suggested just hard-coding the enum values: https://lore.kernel.org/r/tencent_4C0B445E0305A18FACA04B4A959B57835107@qq.com However, this doesn't work as the compiler then complains about an incomplete type definition in the function prototype. Instead, just add a local definition of the enum to the selftest code. Fixes: b06b45e82b59 ("selftests/bpf: add tests for bpf_ct_set_nat_info kfunc") Signed-off-by: Toke Høiland-Jørgensen --- 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..6350d11ec6f6 100644 --- a/tools/testing/selftests/bpf/progs/test_bpf_nf.c +++ b/tools/testing/selftests/bpf/progs/test_bpf_nf.c @@ -43,6 +43,11 @@ struct bpf_ct_opts___local { u8 reserved[3]; } __attribute__((preserve_access_index)); +enum nf_nat_manip_type { + NF_NAT_MANIP_SRC, + NF_NAT_MANIP_DST +}; + struct nf_conn *bpf_xdp_ct_alloc(struct xdp_md *, struct bpf_sock_tuple *, u32, struct bpf_ct_opts___local *, u32) __ksym; struct nf_conn *bpf_xdp_ct_lookup(struct xdp_md *, struct bpf_sock_tuple *, u32,