[libbpf] Questions about XDP/TC


chenhengqi@...
 

1. How do I attach `BPF_PROG_TYPE_SCHED_CLS`/`classifier` BPF programs to specific data path(i.e. ingress or egress) using libbpf ?
 
I found some comments related in the source:
```
The **BPF_F_INGRESS** value in *flags* is used to make the distinction (ingress path is selected if the flag is present, egress path otherwise).
```
 
How can I get that flag, am I missing something ?
 
2. How do I attach `XDP` BPF programs using specific mode(i.e. xdpgeneric/xdpdrv)?
 
I tried googling but most of them lead to tc/ip tools. Thanks in advance.


Toke Høiland-Jørgensen
 

chenhengqi@outlook.com writes:

1. How do I attach `BPF_PROG_TYPE_SCHED_CLS`/`classifier` BPF programs to specific data path(i.e. ingress or egress) using libbpf ?
libbpf does not yet support attaching to TC hooks, but there is work in
progress to add this. See
https://lore.kernel.org/bpf/20210325120020.236504-4-memxor@gmail.com/

(an updated version should hopefully show up soon).

I found some comments related in the source:
```
The **BPF_F_INGRESS** value in *flags* is used to make the distinction (ingress path is selected if the flag is present, egress path otherwise).
```

How can I get that flag, am I missing something ?

2. How do I attach `XDP` BPF programs using specific mode(i.e.
xdpgeneric/xdpdrv)?
Just set XDP_FLAGS_SKB_MODE or XDP_FLAGS_DRV_MODE when attaching...

-Toke