bpf/tests: add support for scapy packets of 1036-1518 bytes#44314
Merged
joestringer merged 4 commits intocilium:mainfrom Feb 17, 2026
Merged
bpf/tests: add support for scapy packets of 1036-1518 bytes#44314joestringer merged 4 commits intocilium:mainfrom
joestringer merged 4 commits intocilium:mainfrom
Conversation
Fix error trace showing the incorrect CTX len when packet and buffer length mismatched. Signed-off-by: Marc Suñé <marc.sune@isovalent.com>
Throw build bug if packets exceed the __SCAPY_MAX_BUF (1518bytes) on BUF_DECL(). Signed-off-by: Marc Suñé <marc.sune@isovalent.com>
Remove unnecessary args to __ASSERT_TRACE_FAIL_BUF(). Signed-off-by: Marc Suñé <marc.sune@isovalent.com>
Commit e80be9e work-arounded the 128 byte limitation of the cilium builtins implementation by reimplementing (hack, innefficiently as noted in the commit msg) a simple version of memcpy/memcmp to be used by scapy assert checks (only). Unfortunately, when buffers exceed ~1036 bytes, the clang/LLVM optimizer removes memcpy code and (attempts to) use built-in instead (even at O1). Since the builtin has a hard limit of 128 8-byte words [1] (thanks Daniel Borkmann for the pointer), this leads to: In file included from _scapy_selftest.c:12: ./scapy.h:64:23: error: A call to built-in function 'memcpy' is not supported. 64 | *(__u64 *)(dst + i) = *(__u64 *)(src + i); | ^ ./scapy.h:64:23: error: A call to built-in function 'memcpy' is not supported. ./scapy.h:64:23: error: A call to built-in function 'memcpy' is not supported. ./scapy.h:64:23: error: A call to built-in function 'memcpy' is not supported. or if directly using `__bpf_memcpy_builtin()` (which calls `__builtin_memcpy()`): In file included from _scapy_selftest.c:7: In file included from ./pktgen.h:7: /home/msuneclo/dev/cilium/bpf/include/bpf/builtins.h:165:2: error: A call to built-in function 'memcpy' is not supported. 165 | __builtin_memcpy(d, s, len); This commit works-around this issue too by wrapping the original _scapy_memcpy() to perform chunked memcpys. Current packet size is limited to 1518 bytes (__SCAPY_MAX_BUF), but could be extended to 2K. [1] https://github.com/llvm/llvm-project/blob/a6929f7937696bb07788be6428fdcf1bf36775b5/llvm/lib/Target/BPF/BPFSelectionDAGInfo.h#L34 Signed-off-by: Marc Suñé <marc.sune@isovalent.com> Reported-by: Simone Magnani <simone.magnani@isovalent.com>
a9ac8a9 to
0f1147d
Compare
Member
Author
|
cc @smagnani96 |
Member
Author
|
/test |
ysksuzuki
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patchset:
build_bug()if scapy packets exceed 1518 bytes (current__SCAPY_MAX_BUF)__ASSERT_TRACE_FAIL_BUF()