BPF List
 help / color / mirror / Atom feed
* vmlinux.h overlap/conflict with network protocol definitions
@ 2024-04-04 17:09 Stephen Hemminger
  2024-04-04 18:16 ` Yonghong Song
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2024-04-04 17:09 UTC (permalink / raw)
  To: Luca Boccassi, daniel, ast, andrii, martin.lau, eddyz87; +Cc: bpf

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.

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-05 20:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-04 17:09 vmlinux.h overlap/conflict with network protocol definitions Stephen Hemminger
2024-04-04 18:16 ` Yonghong Song
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox