Skip to content

Commit f4d6ab3

Browse files
committed
Add the missing case for "ldx #pktlen" to bpf_image().
pcap_compile() does not produce it, but pcapint_filter_with_aux_data() implements it. With this change the latter and bpf_image() implement exactly the same instruction set.
1 parent b7a2eae commit f4d6ab3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

bpf_image.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ bpf_image(const struct bpf_insn *p, int n)
176176
operand = "#pktlen";
177177
break;
178178

179+
case BPF_LDX|BPF_W|BPF_LEN:
180+
op = "ldx";
181+
operand = "#pktlen";
182+
break;
183+
179184
case BPF_LD|BPF_W|BPF_IND:
180185
op = "ld";
181186
(void)snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k);

testprogs/TESTrun

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ my @accept_blocks = (
415415
(000) rsh #43981 ; 0x0074
416416
(000) rsh x ; 0x007c
417417
(000) ld #pktlen ; 0x0080
418+
(000) ldx #pktlen ; 0x0081
418419
(000) neg ; 0x0084
419420
(000) txa ; 0x0087
420421
(000) mod #43981 ; 0x0094

0 commit comments

Comments
 (0)