diff options
| author | Asbjørn Sloth Tønnesen <[email protected]> | 2024-08-08 07:59:02 +0000 |
|---|---|---|
| committer | Martin KaFai Lau <[email protected]> | 2024-08-13 23:43:15 +0000 |
| commit | 92ec8b9367ab328cdd3d4409464137bc9775a2e5 (patch) | |
| tree | 63b767ecbc6273cc99d36a57fc72bbd3638e0578 /tools/testing/selftests/bpf/prog_tests/sockmap_basic.c | |
| parent | Merge branch 'add TCP_BPF_SOCK_OPS_CB_FLAGS to bpf_*sockopt()' (diff) | |
| download | kernel-92ec8b9367ab328cdd3d4409464137bc9775a2e5.tar.gz kernel-92ec8b9367ab328cdd3d4409464137bc9775a2e5.zip | |
selftests/bpf: Avoid subtraction after htons() in ipip tests
On little-endian systems, doing subtraction after htons()
leads to interesting results:
Given:
MAGIC_BYTES = 123 = 0x007B aka. in big endian: 0x7B00 = 31488
sizeof(struct iphdr) = 20
Before this patch:
__bpf_constant_htons(MAGIC_BYTES) - sizeof(struct iphdr) = 0x7AEC
0x7AEC = htons(0xEC7A) = htons(60538)
So these were outer IP packets with a total length of 123 bytes,
containing an inner IP packet with a total length of 60538 bytes.
After this patch:
__bpf_constant_htons(MAGIC_BYTES - sizeof(struct iphdr)) = htons(103)
Now these packets are outer IP packets with a total length of 123 bytes,
containing an inner IP packet with a total length of 103 bytes.
Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
Reviewed-by: Toke Høiland-Jørgensen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Martin KaFai Lau <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/sockmap_basic.c')
0 files changed, 0 insertions, 0 deletions
