Add a JumpIfX instruction which implements conditional jumps using
RegA and RegX. This is in addition to the pre-existing JumpIf
instruction which uses RegA and K.
This instruction / addressing mode is not mentionned in the original BPF
paper, but is supported by tools like bpf_asm, and has recently been
added to the kernel's filter.txt.
Simplify some of the parsing logic, and add a separate helper for
checking for "fake" JumpIfs.
Add JumpIfX support to the BPF vm.
Update testdata with JumpIfX instructions, and add tests
for both the assembler/disassembler and vm.
Fixesgolang/go#27814
Change-Id: I0c3f6ac7eb5b4cd4d9c5af8784ee2e8d25195a0a
GitHub-Last-Rev: 39a88165b2
GitHub-Pull-Request: golang/net#20
Reviewed-on: https://go-review.googlesource.com/c/136895
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Load extension in BPF is an overload of the load absolute
instruction with a 'negative offset'. Disassemble load
absolute instructions to load extension, if the offset
is 'negative', respectively > (0xFFFFFFFF - 0x1000).
Fixesgolang/go#18469
Change-Id: I13af8f5af89ce26b13a35d2b06879dd6e1c7434e
Reviewed-on: https://go-review.googlesource.com/34771
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
The instruction itself doesn't care what the bits it's twiddling represents,
even though the it was introduced to more efficiently manipulate IPv4 packets.
Change-Id: Ie65a6df4041ad2090060636ccf7128680fcf75b7
Reviewed-on: https://go-review.googlesource.com/21244
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>