From: Yonghong Song <yonghong.song@linux.dev>
To: Daniel Xu <dxu@dxuuu.xyz>,
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,
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: Re: [PATCH ipsec-next v1 5/7] bpf: selftests: test_tunnel: Use vmlinux.h declarations
Date: Sat, 25 Nov 2023 16:34:36 -0800 [thread overview]
Message-ID: <eb34b5e0-caf0-472a-99fa-77b43cfce56e@linux.dev> (raw)
In-Reply-To: <c5f6a6686e1472e17014f5d015c8dacade9f053e.1700676682.git.dxu@dxuuu.xyz>
On 11/22/23 1:20 PM, Daniel Xu wrote:
> 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 <antony.antony@secunet.com>
> Signed-off-by: Antony Antony <antony.antony@secunet.com>
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
> .../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 <stddef.h>
> -#include <string.h>
> -#include <arpa/inet.h>
> -#include <linux/bpf.h>
> -#include <linux/if_ether.h>
> -#include <linux/if_packet.h>
> -#include <linux/if_tunnel.h>
> -#include <linux/ip.h>
> -#include <linux/ipv6.h>
> -#include <linux/icmp.h>
> -#include <linux/types.h>
> -#include <linux/socket.h>
> -#include <linux/pkt_cls.h>
> -#include <linux/erspan.h>
> -#include <linux/udp.h>
> +#include "vmlinux.h"
> #include <bpf/bpf_helpers.h>
> #include <bpf/bpf_endian.h>
> +#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));
In my particular setup, I have struct vxlanhdr defined in vmlinux.h so
I hit a compilation failure.
>
> -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,
next prev parent reply other threads:[~2023-11-26 0:34 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 18:20 [PATCH ipsec-next v1 0/7] Add bpf_xdp_get_xfrm_state() kfunc Daniel Xu
2023-11-22 18:20 ` [PATCH ipsec-next v1 1/7] bpf: xfrm: " Daniel Xu
2023-11-22 23:26 ` Alexei Starovoitov
2023-11-25 20:36 ` Yonghong Song
2023-11-26 4:38 ` Daniel Xu
2023-11-22 18:20 ` [PATCH ipsec-next v1 2/7] bpf: xfrm: Add bpf_xdp_xfrm_state_release() kfunc Daniel Xu
2023-11-22 18:20 ` [PATCH ipsec-next v1 3/7] bpf: selftests: test_tunnel: Use ping -6 over ping6 Daniel Xu
2023-11-22 18:20 ` [PATCH ipsec-next v1 4/7] bpf: selftests: test_tunnel: Mount bpffs if necessary Daniel Xu
2023-11-22 18:20 ` [PATCH ipsec-next v1 5/7] bpf: selftests: test_tunnel: Use vmlinux.h declarations Daniel Xu
2023-11-26 0:34 ` Yonghong Song [this message]
2023-11-26 4:34 ` Daniel Xu
2023-11-22 18:20 ` [PATCH ipsec-next v1 6/7] bpf: selftests: test_tunnel: Disable CO-RE relocations Daniel Xu
2023-11-26 0:51 ` Yonghong Song
2023-11-26 0:54 ` Alexei Starovoitov
2023-11-26 4:22 ` Yonghong Song
2023-11-26 20:14 ` Eduard Zingerman
2023-11-27 0:04 ` Daniel Xu
2023-11-27 1:52 ` Eduard Zingerman
2023-11-27 5:44 ` Yonghong Song
2023-11-27 5:53 ` Yonghong Song
2023-11-27 20:45 ` Daniel Xu
2023-11-27 21:32 ` Eduard Zingerman
2023-11-28 0:01 ` Daniel Xu
2023-11-28 4:06 ` Yonghong Song
2023-11-28 16:02 ` Andrii Nakryiko
2023-11-28 16:13 ` Daniel Xu
2023-11-28 16:17 ` Daniel Xu
2023-11-28 16:56 ` Yonghong Song
2023-11-28 16:19 ` Eduard Zingerman
2023-11-27 5:20 ` Yonghong Song
2023-11-22 18:20 ` [PATCH ipsec-next v1 7/7] bpf: xfrm: Add selftest for bpf_xdp_get_xfrm_state() Daniel Xu
2023-11-22 23:28 ` Alexei Starovoitov
2023-11-24 20:59 ` Daniel Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb34b5e0-caf0-472a-99fa-77b43cfce56e@linux.dev \
--to=yonghong.song@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=antony.antony@secunet.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=devel@linux-ipsec.org \
--cc=dxu@dxuuu.xyz \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).