[ovs-dev] attaching ebpf program to openvswitch vport driver

William Tu u9012063 at gmail.com
Fri Jan 3 19:38:44 UTC 2020


Hi Nicolas,

I was wrong. Actually with existing OVS internal device, the xdp generic mode
works fine.  Please see my test on kernel 5.3 below

#!/bin/bash
modprobe openvswitch
ovs-dpctl add-dp br0
ip addr add dev br0 10.1.1.2/24
ip link set dev br0 up

ip netns add at_ns0
ip link add p0 type veth peer name afxdp-p0
ip link set p0 netns at_ns0
ip link set dev afxdp-p0 up

ovs-dpctl add-if br0 afxdp-p0
ip netns exec at_ns0 sh << NS_EXEC_HEREDOC
ip addr add "10.1.1.1/24" dev p0
ip link set dev p0 up
NS_EXEC_HEREDOC

ovs-dpctl add-flow br0 "in_port(0),eth()" 1
ovs-dpctl add-flow br0 "in_port(1),eth()" 0

ping 10.1.1.1

Then insert the prog to drop
ip link set dev br0 xdpgeneric obj xdp1_kern.o sec xdp1
cat /sys/kernel/debug/tracing/trace_pipe
           <...>-91754 [001] ..s1 56247.205203: 0: xdp_prog1 pass
           <...>-91754 [001] ..s1 56248.229296: 0: xdp_prog1 pass

or remove the prog
ip link set dev br0 xdpgeneric off

Thanks
William

On Tue, Dec 17, 2019 at 9:22 AM Nicolas Bouliane
<nbouliane at digitalocean.com> wrote:
>
>
>>
>> In function internal_dev_recv, currently it calls
>> netif_rx(skb)
>> and this skips the generic xdp code path.
>>
>> I wonder if it's ok to replace netif_rx with
>> netif_receive_skb(skb)
>> Then the generic xdp should work.
>>
> Ohh, interesting, I'll check that !
> cheers,
> Nick


More information about the dev mailing list