Hello,
I am trying to implement an eBPF program that trims an UDP packet to a
predefined length. I am able to trim the packet (using the
bpf_change_tail helper) and also to update the ip->len and udp->length
fields. After changing the those fields I update the checksums using the
bpf_[l3,l4]_csum_replace helpers.
Due to the fact that the UDP checksum also covers the data itself, it is
necessary to update it. I tried to use the bpf_csum_diff together with
the bpf_l4_csum_replace helpers, however I found that is not possible to
pass a variable size to the bpf_csum_diff as it is marked as
"ARG_CONST_STACK_SIZE_OR_ZER" in the function prototype. This limitation
makes it impossible to update the checksum on different packets size as
the quantity of bytes to be trimmed depends on the length of the packet.
The code is available at [1] (please note that it is based on hover).
The error that I get when I tried to load the program is:
31: (61) r9 = *(u32 *)(r6 +48)
32: (61) r2 = *(u32 *)(r6 +0)
33: (07) r2 += -100
34: (67) r2 <<= 32
35: (77) r2 >>= 32
36: (b7) r8 = 0
37: (b7) r3 = 0
38: (b7) r4 = 0
39: (b7) r5 = 0
40: (85) call 28
R2 type=inv expected=imm
My questions are.
1. Am I missing another way to update the UDP checksum?
2. In case 1 is false, how could it be implemented? I think having a
function to trim the packet without having a way to update the checksum
is, in some way, useless.
Thanks in advance.
Mauricio V.
[1] https://gist.github.com/mvbpolito/77edb3b4e65cc03c92862b3f17452286
_______________________________________________
iovisor-dev mailing list
[email protected]
https://lists.iovisor.org/mailman/listinfo/iovisor-dev