Re: vmlinux.h overlap/conflict with network protocol definitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 4 Apr 2024 11:16:32 -0700
Yonghong Song <yonghong.song@xxxxxxxxx> wrote:

> 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.


That is an example of header surgery which I would rather avoid having to carry
as long term technical debt baggage.






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux