Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1361045rdh; Fri, 27 Oct 2023 11:47:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGD7JQfXJyqn7diNgxBNCHUe5F2jUi6V7w2iiz1kin6hzDVfigIuM7sFUPrkszX649/8R/H X-Received: by 2002:a25:210:0:b0:d86:74e5:9469 with SMTP id 16-20020a250210000000b00d8674e59469mr3363699ybc.16.1698432473669; Fri, 27 Oct 2023 11:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698432473; cv=none; d=google.com; s=arc-20160816; b=xq9Pjbo2ot6y3HlcmD76XaQ06Qb/KQPTykQ1Wj2eGztocmnY3e/SaY1qrrq/5XGMsu yD+EV082cZZWzV/48hqCysrENVrrNYLTxTsZokIrQGZ46E4ObFjQm4cVSB0M/ZNjzMqt QQJ8gMvaHov2q+o+WVlkAI3YPRNnQoulIVhTlMfUDSOzdVJ7MlBFDzBYKbl0o6QJPOF0 E+KDWpAq5lS5rGu4vVltOBR6/oMx5LkqORJSJ5BYafNH8kJiCXjFIsH+Q1y5eXKzsRVF wxnfjRg0zhThquuR4jJEqpjW2J1ENqpsBwAsCRiWAfkNbtcwgv8DyMjgDmKDnQah1s+N EYbg== 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=cBgckGsvKO9J1GK/znjl6iHoBSLcZiVLBKbXHE7afz0=; fh=7mDMgSQE3N3e6YNeC1R84zsxONeKLaiIWoJ2MDBRnT4=; b=UHhYgxK0ZVjkDHaeH3vf7tDx7d0kutMQIjY1V6aXao13bcKmlLO20GVAm5czymk7FZ C26VMiIEwb3aTjcch5BJZHfI2M3QFuWvHpII7oKWBPvjrEqNpznn1kME0nnBU6G4CIzK 2D2CHLBqY0IEcdMIO4jEpPFqN6CjCEGRaQb3S8q+5g052Dp+xKMC/IP3BO7EVMXnQ6nd iF4AXqvmXyba41p7a2pc4lORYJtFQsHJbOCZEUm8NOizuPDvvhzRViZDNwtHKx+34dIO 5elqnLyLHBqytyqGMX3jk5GJVlo7q9FbDa0CTcHR9D+5uqTDhho/gG+6mINuy1ejPoIS Xoww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm2 header.b=YjRCiU4V; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="r9sLQcd/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b136-20020a25cb8e000000b00d9a628f83cfsi4069160ybg.362.2023.10.27.11.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 11:47:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm2 header.b=YjRCiU4V; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="r9sLQcd/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 C8DD780DCA72; Fri, 27 Oct 2023 11:47:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346601AbjJ0Sr0 (ORCPT + 99 others); Fri, 27 Oct 2023 14:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346617AbjJ0Sq4 (ORCPT ); Fri, 27 Oct 2023 14:46:56 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 532B01B3; Fri, 27 Oct 2023 11:46:49 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 8E54B5C0206; Fri, 27 Oct 2023 14:46:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 27 Oct 2023 14:46:48 -0400 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=fm2; t=1698432408; x= 1698518808; bh=cBgckGsvKO9J1GK/znjl6iHoBSLcZiVLBKbXHE7afz0=; b=Y jRCiU4V215Xa8DKjdZo2ika/BjTj4xklEkFzkgP93hYTijzwxkVXL9tF60nFe83W Qrn+W5Sj7xtT8E5/x/WUlHV+ddJPUFCcIdt4OTuq9j+F9CS5yahxs6UEwq8iqXik SGEHHURyAwnrJxYe3Kf9e+uwkaWTmlihnZ3jUBBUWlZ8usKt1CTf+BAHH3AV8nT6 f63x4mEUAgW+mdf8h0VUtZsb+3L0j3BIhH+IVgS5QjVVmZqVv0YqbGuJ6M0HE3ZO igoWSJ1GSPW1+Ct1JIEexA11JqTPur9K9nAg3dfSXmDXbwfofgKWpbOgQ/ASMVDT ZvntYTRKuBU1tWSDbtT9g== 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=fm3; t=1698432408; x= 1698518808; bh=cBgckGsvKO9J1GK/znjl6iHoBSLcZiVLBKbXHE7afz0=; b=r 9sLQcd/vGuZhTvGL4HgcjRmG5DXVLQMrZVMTs4gtWUaYMudPB408F2NQQVJt78L/ KfQYuEXplYpv9ZlAqwNl7ofwcmC+rR1zW8tqknbb4o4qslFupVYwuNBTddQ1wYVi x9tL7GF05vyndB+xBkA67Ao0qj9iWpySLxFJC4p1kIExSawJUDuq0jWU2+TI4OJN 3F0y2+l4ammfusvtHyWHrr0PgrD8yAAWzZgWOvxUlF5W6zZq/xDhNPgw7wMkMi1H 50JTLd7LT/swuqxqlEWSUlT8qFfTmrL+TQITXviTZmCUiT2qi8GRxBQBkTTywueO fFpbRhZwNFbUAX8jY1c9Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrleeggdduvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpefhvf evufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeffrghnihgvlhcuighuuceo ugiguhesugiguhhuuhdrgiihiieqnecuggftrfgrthhtvghrnhepgfefgfegjefhudeike dvueetffelieefuedvhfehjeeljeejkefgffeghfdttdetnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugiguhesugiguhhuuhdrgiihii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Oct 2023 14:46:47 -0400 (EDT) From: Daniel Xu To: ast@kernel.org, andrii@kernel.org, shuah@kernel.org, daniel@iogearbox.net, steffen.klassert@secunet.com, antony.antony@secunet.com Cc: 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, mykolal@fb.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, devel@linux-ipsec.org Subject: [RFC bpf-next 4/6] bpf: selftests: test_tunnel: Use vmlinux.h declarations Date: Fri, 27 Oct 2023 12:46:20 -0600 Message-ID: <15604344a2cf67a756eda4e37145fe46ce551afd.1698431765.git.dxu@dxuuu.xyz> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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]); Fri, 27 Oct 2023 11:47:50 -0700 (PDT) vmlinux.h declarations are more ergnomic, especially when working with kfuncs. The uapi headers are often incomplete for kfunc definitions. 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.0