From: Yonghong Song <yonghong.song@linux.dev>
To: Stephen Hemminger <stephen@networkplumber.org>,
Luca Boccassi <bluca@debian.org>,
daniel@iogearbox.net, ast@kernel.org, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com
Cc: bpf@vger.kernel.org
Subject: Re: vmlinux.h overlap/conflict with network protocol definitions
Date: Thu, 4 Apr 2024 11:16:32 -0700 [thread overview]
Message-ID: <3ae7e58f-e62f-4d53-8b39-6e3fe1810014@linux.dev> (raw)
In-Reply-To: <20240404100901.7d6bc10f@hermes.local>
On 4/4/24 10:09 AM, Stephen Hemminger wrote:
> I am fixing the use of TC BPF in DPDK to use libbpf and bpftool.
> Luca recommended using vmlinux.h to address possible build and
> CO:RE issues. But it won't work.
>
> There are missing pieces such as definitions of IPV6 next header
> fields (in linux/ipv6.h) and TC actions.
>
> Without major hack surgery, not possible to use vmlinux.h instead.
> Since vmlinux.h defines may things that overlap with other headers.
>
> Using:
>
> $ /usr/sbin/bpftool -V
> bpftool v7.3.0
> using libbpf v1.3
> features:
>
> $ uname -r
> 6.6.15-amd64
>
> The change to BPF program to use vmlinux is:
>
> diff --git a/drivers/net/tap/bpf/tap_rss.c b/drivers/net/tap/bpf/tap_rss.c
> index 888b3bdc24..79f4ee31a1 100644
> --- a/drivers/net/tap/bpf/tap_rss.c
> +++ b/drivers/net/tap/bpf/tap_rss.c
> @@ -2,12 +2,7 @@
> * Copyright 2017 Mellanox Technologies, Ltd
> */
>
> -#include <linux/in.h>
> -#include <linux/if_ether.h>
> -#include <linux/ip.h>
> -#include <linux/ipv6.h>
> -#include <linux/pkt_cls.h>
> -#include <linux/bpf.h>
> +#include "vmlinux.h"
>
> #include <bpf/bpf_helpers.h>
> #include <bpf/bpf_endian.h>
>
> Resulting build failure is:
>
>
> ~/DPDK/tap $ ninja -C build
> ninja: Entering directory `build'
> [1/33] Generating drivers/net/tap/bpf/tap_rss.bpf.o with a custom command
> FAILED: drivers/net/tap/bpf/tap_rss.o
> /usr/bin/clang -O2 -Wall -Wextra -DTAP_MAX_QUEUES=16 -target bpf -g -c -idirafter /usr/include -idirafter /usr/include/x86_64-linux-gnu ../drivers/net/tap/bpf/tap_rss.c -o drivers/net/tap/bpf/tap_rss.o
> ../drivers/net/tap/bpf/tap_rss.c:116:8: error: use of undeclared identifier 'IPPROTO_HOPOPTS'
> case IPPROTO_HOPOPTS:
> ^
> ../drivers/net/tap/bpf/tap_rss.c:117:8: error: use of undeclared identifier 'IPPROTO_ROUTING'
> case IPPROTO_ROUTING:
> ^
> ../drivers/net/tap/bpf/tap_rss.c:118:8: error: use of undeclared identifier 'IPPROTO_DSTOPTS'
> case IPPROTO_DSTOPTS:
> ^
> ../drivers/net/tap/bpf/tap_rss.c:126:8: error: use of undeclared identifier 'IPPROTO_FRAGMENT'
> case IPPROTO_FRAGMENT:
> ^
> ../drivers/net/tap/bpf/tap_rss.c:210:33: error: use of undeclared identifier 'ETH_P_IP'
> if (skb->protocol == bpf_htons(ETH_P_IP))
> ^
> ../drivers/net/tap/bpf/tap_rss.c:210:33: error: use of undeclared identifier 'ETH_P_IP'
> ../drivers/net/tap/bpf/tap_rss.c:210:33: error: use of undeclared identifier 'ETH_P_IP'
> ../drivers/net/tap/bpf/tap_rss.c:210:33: error: use of undeclared identifier 'ETH_P_IP'
> ../drivers/net/tap/bpf/tap_rss.c:212:38: error: use of undeclared identifier 'ETH_P_IPV6'
> else if (skb->protocol == bpf_htons(ETH_P_IPV6))
> ^
> ../drivers/net/tap/bpf/tap_rss.c:212:38: error: use of undeclared identifier 'ETH_P_IPV6'
> ../drivers/net/tap/bpf/tap_rss.c:212:38: error: use of undeclared identifier 'ETH_P_IPV6'
> ../drivers/net/tap/bpf/tap_rss.c:212:38: error: use of undeclared identifier 'ETH_P_IPV6'
> ../drivers/net/tap/bpf/tap_rss.c:248:10: error: use of undeclared identifier 'TC_ACT_OK'
> return TC_ACT_OK;
> ^
> ../drivers/net/tap/bpf/tap_rss.c:252:10: error: use of undeclared identifier 'TC_ACT_OK'
> return TC_ACT_OK;
> ^
> ../drivers/net/tap/bpf/tap_rss.c:256:9: error: use of undeclared identifier 'TC_ACT_PIPE'
> return TC_ACT_PIPE;
> ^
> 15 errors generated.
> ninja: build stopped: subcommand failed.
This is a known issue as currently vmlinux.h does not support macros.
There are some efforts by Edward Zingerman to support this but this has
not done yet. At the same time, you could have a trivial header file
like
https://github.com/torvalds/linux/blob/master/tools/testing/selftests/bpf/progs/bpf_tracing_net.h
to be used for bpf program and then your bpf program with vmlinux.h can
have much easier CORE support.
next prev parent reply other threads:[~2024-04-04 18:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 17:09 vmlinux.h overlap/conflict with network protocol definitions Stephen Hemminger
2024-04-04 18:16 ` Yonghong Song [this message]
2024-04-04 18:27 ` Stephen Hemminger
2024-04-04 21:45 ` Andrii Nakryiko
2024-04-05 0:52 ` Stephen Hemminger
2024-04-05 17:31 ` Andrii Nakryiko
2024-04-05 19:37 ` Stephen Hemminger
2024-04-05 20:00 ` Andrii Nakryiko
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=3ae7e58f-e62f-4d53-8b39-6e3fe1810014@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bluca@debian.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=martin.lau@linux.dev \
--cc=stephen@networkplumber.org \
/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