Add IPv6 filter tests and implement BPF ALU instruction conversion#11301
Draft
Add IPv6 filter tests and implement BPF ALU instruction conversion#11301
Conversation
Copilot
AI
changed the title
[WIP] Add test function for IPv6 packet filters
Add IPv6 filter tests for BPF packet filtering
Oct 30, 2025
Co-authored-by: tomastigera <49207409+tomastigera@users.noreply.github.com>
88594e2 to
75aa8e0
Compare
tomastigera
reviewed
Nov 5, 2025
Comment on lines
+401
to
+411
| bpfAluAdd uint8 = 0x00 | ||
| bpfAluSub uint8 = 0x10 | ||
| bpfAluMul uint8 = 0x20 | ||
| bpfAluDiv uint8 = 0x30 | ||
| bpfAluOr uint8 = 0x40 | ||
| bpfAluAnd uint8 = 0x50 | ||
| bpfAluLsh uint8 = 0x60 | ||
| bpfAluRsh uint8 = 0x70 | ||
| bpfAluNeg uint8 = 0x80 | ||
| bpfAluMod uint8 = 0x90 | ||
| bpfAluXor uint8 = 0xa0 |
Contributor
There was a problem hiding this comment.
@copilot implement classic bpf to ebpf instruction conversion in function cBPF2eBPF in the class bpfClassAlu branch
Contributor
Author
There was a problem hiding this comment.
Implemented in commit 53d385f. Added conversion for all 11 ALU operations (add, sub, mul, div, or, and, lsh, rsh, neg, mod, xor) with support for both immediate (K) and register (X) source operands. Also implemented scratch memory operations (ST, STX, LD MEM, LDX MEM) using stack-based emulation.
The protochain test still fails due to BPF verifier rejecting loop structures - this is a known limitation when converting classic BPF loops to eBPF.
…memory operations - Implemented all ALU operations (add, sub, mul, div, or, and, lsh, rsh, neg, mod, xor) - Added support for both immediate (K) and register (X) source operands - Implemented scratch memory operations (ST, STX, LD MEM, LDX MEM) - Classic BPF scratch memory M[0-15] is emulated using stack slots The protochain test still fails due to BPF verifier rejecting loop structures, which is a fundamental limitation when converting classic BPF loops to eBPF. Co-authored-by: tomastigera <49207409+tomastigera@users.noreply.github.com>
Copilot
AI
changed the title
Add IPv6 filter tests for BPF packet filtering
Add IPv6 filter tests and implement BPF ALU instruction conversion
Nov 5, 2025
Contributor
|
This PR is stale because it has been open for 60 days with no activity. |
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.
The existing
TestFilterfunction only validates BPF filter expressions against IPv4 packets. This adds equivalent coverage for IPv6 and implements classic BPF to eBPF instruction conversion to support advanced filter expressions.Changes
IPv6 Filter Tests
TestFilterIPv6function mirroring the IPv4 test structureBPF Instruction Conversion
cBPF2eBPFfunctionImplementation Details
bpfClassStandbpfClassStxconstants for store instruction classesKnown Limitations
The
ip6 protochaintest still fails due to BPF verifier rejecting loop structures, which is a fundamental limitation when converting classic BPF programs with loops to eBPF without bounded loop support.Addresses lines 29-144 of
felix/bpf/ut/filter_test.goand implements ALU conversion infelix/bpf/filter/filter.go.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.