Skip to content

adding further BPF program flags for Linux. #4356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libc-test/semver/linux-aarch64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ B2500000
B3000000
B3500000
B4000000
BPF_A
BPF_ABS
BPF_ADD
BPF_ALU
BPF_B
BPF_CLASS
BPF_DIV
BPF_H
BPF_IMM
Expand All @@ -25,15 +27,21 @@ BPF_MEM
BPF_MISC
BPF_MISCOP
BPF_MOD
BPF_MODE
BPF_MSH
BPF_NEG
BPF_NET_OFF
BPF_OP
BPF_RET
BPF_RVAL
BPF_SIZE
BPF_SRC
BPF_ST
BPF_STMT
BPF_STX
BPF_SUB
BPF_TAX
BPF_TXA
BPF_W
BPF_X
BPF_XOR
Expand Down
8 changes: 8 additions & 0 deletions libc-test/semver/linux-loongarch64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ B2500000
B3000000
B3500000
B4000000
BPF_A
BPF_ABS
BPF_ADD
BPF_ALU
BPF_B
BPF_CLASS
BPF_DIV
BPF_H
BPF_IMM
Expand All @@ -25,15 +27,21 @@ BPF_MEM
BPF_MISC
BPF_MISCOP
BPF_MOD
BPF_MODE
BPF_MSH
BPF_NEG
BPF_NET_OFF
BPF_OP
BPF_RET
BPF_RVAL
BPF_SIZE
BPF_SRC
BPF_ST
BPF_STMT
BPF_STX
BPF_SUB
BPF_TAX
BPF_TXA
BPF_W
BPF_X
BPF_XOR
Expand Down
8 changes: 8 additions & 0 deletions libc-test/semver/linux-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ B2500000
B3000000
B3500000
B4000000
BPF_A
BPF_ABS
BPF_ADD
BPF_ALU
BPF_B
BPF_CLASS
BPF_DIV
BPF_H
BPF_IMM
Expand All @@ -25,15 +27,21 @@ BPF_MEM
BPF_MISC
BPF_MISCOP
BPF_MOD
BPF_MODE
BPF_MSH
BPF_NEG
BPF_NET_OFF
BPF_OP
BPF_RET
BPF_RVAL
BPF_SIZE
BPF_SRC
BPF_ST
BPF_STMT
BPF_STX
BPF_SUB
BPF_TAX
BPF_TXA
BPF_W
BPF_X
BPF_XOR
Expand Down
26 changes: 26 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3413,6 +3413,12 @@ pub const BPF_JSET: __u32 = 0x40;
pub const BPF_K: __u32 = 0x00;
pub const BPF_X: __u32 = 0x08;

// linux/filter.h

pub const BPF_A: __u32 = 0x10;
pub const BPF_TAX: __u32 = 0x00;
pub const BPF_TXA: __u32 = 0x80;

// linux/openat2.h
pub const RESOLVE_NO_XDEV: crate::__u64 = 0x01;
pub const RESOLVE_NO_MAGICLINKS: crate::__u64 = 0x02;
Expand Down Expand Up @@ -6030,6 +6036,26 @@ f! {
(x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)
}

pub fn BPF_CLASS(code: __u32) -> __u32 {
code & 0x07
}

pub fn BPF_SIZE(code: __u32) -> __u32 {
code & 0x18
}

pub fn BPF_MODE(code: __u32) -> __u32 {
code & 0xe0
}

pub fn BPF_OP(code: __u32) -> __u32 {
code & 0xf0
}

pub fn BPF_SRC(code: __u32) -> __u32 {
code & 0x08
}

pub fn BPF_RVAL(code: __u32) -> __u32 {
code & 0x18
}
Expand Down