Skip to content

Instantly share code, notes, and snippets.

@heatd
Created November 28, 2022 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heatd/4cc7912027caea63df8a96e73b185aca to your computer and use it in GitHub Desktop.
Save heatd/4cc7912027caea63df8a96e73b185aca to your computer and use it in GitHub Desktop.
struct bpf_instr insns[] = {
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, 12),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_IP, 0, 3),
BPF_STMT(BPF_LD + BPF_B + BPF_ABS, 23),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_TCP, 0, 1),
BPF_STMT(BPF_RET + BPF_K, (u32) -1),
BPF_STMT(BPF_RET + BPF_K, 0),
};
0: 55 push %rbp
1: 48 89 ec mov %rbp,%rsp
4: 0f b7 47 0c movzwl 0xc(%rdi),%eax
8: 86 e0 xchg %ah,%al
a: 3d 00 08 00 00 cmp $0x800,%eax
f: 0f 85 14 00 00 00 jne 0x29
15: 0f b6 47 17 movzbl 0x17(%rdi),%eax
19: 83 f8 06 cmp $0x6,%eax
1c: 0f 85 07 00 00 00 jne 0x29
22: b8 ff ff ff ff mov $0xffffffff,%eax
27: 5d pop %rbp
28: c3 ret
29: 31 c0 xor %eax,%eax
2b: 5d pop %rbp
2c: c3 ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment