Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp100764rdd; Wed, 22 Nov 2023 10:22:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFm7Ag3lKmlrae9b4yRY9flofU4LF/ORLmz9ErjzuZzA9MAzOw0rUGQAoUJ0PILBFGkFJKk X-Received: by 2002:a17:90a:1951:b0:280:a01a:906a with SMTP id 17-20020a17090a195100b00280a01a906amr3454125pjh.5.1700677368670; Wed, 22 Nov 2023 10:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700677368; cv=none; d=google.com; s=arc-20160816; b=Z9K2idPUQQscG9bKYK3qEdb+UtyOpNIUXA6zgxRbr1r5N08cIDHhd2x8sk6C6BS7Pp XRinmcPuc786ZWcLwQktQJzRGKsvwY2Ol+L1nFtQV+O44TLE9slCmmSumkVtnfjcwCi8 ZIKx33mX/JcJbjqOAjxNM00At8pO7vfwKQlovrx7sUbDUZtvIYR5p3UNFn6A6IXn/04f 6XhHMKjpWtVrV7M95oy9iLCccZvUhbSjIlJTSrVru3pAU3mhYh1cQuusqBVsuXMRNNUm kqJ22eCeuAML0cJhbcuHY6l/GQmlR+a1G2pMW9K0UG8lUgvRoudoaWvQ0CQqZT53b+24 VREQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=WA5yo16lMwft5CPh1GKorx1eBd7zIhQykMs+an4tdPA=; fh=p6/jJmH8ymaPPPkPkGCoAO+quO2RGUs+oNx5YU3+VPA=; b=LHhziQw/a1MEKvtqLa0yBY5FFh9BNk7OFrCZf/GlE09i/9fh8h9UQjaI6wZybcmjAH R7ONg2UWYHIg2rlIJketWyBgNKndibTv8StNHsad0I9/4pWQTiPRJ0OCEzSy3MJAbgox +cWuAUIAz9x0j5p+C4418ALa4MYSipLUt6IHUVEMQ1iPFPhL4PG0rkOs07FZ39tFqMR/ QDYIeH5T05gUIdftq7bbIimAkg+5I/qB02uXMi9MmM5WrX75F+eR2IYKkW+52FCfQaA+ 3LgYvox4idJ6RbWT0OqZ3302bvmx1+iaGlRGrpwBD/8+9e9mMTYNvflQionHsTBnF78d YrIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="BFalt9Z/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=KRc5j5oI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z10-20020a170903018a00b001cf51f91979si10693669plg.332.2023.11.22.10.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm3 header.b="BFalt9Z/"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=KRc5j5oI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4128781EA72B; Wed, 22 Nov 2023 10:22:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344162AbjKVSV2 (ORCPT + 99 others); Wed, 22 Nov 2023 13:21:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344081AbjKVSVN (ORCPT ); Wed, 22 Nov 2023 13:21:13 -0500 Received: from new3-smtp.messagingengine.com (new3-smtp.messagingengine.com [66.111.4.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94DD8A4; Wed, 22 Nov 2023 10:21:08 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id EAAFC58055A; Wed, 22 Nov 2023 13:21:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 22 Nov 2023 13:21:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1700677267; x= 1700684467; bh=WA5yo16lMwft5CPh1GKorx1eBd7zIhQykMs+an4tdPA=; b=B Falt9Z/i6QDvEudBODypdblGWf4C34f3e4zwjOAQAJYvtG3NBAW/lttl0hmKGUeG sNezz1XKkZ/AIymaW2ZFOfEkh4f18HNcUlXP8z1IW3mu40BXMl5gIqMnFisWpei5 wCQzNtoPT9vhlBlv2zb22siDC1cy6H5QHW/6pmizxoUcxHx/sJaFWoxH/A5+XY6L BM9dL0enMkHhEhq3vtgYM1/BL4KdboEhM+yhErOu/H5eSMiAWBlv5cf33JMpwLlc kOc3Pvm1NSFrywV7RPM7Ckd6tBDjlVwVlrRPpbCF/hcpJ8ysFSRZDpSL7yZheKg/ cNbCN7/tvbAhYzsZfa/kQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1700677267; x= 1700684467; bh=WA5yo16lMwft5CPh1GKorx1eBd7zIhQykMs+an4tdPA=; b=K Rc5j5oIkr3tswv0HQiFshjicajn2sHsLWPsKJGIMQAJDgz2B1m2TsFTyzCNiPxI1 9QLbTpjgW2vFhfRa5COk6mDiGCwTMrMBT+qc2amMJkpk4cXIfdabLJ2X2rIL3UKG cz3VlgBpHATCeysbLosMdm8hnV4JJpdOzAp4/kqKY0GIYHqyeMz2CQaid3OQkTH8 RaDYAYcgaTaECpH0/l09+rok7/sg5A4a7OiWjjR7kcplE+cTZNOGTDRTWOT9Xgvm TwJR12Qn7tqtMW4nWNHJbS8bCrwbC8ZZccg8lf0SSUnCxs9IJLgIg5j80zFSt+5/ nAERvz0dCSY6Huo37VJpQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehuddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdefhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghlucgiuhcu oegugihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpefgfefggeejhfduie ekvdeuteffleeifeeuvdfhheejleejjeekgfffgefhtddtteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Nov 2023 13:21:06 -0500 (EST) From: Daniel Xu To: shuah@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ast@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com Cc: mykolal@fb.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linux-ipsec.org, netdev@vger.kernel.org Subject: [PATCH ipsec-next v1 5/7] bpf: selftests: test_tunnel: Use vmlinux.h declarations Date: Wed, 22 Nov 2023 11:20:26 -0700 Message-ID: X-Mailer: git-send-email 2.42.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 10:22:01 -0800 (PST) vmlinux.h declarations are more ergnomic, especially when working with kfuncs. The uapi headers are often incomplete for kfunc definitions. Co-developed-by: Antony Antony Signed-off-by: Antony Antony Signed-off-by: Daniel Xu --- .../selftests/bpf/progs/bpf_tracing_net.h | 1 + .../selftests/bpf/progs/test_tunnel_kern.c | 48 ++++--------------- 2 files changed, 9 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h index 0b793a102791..1bdc680b0e0e 100644 --- a/tools/testing/selftests/bpf/progs/bpf_tracing_net.h +++ b/tools/testing/selftests/bpf/progs/bpf_tracing_net.h @@ -26,6 +26,7 @@ #define IPV6_AUTOFLOWLABEL 70 #define TC_ACT_UNSPEC (-1) +#define TC_ACT_OK 0 #define TC_ACT_SHOT 2 #define SOL_TCP 6 diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c index f66af753bbbb..3065a716544d 100644 --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c @@ -6,62 +6,30 @@ * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "vmlinux.h" #include #include +#include "bpf_kfuncs.h" +#include "bpf_tracing_net.h" #define log_err(__ret) bpf_printk("ERROR line:%d ret:%d\n", __LINE__, __ret) -#define VXLAN_UDP_PORT 4789 +#define VXLAN_UDP_PORT 4789 +#define ETH_P_IP 0x0800 +#define PACKET_HOST 0 +#define TUNNEL_CSUM bpf_htons(0x01) +#define TUNNEL_KEY bpf_htons(0x04) /* Only IPv4 address assigned to veth1. * 172.16.1.200 */ #define ASSIGNED_ADDR_VETH1 0xac1001c8 -struct geneve_opt { - __be16 opt_class; - __u8 type; - __u8 length:5; - __u8 r3:1; - __u8 r2:1; - __u8 r1:1; - __u8 opt_data[8]; /* hard-coded to 8 byte */ -}; - struct vxlanhdr { __be32 vx_flags; __be32 vx_vni; } __attribute__((packed)); -struct vxlan_metadata { - __u32 gbp; -}; - -struct bpf_fou_encap { - __be16 sport; - __be16 dport; -}; - -enum bpf_fou_encap_type { - FOU_BPF_ENCAP_FOU, - FOU_BPF_ENCAP_GUE, -}; - int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx, struct bpf_fou_encap *encap, int type) __ksym; int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx, -- 2.42.1