On 06/28/2017 10:46 AM, Panneman, J.J. (Jeffrey) wrote:
Hi All, I posted this question in the Cillium Slack too, but I figured posting it here might help other people too. I checked out the Cillium source(from what I see makes use of the provided tc-helpers: https://github.com/cilium/cilium/blob/master/bpf/lib/csum.h), but is there an appropriate way to do checksum (re)calculation for UDP with XDP ? Since it does not really like long loops that much and the payload possibly being quite long. I don't really see a way to loop over the payload to recalculate the checksum, would anyone perhaps have a code snippet for this ?
Depends on the use-case, are you rewriting also UDP payload in XDP? If not, why is [1] not sufficient resp. a variant of that which calcs the diff? csum_diff() could be an option, but why not doing it in BPF itself? [1] http://lingrok.org/xref/linux-net-next/tools/testing/selftests/bpf/test_xdp.c#141