-
Notifications
You must be signed in to change notification settings - Fork 66
Add a simple SockOps program example #256
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
base: main
Are you sure you want to change the base?
Add a simple SockOps program example #256
Conversation
✅ Deploy Preview for aya-rs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
tamird
left a comment
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.
Mostly LGTM, a few comments. @vadorovsky can you TAL as well?
@tamird reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @skorobogatydmitry)
-- commits line 7 at r2:
Please squash to a single commit.
Code quote:
New commits in r1 on 11/24/2025 at 2:09 PM:
- 301d145: Add a simple SockOps program example
New commits in r2 on 11/25/2025 at 4:44 AM:
- 8188702: Fix lint errors:
- fit 80-symbols rows width
- add spaces for the code blocks
docs/book/programs/sockets.md line 29 at r2 (raw file):
Ok = 1, #[allow(dead_code)] Err = 2, // Some other number to indicate error
If 1 is success and negative is not supported, then what is 2?
docs/book/programs/sockets.md line 68 at r2 (raw file):
} // Stub panic handler to please the compiler
This is actually not a stub - we use an infinite loop to ensure that any panicking code paths are rejected by the verifier (because it forbids infinite loops).
docs/book/programs/sockets.md line 19 at r1 (raw file):
enum SockOpsResult { // From the official docs: Regardless of the type of operation, the program should always return 1 on success.
what are the official docs? can you please link to the source?
Nothing in particular. A
It's linked at the top of the page, I don't see the point to repeat it in the comment here. |
tamird
left a comment
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 needs a rebase after #258. Thanks!
@tamird reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @skorobogatydmitry)
docs/book/programs/sockets.md line 19 at r1 (raw file):
It's linked at the top of the page, I don't see the point to repeat it in the comment here.
Those aren't official docs, those are docs hosted by a company called isovalent. The source code is https://github.com/isovalent/ebpf-docs.
docs/book/programs/sockets.md line 29 at r2 (raw file):
Nothing in particular. A
enumwith single option looks odd and current implementation ofsock_opsrequires-> u32, so I can't add a negative option.
Then just toss the enum and return a literal 0?
- fit 80-symbols rows width - add spaces for the code blocks
c1e9247 to
97317d6
Compare
97317d6 to
5e1a549
Compare
I rebased the change and removed all mentions of docs.ebpf.io as an official source. Thank you for pointing this out! I left the enum around, as I don't have my playground to test the change handy. On the top of that, I think that having enum makes it clearer what the numbers are about, what's good for the code as an example. |
tamird
left a comment
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.
@codex review
@tamird reviewed 2 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @skorobogatydmitry).
docs/book/programs/sockets.md line 29 at r2 (raw file):
Previously, skorobogatydmitry (Dmitry Skorobogaty) wrote…
I rebased the change and removed all mentions of docs.ebpf.io as an official source. Thank you for pointing this out!
I left the enum around, as I don't have my playground to test the change handy. On the top of that, I think that having enum makes it clearer what the numbers are about, what's good for the code as an example.
I think it's fine to keep the enum, but the value of "2" is nonsense, right?
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // the program should always return 1 on success. | ||
| // A negative integer indicate a operation is not supported. | ||
| Ok = 1, | ||
| #[allow(dead_code)] | ||
| Err = 2, // Some other number to indicate error |
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.
Use negative value for SockOps error return
The example explains that SockOps programs should return 1 on success and a negative integer on unsupported operations, but the enum sets Err = 2. If a reader uses this enum for error handling, the program will return a non‑negative value that the kernel treats as success, so the intended error path won’t trigger. This is especially misleading because the comment explicitly documents negative values as the error contract.
Useful? React with 👍 / 👎.
This change is