Re: [iovisor-dev] AF_XDP query

2019-08-02 Thread William Tu
On Fri, Aug 2, 2019 at 3:23 AM Bjorn Topel wrote: > > On Tue, 30 Jul 2019 at 22:25, Kanthi P wrote: > > > > Hi, > > > > Is it possible to have 2 processes each with its own AF_XDP socket and its > > own UMEM? > > > Hi Kanthi, In the case of OVS AF_XDP netdev, we've used multiple PMD threads. Ea

Re: [iovisor-dev] minutes: IO Visor TSC/Dev Meeting

2019-01-09 Thread William Tu
he > springtime > - March-May timeframe > - 2 days? > > William > * Adding AF_XDP support to vSphere driver Sorry, I mean AF_XDP for veth driver. Thank you William > > > === Attendees === > Brenden Blanco > Quentin Monnet > Ja

[iovisor-dev] [PATCHv3 RFC 1/3] netdev-afxdp: add new netdev type for AF_XDP

2018-11-28 Thread William Tu
The patch creates a new netdev type called "afxdp" and re-uses some of the AF_XDP API implementation from xdpsock_user.c at linux sample code. By default, it binds a device's queue 0 and uses the generic XDP support to send and receive packets. Signed-off-by: William Tu --

[iovisor-dev] [PATCHv3 RFC 2/3] tests: add AF_XDP netdev test cases.

2018-11-28 Thread William Tu
interface. Signed-off-by: William Tu --- tests/automake.mk | 17 + tests/system-afxdp-macros.at| 153 tests/system-afxdp-testsuite.at | 26 + tests/system-afxdp-traffic.at | 1541 +++ 4 files changed, 1737 insertions(+) create mode

[iovisor-dev] [PATCHv3 RFC 3/3] FIXME: work around the failed cases.

2018-11-28 Thread William Tu
There are still two issues causing some test cases failed. This patch provides an work-around. Signed-off-by: William Tu --- lib/dpif-netdev.c| 2 +- tests/system-afxdp-macros.at | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dpif-netdev.c b/lib/dpif

[iovisor-dev] [PATCHv3 RFC 0/3] AF_XDP netdev support for OVS

2018-11-28 Thread William Tu
or more specific function to pull in pthread library.") - remove the dependency on libbpf and dpif-bpf. instead, use the built-in XDP_ATTACH feature. - data structure optimizations for better performance, see[1] - more test cases support William Tu (3): netdev-afxdp: add new netdev type for AF_X

[iovisor-dev] [PATCHv2 RFC 3/3] tests: add afxdp test cases.

2018-08-31 Thread William Tu
The patch adds the test framework for OVS using afxdp. Currently there are two test cases, using ping and http as traffic forwarding through ovs with 2 afxdp netdev. Signed-off-by: William Tu --- tests/automake.mk | 17 + tests/ofproto-macros.at | 1 + tests/system

[iovisor-dev] [PATCHv2 RFC 0/3] AF_XDP support for OVS

2018-08-31 Thread William Tu
r packet: 3985 v.s 18124 Next Step = 1) optimize the tx part as well as l2fwd 2) try the zero copy mode driver v1->v2: - add a list to maintain unused umem elements - remove copy from rx umem to ovs internal buffer - use hugetlb to reduce misses (not much difference) - use pmd mode netdev

[iovisor-dev] [PATCHv2 RFC 2/3] netdev-linux: add new netdev type afxdp.

2018-08-31 Thread William Tu
am/map to the netdev, and initializes the af_xdp socket. Signed-off-by: William Tu --- lib/automake.mk| 5 +- lib/dp-packet.c| 20 ++ lib/dp-packet.h| 27 +- lib/dpif-netdev-perf.h | 16 +- lib/dpif-netdev.c | 59 +++- lib/if_xdp.h | 79 + lib/netd

[iovisor-dev] [PATCHv2 RFC 1/3] afxdp: add ebpf code for afxdp and xskmap.

2018-08-31 Thread William Tu
AF_XDP requires attaching an xdp program and xskmap for each netdev. The patch provides these program/map and the loading and attaching implementation. Signed-off-by: William Tu --- acinclude.m4 | 1 + bpf/api.h | 6 ++ bpf/helpers.h | 2 ++ bpf/maps.h| 12

[iovisor-dev] [PATCH RFC 1/3] afxdp: add ebpf code for afxdp and xskmap.

2018-08-17 Thread William Tu
AF_XDP requires attaching an xdp program and xskmap for each netdev. The patch provides these program/map and the loading and attaching implementation. Signed-off-by: William Tu --- acinclude.m4 | 1 + bpf/api.h | 6 ++ bpf/helpers.h | 2 ++ bpf/maps.h| 12

[iovisor-dev] [PATCH RFC 2/3] netdev-linux: add new netdev type afxdp.

2018-08-17 Thread William Tu
am/map to the netdev, and initializes the af_xdp socket. Signed-off-by: William Tu --- lib/automake.mk | 3 +- lib/dpif-netdev.c | 74 - lib/if_xdp.h | 79 ++ lib/netdev-dummy.c| 1 + lib/netdev-linux.c| 741 ++

[iovisor-dev] [PATCH RFC 3/3] tests: add afxdp test cases.

2018-08-17 Thread William Tu
The patch adds the test framework for OVS using afxdp. Currently there are two test cases, using ping and http as traffic forwarding through ovs with 2 afxdp netdev. Signed-off-by: William Tu --- tests/automake.mk | 17 + tests/ofproto-macros.at | 1 + tests/system

[iovisor-dev] [PATCH RFC 0/3] AF_XDP support for OVS

2018-08-17 Thread William Tu
he patch series is based on the ovs-ebpf implementaion. A copy is put at: https://github.com/williamtu/ovs-ebpf/ branch afxdp-v1 William Tu (3): afxdp: add ebpf code for afxdp and xskmap. netdev-linux: add new netdev type afxdp. tests: add afxdp test cases. acinclude.m4|

[iovisor-dev] [RFC PATCHv2 12/13] ofproto: disable megaflow for bpf datapath.

2018-07-14 Thread William Tu
BPF datapath is always exact match. Signed-off-by: William Tu --- ofproto/ofproto-dpif-upcall.c | 4 1 file changed, 4 insertions(+) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 4f696fdca7f6..92a55d0b7768 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b

[iovisor-dev] [RFC PATCHv2 10/13] tests: Add "make check-bpf" traffic target.

2018-07-14 Thread William Tu
Add a separate test file tests/system-bpf-traffic.at for bpf testing. The test cases are a subset of the existing system-traffic.at, and with additional bpf-specific tests. When test passes, the log file is saved under: tests/system-bpf-testsuite.dir// Signed-off-by: William Tu Signed-off-by

[iovisor-dev] [RFC PATCHv2 11/13] vagrant: add ebpf support using ubuntu/bionic

2018-07-14 Thread William Tu
VAGRANT_VAGRANTFILE=Vagrantfile-eBPF vagrant up Signed-off-by: William Tu Signed-off-by: Yifeng Sun --- Makefile.am | 1 + Vagrantfile-eBPF | 99 2 files changed, 100 insertions(+) create mode 100644 Vagrantfile-eBPF diff --git a

[iovisor-dev] [RFC PATCHv2 09/13] utilities: Add ovs-bpfctl utility.

2018-07-14 Thread William Tu
From: Joe Stringer This new utility is used for standalone probing of BPF datapath state. Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- utilities/automake.mk | 9 ++ utilities/ovs-bpfctl.8

[iovisor-dev] [RFC PATCHv2 07/13] bpf: implement OVS BPF datapath.

2018-07-14 Thread William Tu
lookup. The protocol headers are auto-generated and defined at generated_headers.h. The bpf_flow_key is extracted using the P4-to-eBPF compiler from the bcc project. A couple of manual tweaks are required, see parser.h. Signed-off-by: William Tu Signed-off-by: Yifeng Sun Signed-off-by: Joe Stringer

[iovisor-dev] [RFC PATCHv2 13/13] xdp: early drop ipv6 packet.

2018-07-14 Thread William Tu
If not using ipv6, drop it in XDP. Signed-off-by: William Tu --- bpf/xdp.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/bpf/xdp.h b/bpf/xdp.h index 2d2102a6ba28..e71b268370c6 100644 --- a/bpf/xdp.h +++ b/bpf/xdp.h @@ -23,8 +23,26 @@ __section("xdp")

[iovisor-dev] [RFC PATCHv2 06/13] dpif-bpf-odp: Add bpf datapath interface and impl.

2018-07-14 Thread William Tu
From: Joe Stringer Add an implementation of the API between the userspace "Open vSwitch Datapath Protocol" and the BPF datapath. Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- lib/a

[iovisor-dev] [RFC PATCHv2 08/13] vswitch/bridge.c: add bpf datapath initialization.

2018-07-14 Thread William Tu
The patch initializes the bpf datapath when bridge starts. The check_support could be avoided since we know what datapath bpf program supports what feature. Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun

[iovisor-dev] [RFC PATCHv2 03/13] lib: implement perf event ringbuffer for upcall.

2018-07-14 Thread William Tu
From: Joe Stringer A flow missed by the match action table in ebpf triggers an upcall, which forwards the information to ovs-vswitchd using skb_perf_event_output helper function. The patch implements the userspace receiving logic. Signed-off-by: Joe Stringer Signed-off-by: William Tu

[iovisor-dev] [RFC PATCHv2 04/13] lib/bpf: add support for managing bpf program/map.

2018-07-14 Thread William Tu
From: Joe Stringer Through libbpf, the patch adds support for loading bpf program and maps, pinning the program and map to /sys/fs/bpf/ovs/, managing the file descriptor of each loaded map, and printting. Signed-off-by: Joe Stringer Co-authored-by: William Tu Co-authored-by: Yifeng Sun

[iovisor-dev] [RFC PATCHv2 05/13] dpif: add 'dpif-bpf' provider.

2018-07-14 Thread William Tu
=3139657 [2] http://openvswitch.org/support/ovscon2016/7/1120-tu.pdf Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- lib/dpif-bpf.c | 1996 +++ lib/dpif

[iovisor-dev] [RFC PATCHv2 01/13] ovs-bpf: add documentation and configuration.

2018-07-14 Thread William Tu
From: Joe Stringer The patch add bpf installation guide and configuration for linking to libbpf library. Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- Documentation/automake.mk | 1 + Documentation/index.rst | 2 +- Documentation/intro/install

[iovisor-dev] [RFC PATCHv2 02/13] netdev: add ebpf support for netdev provider.

2018-07-14 Thread William Tu
types, netdev-linux and netdev-vport, have the actual implementation. Signed-off-by: William Tu Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- include/linux/pkt_cls.h | 21 +++ lib/dpif-netdev.c | 29 ++-- lib/netdev-bsd.c| 2 + lib/netdev-dpdk.c | 2 + lib/n

[iovisor-dev] [RFC PATCHv2 00/13] OVS eBPF datapath.

2018-07-14 Thread William Tu
r (7): ovs-bpf: add documentation and configuration. netdev: add ebpf support for netdev provider. lib: implement perf event ringbuffer for upcall. lib/bpf: add support for managing bpf program/map. dpif: add 'dpif-bpf' provider. dpif-bpf-odp: Add bpf datapath interface and

Re: [iovisor-dev] [RFC PATCH 00/11] OVS eBPF datapath.

2018-07-05 Thread William Tu
> > d71962f ("bpf: allow map helpers access to map values directly") removes > that limitation from the verifier and should allow you to use map values > as map keys directly. 4.18-rc1 has it. > >> Thanks >> William Hi Paul, Thanks a lot! This is very helpful. I'm testing it now, works great so

Re: [iovisor-dev] [RFC PATCH 00/11] OVS eBPF datapath.

2018-07-04 Thread William Tu
On Tue, Jul 3, 2018 at 10:56 AM, Alexei Starovoitov wrote: > On Thu, Jun 28, 2018 at 07:19:35AM -0700, William Tu wrote: >> Hi Alexei, >> >> Thanks a lot for the feedback! >> >> On Wed, Jun 27, 2018 at 8:00 PM, Alexei Starovoitov >> wrote: >> > O

Re: [iovisor-dev] [RFC PATCH 00/11] OVS eBPF datapath.

2018-06-28 Thread William Tu
Hi Alexei, Thanks a lot for the feedback! On Wed, Jun 27, 2018 at 8:00 PM, Alexei Starovoitov wrote: > On Sat, Jun 23, 2018 at 05:16:32AM -0700, William Tu wrote: >> >> Discussion >> == >> We are still actively working on finishing the feature, currently

[iovisor-dev] [RFC PATCH 05/11] dpif: add 'dpif-bpf' provider.

2018-06-23 Thread William Tu
=3139657 [2] http://openvswitch.org/support/ovscon2016/7/1120-tu.pdf Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- lib/dpif-bpf.c | 1995 +++ lib/dpif

[iovisor-dev] [RFC PATCH 00/11] OVS eBPF datapath.

2018-06-23 Thread William Tu
: add 'dpif-bpf' provider. dpif-bpf-odp: Add bpf datapath interface and impl. utilities: Add ovs-bpfctl utility. William Tu (4): bpf: implement OVS BPF datapath. vswitch/bridge.c: add bpf datapath initialization. tests: Add "make check-bpf" traffic target.

[iovisor-dev] [RFC PATCH 01/11] ovs-bpf: add documentation and configuration.

2018-06-23 Thread William Tu
From: Joe Stringer The patch add bpf installation guide and configuration for linking to libbpf library. Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- Documentation/automake.mk | 1 + Documentation/index.rst | 2 +- Documentation/intro/install

[iovisor-dev] [RFC PATCH 04/11] lib/bpf: add support for managing bpf program/map.

2018-06-23 Thread William Tu
From: Joe Stringer Through libbpf, the patch adds support for loading bpf program and maps, pinning the program and map to /sys/fs/bpf/ovs/, managing the file descriptor of each loaded map, and printting. Signed-off-by: Joe Stringer Co-authored-by: William Tu Co-authored-by: Yifeng Sun

[iovisor-dev] [RFC PATCH 10/11] tests: Add "make check-bpf" traffic target.

2018-06-23 Thread William Tu
Add a separate test file tests/system-bpf-traffic.at for bpf testing. The test cases are a subset of the existing system-traffic.at, and with additional bpf-specific tests. When test passes, the log file is saved under: tests/system-bpf-testsuite.dir// Signed-off-by: William Tu Signed-off-by

[iovisor-dev] [RFC PATCH 03/11] lib: implement perf event ringbuffer for upcall.

2018-06-23 Thread William Tu
From: Joe Stringer A flow missed by the match action table in ebpf triggers an upcall, which forwards the information to ovs-vswitchd using skb_perf_event_output helper function. The patch implements the userspace receiving logic. Signed-off-by: Joe Stringer Signed-off-by: William Tu

[iovisor-dev] [RFC PATCH 08/11] vswitch/bridge.c: add bpf datapath initialization.

2018-06-23 Thread William Tu
The patch initializes the bpf datapath when bridge starts. The check_support could be avoided since we know what datapath bpf program supports what feature. Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun

[iovisor-dev] [RFC PATCH 06/11] dpif-bpf-odp: Add bpf datapath interface and impl.

2018-06-23 Thread William Tu
From: Joe Stringer Add an implementation of the API between the userspace "Open vSwitch Datapath Protocol" and the BPF datapath. Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- lib/a

[iovisor-dev] [RFC PATCH 11/11] vagrant: add ebpf support using ubuntu/bionic

2018-06-23 Thread William Tu
VAGRANT_VAGRANTFILE=Vagrantfile-eBPF vagrant up Signed-off-by: William Tu Signed-off-by: Yifeng Sun --- Makefile.am | 1 + Vagrantfile-eBPF | 99 2 files changed, 100 insertions(+) create mode 100644 Vagrantfile-eBPF diff --git a

[iovisor-dev] [RFC PATCH 02/11] netdev: add ebpf support for netdev provider.

2018-06-23 Thread William Tu
types, netdev-linux and netdev-vport, have the actual implementation. Signed-off-by: William Tu Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- include/linux/pkt_cls.h | 21 +++ lib/dpif-netdev.c | 29 ++-- lib/netdev-bsd.c| 2 + lib/netdev-dpdk.c | 2 + lib/n

[iovisor-dev] [RFC PATCH 09/11] utilities: Add ovs-bpfctl utility.

2018-06-23 Thread William Tu
From: Joe Stringer This new utility is used for standalone probing of BPF datapath state. Signed-off-by: Joe Stringer Signed-off-by: William Tu Signed-off-by: Yifeng Sun Co-authored-by: William Tu Co-authored-by: Yifeng Sun --- utilities/automake.mk | 9 ++ utilities/ovs-bpfctl.8

[iovisor-dev] [RFC PATCH 07/11] bpf: implement OVS BPF datapath.

2018-06-23 Thread William Tu
lookup. The protocol headers are auto-generated and defined at generated_headers.h. The bpf_flow_key is extracted using the P4-to-eBPF compiler from the bcc project. A couple of manual tweaks are required, see parser.h. Signed-off-by: William Tu Signed-off-by: Yifeng Sun Signed-off-by: Joe Stringer

Re: [iovisor-dev] GCOV coverage on BPF program

2018-06-19 Thread William Tu
On Tue, Jun 19, 2018 at 8:47 AM, Y Song wrote: > On Tue, Jun 19, 2018 at 7:54 AM, William Tu wrote: >> Hi, >> >> I'm trying to run coverage tests on my bpf program and it compiles fails. >> I guess BPF does not support '--coverage' flags? > > This

[iovisor-dev] GCOV coverage on BPF program

2018-06-19 Thread William Tu
Hi, I'm trying to run coverage tests on my bpf program and it compiles fails. I guess BPF does not support '--coverage' flags? root@boxes:~/ovs# clang-4.0 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function

Re: [iovisor-dev] BPF verifier: ctx+const+const is not allowed

2018-04-29 Thread William Tu via iovisor-dev
t;> we could possibly avoid it. >> >> Thanks, >> Yonghong >> >> >> On Sat, Apr 28, 2018 at 7:57 AM, William Tu via iovisor-dev >> wrote: >>> Hi, >>> >>> We're hitting a BPF verifier error saying >>> "dereferen

[iovisor-dev] BPF verifier: ctx+const+const is not allowed

2018-04-28 Thread William Tu via iovisor-dev
Hi, We're hitting a BPF verifier error saying "dereference of modified ctx ptr R1 off=36+0, ctx+const is allowed, ctx+const+const is not " but actually the 2nd const is 0. I don't know why compiler generate (r1+0) in this case: 602: (61) r4 = *(u32 *)(r1 +0) verifier log 594: (15) if r6

Re: [iovisor-dev] Is there information about eBPF + OVS ?

2017-12-27 Thread William Tu via iovisor-dev
Hi Heung, You can also find more details here: https://dl.acm.org/citation.cfm?id=3139657 William On Wed, Dec 27, 2017 at 7:52 AM, William Tu wrote: > Hi Heung, > > Thanks for your interest. > The eBPF+OVS project is still under development in our private repo. > We'll

Re: [iovisor-dev] Is there information about eBPF + OVS ?

2017-12-27 Thread William Tu via iovisor-dev
t; If you are using eBPF + OVS, please let me know if you have any insights >> about it. > > I'll redirect that question to William Tu (Cc'ed). > > -- > Best regards, > Jesper Dangaard Brouer > MSc.CS, Principal Kernel Engineer at Red Hat > LinkedIn: http

Re: [iovisor-dev] [PATCH RFC] bpf: add connection tracking helper functions

2017-09-04 Thread William Tu via iovisor-dev
On Sun, Sep 3, 2017 at 3:26 PM, Thomas Graf wrote: > On 1 September 2017 at 04:30, William Tu via iovisor-dev > wrote: > > This patch adds two BPF conntrack helper functions, bpf_ct_lookup() > > and bpf_ct_commit(), to enable the possibility of BPF stateful firewall. > >

Re: [iovisor-dev] [PATCH RFC] bpf: add connection tracking helper functions

2017-09-03 Thread William Tu via iovisor-dev
Hi Alexei, Thanks, I do see the lockdep complain now. I will switch to use GFP_ATOMIC. William On Sat, Sep 2, 2017 at 8:20 AM, William Tu wrote: > > > On Fri, Sep 1, 2017 at 10:53 PM, Alexei Starovoitov < > alexei.starovoi...@gmail.com> wrote: > >> On Fri, Sep 1,

Re: [iovisor-dev] [PATCH RFC] bpf: add connection tracking helper functions

2017-09-02 Thread William Tu via iovisor-dev
On Fri, Sep 1, 2017 at 10:53 PM, Alexei Starovoitov < alexei.starovoi...@gmail.com> wrote: > On Fri, Sep 1, 2017 at 4:30 AM, William Tu wrote: > > + > > + /* TODO: conntrack expectation */ > > + > > + nf_

[iovisor-dev] [PATCH RFC] bpf: add connection tracking helper functions

2017-09-01 Thread William Tu via iovisor-dev
ks. Thanks! Signed-off-by: William Tu Cc: Joe Stringer Cc: Daniel Borkmann Cc: Alexei Starovoitov --- include/uapi/linux/bpf.h | 31 + net/core/filter.c | 224 ++ samples/bpf/Makefile | 1 + s

Re: [iovisor-dev] bpf invalid stack off=-528

2017-04-20 Thread William Tu via iovisor-dev
On Wed, Apr 19, 2017 at 10:44 AM, William Tu wrote: > Thanks for the reply. > >> could you increase the max to 1M or so >> and see what the actual number of insns it needs? > > it takes 112,762 insns. And the kernel runs a while (~6 seconds) to verify it. > >> If

Re: [iovisor-dev] bpf invalid stack off=-528

2017-04-19 Thread William Tu via iovisor-dev
Thanks for the reply. > could you increase the max to 1M or so > and see what the actual number of insns it needs? it takes 112,762 insns. And the kernel runs a while (~6 seconds) to verify it. > If the program is short, as you say, can you debug > the state prunning to see why it's not recogniz

Re: [iovisor-dev] BPF unrolled loop doesn't work and its workaround

2017-04-19 Thread William Tu via iovisor-dev
. > In general, a message like this "back-edge from insn 240 to 219" indicates a > loop (back-edge ...). > > Compiler probably should give a warning if it is BPF backend to indicate > there > are loops in the byte code. I will look into this. > > Yonghong >

Re: [iovisor-dev] BPF unrolled loop doesn't work and its workaround

2017-04-18 Thread William Tu via iovisor-dev
egards, William On Tue, Apr 18, 2017 at 6:22 PM, Mauricio Vasquez wrote: > Hi William, > > On 04/18/2017 06:54 PM, William Tu via iovisor-dev wrote: >> >> Hi, >> >> I found that if the loop variable "int i" is used in the map lookup as >> bel

[iovisor-dev] BPF array initialization fails

2017-04-18 Thread William Tu via iovisor-dev
Hi, I have a struct like below: struct bpf_flow_keys { long src; }; I'm initializing an array of it using structures like below: struct bpf_flow_keys flow_mask_array[] = { {.src = }, {.src = }, }; instead of initialize it one-by-one struct bpf_flow_keys flow_

[iovisor-dev] BPF unrolled loop doesn't work and its workaround

2017-04-18 Thread William Tu via iovisor-dev
Hi, I found that if the loop variable "int i" is used in the map lookup as below: #pragma clang loop unroll(full) for (i = 0; i < 8; ++i) { struct bpf_flow_keys *mask; mask = bpf_map_lookup_elem(&flow_mask, &i); if (!mask) break; } Then the compiled BPF code d

Re: [iovisor-dev] bpf invalid stack off=-528

2017-04-14 Thread William Tu via iovisor-dev
rogram is too large. Processed 65537 insn Error fetching program/map! Regards, William On Fri, Feb 10, 2017 at 10:59 AM, Alexei Starovoitov wrote: > On Fri, Feb 10, 2017 at 9:08 AM, William Tu wrote: >> my program is too huge so I start with simple example using xdp1_kern.c >> I t

Re: [iovisor-dev] Describing howto read the eBPF generated ELF binary

2017-03-06 Thread William Tu via iovisor-dev
On Mon, Mar 6, 2017 at 7:07 AM, Jesper Dangaard Brouer via iovisor-dev wrote: > (repost with subscribed email) > Hi All, > > I've added a section to my eBPF documentation, about how to read the > eBPF generated ELF binary, and deduct the size of the compiled program > (mostly for kernel/samples/bp

Re: [iovisor-dev] BPF verifier: cannot add integer value with 0 upper zero bits to ptr_to_packet

2017-02-23 Thread William Tu via iovisor-dev
te: > On 02/17/2017 06:07 PM, William Tu via iovisor-dev wrote: >> >> Hi, >> >> I encountered another BPF verifier issue related to my previous one >> https://lists.iovisor.org/pipermail/iovisor-dev/2017-January/000603.html >> >> My guess is that when regi

[iovisor-dev] BPF verifier: cannot add integer value with 0 upper zero bits to ptr_to_packet

2017-02-17 Thread William Tu via iovisor-dev
Hi, I encountered another BPF verifier issue related to my previous one https://lists.iovisor.org/pipermail/iovisor-dev/2017-January/000603.html My guess is that when register spills to stack and restore, the state of imm upper zero bits does not get restore? Any comments are appreciated! This t

Re: [iovisor-dev] bpf invalid stack off=-528

2017-02-10 Thread William Tu via iovisor-dev
ther header structure definitions, I think it's the reason I use more than 512 byte stack memory. --William On Thu, Feb 9, 2017 at 9:48 AM, William Tu wrote: > On Thu, Feb 9, 2017 at 8:59 AM, Alexei Starovoitov > wrote: >> On Thu, Feb 9, 2017 at 8:43 AM, William Tu via io

Re: [iovisor-dev] bpf invalid stack off=-528

2017-02-09 Thread William Tu via iovisor-dev
On Thu, Feb 9, 2017 at 8:59 AM, Alexei Starovoitov wrote: > On Thu, Feb 9, 2017 at 8:43 AM, William Tu via iovisor-dev > wrote: >> >> $(CLANG) \ >> -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \ >> -Wno-compare-distinct-point

Re: [iovisor-dev] bpf invalid stack off=-528

2017-02-09 Thread William Tu via iovisor-dev
> You are generating the C files in the end, right? So the code > shown is what clang gets to compile; or does this come from > another llvm front end somehow? yes, we are generating C files, then clang v3.8, then LLVM v4.0. It's the same compile options used in sample/bpf/Makefile > > Also this

Re: [iovisor-dev] bpf invalid stack off=-528

2017-02-09 Thread William Tu via iovisor-dev
On Thu, Feb 9, 2017 at 5:11 AM, Daniel Borkmann wrote: > On 02/08/2017 09:22 PM, William Tu via iovisor-dev wrote: >> >> Hi, >> >> I have a program which I use around at most 300byte of local stack as >> below. The largest struct is the "struct Headers"

[iovisor-dev] bpf invalid stack off=-528

2017-02-08 Thread William Tu via iovisor-dev
Hi, I have a program which I use around at most 300byte of local stack as below. The largest struct is the "struct Headers" which is around 80 byte. However, when loading into the verifier, it says 393: (7b) *(u64 *)(r10 -56) = r1 394: (05) goto pc+56 451: (7b) *(u64 *)(r10 -528) = r0 invalid sta

Re: [iovisor-dev] BPF verifier: cannot add integer value with 0 upper zero bits to ptr_to_packet

2017-01-19 Thread William Tu via iovisor-dev
thanks for the patch, it works. >> from 52 to 80: R0=imm1,min_value=1,max_value=1 R1=pkt(id=0,off=0,r=34) >> R2=pkt_end R3=inv R4=imm272 R5=inv56,min_value=17,max_value=17 >> R6=pkt(id=0,off=26,r=34) R10=fp >> 80: (07) r4 += 71 >> 81: (18) r5 = 0xfff8 >> 83: (5f) r4 &= r5 >> 84: (77) r4 >>= 3

Re: [iovisor-dev] BPF verifier: cannot add integer value with 0 upper zero bits to ptr_to_packet

2017-01-18 Thread William Tu via iovisor-dev
eg->imm &= src_reg->imm; + + else if (opcode == BPF_AND && BPF_SRC(insn->code) == BPF_X && + src_reg->type == UNKNOWN_VALUE) + { + dst_reg->min_value &= src_reg->min_value; + dst_reg->max_value &= sr

Re: [iovisor-dev] direct packet access boundary check

2017-01-16 Thread William Tu via iovisor-dev
thanks! code generation is a good idea. On Fri, Jan 13, 2017 at 2:28 PM, Thomas Graf wrote: > On 12 January 2017 at 10:50, William Tu via iovisor-dev > wrote: >> Hi, >> >> I observed that for direct packet access, we have to use this data and >> data_end checkin

[iovisor-dev] direct packet access boundary check

2017-01-12 Thread William Tu via iovisor-dev
Hi, I observed that for direct packet access, we have to use this data and data_end checking pattern: int xdp_prog1(struct xdp_md *ctx) { void *data_end = (void *)(long)ctx->data_end; void *data = (void *)(long)ctx->data; struct ethhdr *eth = data; ... nh_off = sizeof(*eth);

[iovisor-dev] BPF verifier: cannot add integer value with 0 upper zero bits to ptr_to_packet

2017-01-12 Thread William Tu via iovisor-dev
Hi, I encounter the following BPF verifier error: from 28 to 30: R0=imm1,min_value=1,max_value=1 R1=pkt(id=0,off=0,r=22) R2=pkt_end R3=imm144,min_value=144,max_value=144 R4=imm0,min_value=0,max_value=0 R5=inv48,min_value=2054,max_value=2054 R10=fp 30: (bf) r5 = r3 31: (07) r5 += 23 32: (77) r5 >>=

Re: [iovisor-dev] LLVM error: couldn't allocate output register for constraint 'r' at line 473618

2017-01-09 Thread William Tu via iovisor-dev
sage. > > On Fri, Jan 6, 2017 at 1:30 PM, William Tu via iovisor-dev > wrote: >> thanks >> the code is at >> https://gist.github.com/williamtu/7e41392a34672d7b4574aee063ea4a3b >> >> >> On Fri, Jan 6, 2017 at 1:21 PM, Brenden Blanco wrote: >>> Yes,

Re: [iovisor-dev] LLVM error: couldn't allocate output register for constraint 'r' at line 473618

2017-01-06 Thread William Tu via iovisor-dev
thanks the code is at https://gist.github.com/williamtu/7e41392a34672d7b4574aee063ea4a3b On Fri, Jan 6, 2017 at 1:21 PM, Brenden Blanco wrote: > Yes, it would be helpful to share the code. > > On Fri, Jan 6, 2017 at 12:34 PM, William Tu via iovisor-dev > wrote: >> >&

[iovisor-dev] LLVM error: couldn't allocate output register for constraint 'r' at line 473618

2017-01-06 Thread William Tu via iovisor-dev
Hi, I'm adding parser and extra map lookup into the xdp1_kern.c and encounter this LLVM error. My environment: clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final) LLVM version 4.0.0svn I think it might be related to bpf map access, if I comment out the map access code, then the problem goes a

[iovisor-dev] modify and broadcast/multicast packet using tc eBPF

2016-12-16 Thread William Tu via iovisor-dev
Hi, I want to modify packet and broadcast/multicast to different ports. One way is that at tc ingress, attach a single eBPF program and call multiple "bpf_skb_clone_redirect()". For example: set_mac1, clone_redirect(1), set_mac2, inc_ttl, clone_redirect(2), set_mac3, clone_redirect(3), ... Someti

Re: [iovisor-dev] kprobe/kretprobe on cls_bpf_classify

2016-10-31 Thread William Tu via iovisor-dev
Hi Brenden, thanks, I will double check my kernel settings. On Sat, Oct 29, 2016 at 3:16 PM, Brenden Blanco wrote: > > > On Sat, Oct 29, 2016 at 1:27 AM, William Tu via iovisor-dev > wrote: >> >> Hi, >> >> I'm trying to measure the performance of my BPF

[iovisor-dev] kprobe/kretprobe on cls_bpf_classify

2016-10-28 Thread William Tu via iovisor-dev
Hi, I'm trying to measure the performance of my BPF programs, which attach to clsact. As a start, I thought I could simply measure the cycles spent on cls_bpf_classify(), because it's the wrapper calling into my BPF programs. However, it seems that kprobe can not probe cls_bpf_classify(), even th

Re: [iovisor-dev] clear/empty a bpf hash map

2016-10-24 Thread William Tu via iovisor-dev
Hi Alexei, Thanks for your reply. On Mon, Oct 24, 2016 at 7:01 PM, Alexei Starovoitov wrote: > On Mon, Oct 24, 2016 at 2:22 PM, William Tu via iovisor-dev > wrote: >> Hi, >> >> Is there an easy way to clear all entries in a BPF hash map? >> >> My use case:

[iovisor-dev] clear/empty a bpf hash map

2016-10-24 Thread William Tu via iovisor-dev
Hi, Is there an easy way to clear all entries in a BPF hash map? My use case: When my BPF userspace program and kernel BPF is running, I want to dynamically adding a new BPF hash map. IIUC, there is no way to do that. So at beginning when loading the BPF, I pre-allocate a pool of hash maps and al

Re: [iovisor-dev] BPF switch case LLVM error

2016-10-24 Thread William Tu via iovisor-dev
http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=57a09bf0a416700676e77102c28f9cfcb48267e0 > > On Sun, Oct 23, 2016 at 4:35 PM, William Tu via iovisor-dev > wrote: >> Thanks! I upgrade LLVM to 4.0.0 and this error no longer shows up. >> William >> &

Re: [iovisor-dev] BPF switch case LLVM error

2016-10-23 Thread William Tu via iovisor-dev
Thanks! I upgrade LLVM to 4.0.0 and this error no longer shows up. William On Sat, Oct 22, 2016 at 8:33 AM, Alexei Starovoitov wrote: > On Fri, Oct 21, 2016 at 11:38 PM, William Tu via iovisor-dev > wrote: >> Hi, >> I'm running into this LLVM ERROR at compile time. D

Re: [iovisor-dev] Assertion in samples/bpf test_maps.c and tracex3 seg fault

2016-10-21 Thread William Tu via iovisor-dev
test_map and tracex3 uses percpu array. Currently it might fail due to number of CPU mismatch between kernel and userspace. We will provide patch later. Regards, William On Thu, Sep 8, 2016 at 3:36 AM, Louie Lu via iovisor-dev wrote: > Hi everyone, > > I'm running kernel 4.8.0-rc5, and after run

[iovisor-dev] BPF switch case LLVM error

2016-10-21 Thread William Tu via iovisor-dev
Hi, I'm running into this LLVM ERROR at compile time. Does anyone seem this before or can give me some suggestions? thanks! --- LLVM ERROR: Cannot select: 0x3bafa28: ch = brind 0x3bc98f0:1, 0x3bc98f0 [ORD=1] [ID=9] 0x3bc98f0: i64,ch = load 0x3bb0db0:1, 0x3baf588, 0x3bc8c58 [ORD=1] [ID=8]

Re: [iovisor-dev] Question about XDP on multiple NICs with the same driver

2016-08-22 Thread William Tu via iovisor-dev
I see, thanks! I miss the fact that the xdp prog is attached to struct e1000_adapter *adapter, which is different per netdev, and thus different per ifindex. On Mon, Aug 22, 2016 at 4:47 PM, Alexei Starovoitov wrote: > On Mon, Aug 22, 2016 at 4:26 PM, William Tu via iovisor-dev > wrote:

[iovisor-dev] Question about XDP on multiple NICs with the same driver

2016-08-22 Thread William Tu via iovisor-dev
Hi, I'm not sure if we discussed this before, but I'm thinking that if I have two identical NICs (ex: two e1000 cards with ifindex 1 and 2), and I load the e1000.ko driver. At userspace, I run $ /samples/bpf/xdp 1 $ /samples/bpf/xdp 2 Then the latter XDP BPF actually overwrites the former because

[iovisor-dev] [RFC] samples/bpf: Add tunnel set/get tests.

2016-08-12 Thread William Tu via iovisor-dev
attached to tc egress and bpf_skb_get_* is attached to egress qdisc. A ping between two tunnels is used to verify correctness and the result of bpf_skb_get_* printed by bpf_trace_printk. Signed-off-by: William Tu --- samples/bpf/Makefile | 1 + samples/bpf/bpf_helpers.h | 8

Re: [iovisor-dev] bpf verification fails when accessing an array element

2016-08-08 Thread William Tu via iovisor-dev
27;s similar that once we check index is within correct range, the access to the array is safe. Regards, William > > Thanks > >> Regards, >> William >> >> On Mon, Apr 18, 2016 at 1:00 PM, Alexei Starovoitov >> wrote: >>> On Mon, Apr 18, 2016 a

Re: [iovisor-dev] bpf verification fails when accessing an array element

2016-08-08 Thread William Tu via iovisor-dev
Hi Alexei, I wonder if anyone is working on this issue currently? Or I could start learning from your "direct packet access" patch and see if could implement it? Thanks. Regards, William On Mon, Apr 18, 2016 at 1:00 PM, Alexei Starovoitov wrote: > On Mon, Apr 18, 2016 at 12:47 P

Re: [iovisor-dev] question about struct xdp_md

2016-08-01 Thread William Tu via iovisor-dev
Hi Alexei, Thanks! Looking at the xdp_convert_ctx_access(), now I understand that it's actually doesn't matter and the generated code is the same. Regards, William On Mon, Aug 1, 2016 at 10:02 AM, Alexei Starovoitov wrote: > On Sun, Jul 31, 2016 at 11:05:55PM -0700, William Tu vi

[iovisor-dev] question about struct xdp_md

2016-07-31 Thread William Tu via iovisor-dev
Hi, I'm looking at definition of xdp_md: struct xdp_md { __u32 data; __u32 data_end; }; I'm curious why are we using __u32? Isn't data and data_end an 8-byte pointer to the packet's buffer? For example in xdp2_kern.c int xdp_prog1(struct xdp_md *ctx) { void *data_end = (void *)(long)

Re: [iovisor-dev] Intel e1000 XDP driver support

2016-07-28 Thread William Tu via iovisor-dev
Hi Brenden, I've patched the e1000 driver using your link and tested on my VM. I can run samples/bpf/xdp1 and xdp2 with ping from the other machine without any issue. Thanks! Regards, William On Wed, Jul 27, 2016 at 1:32 PM, William Tu wrote: > thanks! I will try it. > > On Wed

Re: [iovisor-dev] Intel e1000 XDP driver support

2016-07-27 Thread William Tu via iovisor-dev
thanks! I will try it. On Wed, Jul 27, 2016 at 1:05 PM, Brenden Blanco wrote: > On Wed, Jul 27, 2016 at 12:50 PM, William Tu via iovisor-dev > wrote: >> >> Hi, >> >> I'm planning to test XDP in VM, I wonder if XDP has been ported to >> net-next, or

[iovisor-dev] Intel e1000 XDP driver support

2016-07-27 Thread William Tu via iovisor-dev
Hi, I'm planning to test XDP in VM, I wonder if XDP has been ported to net-next, or currently anyone is working on it? Thanks! Regards, William ___ iovisor-dev mailing list iovisor-dev@lists.iovisor.org https://lists.iovisor.org/mailman/listinfo/iovisor

Re: [iovisor-dev] Assertion fails at samples/bpf/test_maps

2016-06-22 Thread William Tu via iovisor-dev
Jesper Dangaard Brouer >>> wrote: >>> > On Tue, 21 Jun 2016 18:54:53 -0700 >>> > Alexei Starovoitov wrote: >>> > >>> >> On Tue, Jun 21, 2016 at 11:48 AM, William Tu via iovisor-dev >>> >> wrote: >>> >> &g

Re: [iovisor-dev] Failed to run sockex2 and sockex3 at latest samples/bpf/

2016-06-21 Thread William Tu via iovisor-dev
Hi Alexei, Thank you, I've sent the patch to netdev. Regards, William On Tue, Jun 21, 2016 at 6:45 PM, Alexei Starovoitov wrote: > On Tue, Jun 21, 2016 at 11:03 AM, William Tu via iovisor-dev > wrote: >> Hi, >> >> I'm trying to run sockex2 and sockex3 but

[iovisor-dev] Assertion fails at samples/bpf/test_maps

2016-06-21 Thread William Tu via iovisor-dev
Hi, I'm running test_maps under net-next/samples/bpf/, commit 601009780635. The code logic all make sense but I got the assertion errors / coredump for some unknown reason under different compiler optimization flags (-O0 and -O2). The test_hashmap_sanity() works fine but fails at test_percpu_hashm

[iovisor-dev] Failed to run sockex2 and sockex3 at latest samples/bpf/

2016-06-21 Thread William Tu via iovisor-dev
Hi, I'm trying to run sockex2 and sockex3 but got the error: [root@vm-dev bpf]# ./sockex2 failed to create a map: 1 Operation not permitted Then I found that I have max locked memory set to 64K, after reconfig to unlimited then the bpf map is created and sockex2/3 works fine. The hash_map created