-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add missing definitions for QNX8 for several BPF-related structures and constants #4769
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
Open
rafaeling
wants to merge
4
commits into
rust-lang:main
Choose a base branch
from
rafaeling:nto-bpf-ifreq-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+124
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| use crate::bpf_insn; | ||
|
|
||
| pub const BPF_LD: u16 = 0x00; | ||
| pub const BPF_LDX: u16 = 0x01; | ||
| pub const BPF_ST: u16 = 0x02; | ||
| pub const BPF_STX: u16 = 0x03; | ||
| pub const BPF_ALU: u16 = 0x04; | ||
| pub const BPF_JMP: u16 = 0x05; | ||
| pub const BPF_RET: u16 = 0x06; | ||
| pub const BPF_MISC: u16 = 0x07; | ||
| pub const BPF_W: u16 = 0x00; | ||
| pub const BPF_H: u16 = 0x08; | ||
| pub const BPF_B: u16 = 0x10; | ||
| pub const BPF_IMM: u16 = 0x00; | ||
| pub const BPF_ABS: u16 = 0x20; | ||
| pub const BPF_IND: u16 = 0x40; | ||
| pub const BPF_MEM: u16 = 0x60; | ||
| pub const BPF_LEN: u16 = 0x80; | ||
| pub const BPF_MSH: u16 = 0xa0; | ||
| pub const BPF_ADD: u16 = 0x00; | ||
| pub const BPF_SUB: u16 = 0x10; | ||
| pub const BPF_MUL: u16 = 0x20; | ||
| pub const BPF_DIV: u16 = 0x30; | ||
| pub const BPF_OR: u16 = 0x40; | ||
| pub const BPF_AND: u16 = 0x50; | ||
| pub const BPF_LSH: u16 = 0x60; | ||
| pub const BPF_RSH: u16 = 0x70; | ||
| pub const BPF_NEG: u16 = 0x80; | ||
| pub const BPF_MOD: u16 = 0x90; | ||
| pub const BPF_XOR: u16 = 0xa0; | ||
| pub const BPF_JA: u16 = 0x00; | ||
| pub const BPF_JEQ: u16 = 0x10; | ||
| pub const BPF_JGT: u16 = 0x20; | ||
| pub const BPF_JGE: u16 = 0x30; | ||
| pub const BPF_JSET: u16 = 0x40; | ||
| pub const BPF_K: u16 = 0x00; | ||
| pub const BPF_X: u16 = 0x08; | ||
| pub const BPF_A: u16 = 0x10; | ||
| pub const BPF_TAX: u16 = 0x00; | ||
| pub const BPF_TXA: u16 = 0x80; | ||
|
|
||
| f! { | ||
| 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 | ||
| } | ||
|
|
||
| pub fn BPF_MISCOP(code: u32) -> u32 { | ||
| code & 0xf8 | ||
| } | ||
|
|
||
| pub fn BPF_STMT(code: u16, k: u32) -> bpf_insn { | ||
| bpf_insn { | ||
| code, | ||
| jt: 0, | ||
| jf: 0, | ||
| k, | ||
| } | ||
| } | ||
|
|
||
| pub fn BPF_JUMP(code: u16, k: u32, jt: u8, jf: u8) -> bpf_insn { | ||
| bpf_insn { code, jt, jf, k } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| use crate::prelude::*; | ||
|
|
||
| s_no_extra_traits! { | ||
| pub union __c_anonymous_ifr_ifru { | ||
| pub ifru_addr: crate::sockaddr, | ||
| pub ifru_dstaddr: crate::sockaddr, | ||
| pub ifru_broadaddr: crate::sockaddr, | ||
| pub ifru_buffer: ifreq_buffer, | ||
| pub ifru_flags: [c_short; 2], | ||
| pub ifru_index: c_short, | ||
| pub ifru_jid: c_int, | ||
| pub ifru_metric: c_int, | ||
| pub ifru_mtu: c_int, | ||
| pub ifru_phys: c_int, | ||
| pub ifru_media: c_int, | ||
| pub ifru_data: *mut c_char, | ||
| pub ifru_cap: [c_int; 2], | ||
| pub ifru_fib: c_uint, | ||
| pub ifru_vlan_pcp: c_uchar, | ||
| } | ||
|
|
||
| pub struct ifreq { | ||
| /// if name, e.g. "en0" | ||
| pub ifr_name: [c_char; crate::IFNAMSIZ], | ||
| pub ifr_ifru: __c_anonymous_ifr_ifru, | ||
| } | ||
|
|
||
| pub struct ifreq_buffer { | ||
| pub length: size_t, | ||
| pub buffer: *mut c_void, | ||
| } | ||
| } |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these not available on 8.0 either?
If this change is related to making tests pass on 8.0 rather than as part of the BPF, would you be able to put it in a separate commit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, these are not available on 8.0, so this is part of the BPF topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't follow the connection - why are sysctl things like
HW_IOSTATSrelated to BPF?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion.
I was just referring specifically to the
BIOC*constants needed for BPF. I initially assumed that all of the constants in that section were BPF-related, but that turns out not to be the case. After checking the actual BIOC* values used for BPF on QNX 8, I added the new flag because the build was incorrectly picking up the constants from the else branch (intended for QNX 7.1/7.0 I think).There are many other constants defined there that are unrelated to BPF. My assumption is that
nto71_iosockandnto80share the same constant layout, but I dont work for QNX, so I had to assume a few things.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes more sense to me, but I'd like the maintainers to double check since it's a bit surprising.
@flba-eb @gh-tr @jonathanpallant @japaric could you review and/or test the changes to these constants on QNX 8?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks okay, but I suggest to inverse the logic:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these constants all only for the old network stack then? A comment would be nice then if you could add one @rafaeling.