> Jakub Kicinski writes: > > > On Wed, 29 Sep 2021 11:54:46 -0700 Alexei Starovoitov wrote: > >> I'm missing something. Why do we need a separate flush() helper? > >> Can't we do: > >> char buf[64], *p; > >> p = xdp_mb_pointer(ctx, flags, off, len, buf); > >> read/write p[] > >> if (p == buf) > >> xdp_store_bytes(ctx, off, buf, len, flags); > > > > Sure we can. That's what I meant by "leave the checking to the program". > > It's bike shedding at this point. > > Yeah, let's discuss the details once we have a patch :) > > -Toke > Hi, I implemented the xdp_mb_pointer/xdp_mb_pointer_flush logic here (according to current discussion): https://github.com/LorenzoBianconi/bpf-next/commit/a5c61c0fa6cb05bab8caebd96aca5fbbd9510867 For the moment I have only defined two utility routines and I have not exported them in ebpf helpers since I need to check what are missing bits in the verifier code (but afaik this would be orthogonal with respect to the "helper code"): - bpf_xdp_pointer --> xdp_mb_pointer - bpf_xdp_copy_buf --> xdp_mb_pointer_flush In order to test them I have defined two new ebpf helpers (they use bpf_xdp_pointer/bpf_xdp_copy_buf internally): - bpf_xdp_load_bytes - bpf_xdp_store_bytes In order to test bpf_xdp_load_bytes/bpf_xdp_store_bytes + bpf_xdp_pointer/bpf_xdp_copy_buf I added some selftests here: https://github.com/LorenzoBianconi/bpf-next/commit/5661a491a890c00db744f2884b7ee3a6d0319384 Can you please check if the code above is aligned to current requirements or if it is missing something? If this code it is fine, I guess we have two option here: - integrate the commits above in xdp multi-buff series (posting v15) and work on the verfier code in parallel (if xdp_mb_pointer helper is not required from day0) - integrate verfier changes in xdp multi-buff series, drop bpf_xdp_load_bytes helper (probably we will still need bpf_xdp_store_bytes) and introduce bpf_xdp_pointer as new ebpf helper. I am fine both ways. If we decide for the second option I would need some guidance on verifier changes since I am not so familiar with that code. Regards, Lorenzo