Skip to content
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

aya-ebpf: XdpContext adjust_{head|tail|meta} API #949

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gabhijit
Copy link

@gabhijit gabhijit commented May 17, 2024

Added new public API for the XdpContext:

  • adjust_head : To grow the packet buffer at the beginning
  • adjist_tail : To grow the packet buffer at the end
  • adjust_meta : To grow metadata area

These API are handy for packet processing when additional headers etc. are to be pushed to the packet.

Also added these APIs using cargo xtask public-api --bless

Refs: #948


This change is Reviewable

Added new public API for the `XdpContext`:
- `adjust_head` : To grow the packet buffer at the beginning
- `adjist_tail` : To grow the packet buffer at the end
- `adjust_meta` : To grow metadata area

These API are handy for packet processing when additional headers etc.
are to be pushed to the packet.

Also added these APIs using `cargo xtask public-api --bless`

Refs: aya-rs#948
@gabhijit gabhijit marked this pull request as draft May 17, 2024 13:10
Copy link

netlify bot commented May 17, 2024

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 23d82dc
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/6647573c3a0a7f00081e3bcc
😎 Deploy Preview https://deploy-preview-949--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mergify mergify bot added aya-bpf This is about aya-bpf (kernel) test A PR that improves test cases or CI labels May 17, 2024
@FedericoRinaudi
Copy link

FedericoRinaudi commented May 22, 2024

I noticed from the comments in the code that passing a negative value can reduce the packet size, which would be very convenient for me. However, passing a negative value to the adjust_head method seems to increase the packet size. Am I missing something, or could there be an issue? Thank you.

@gabhijit
Copy link
Author

I noticed from the comments in the code that passing a negative value can reduce the packet size, which would be very convenient for me. However, passing a negative value to the adjust_head method seems to increase the packet size. Am I missing something, or could there be an issue? Thank you.

Yes, using the negative value adjust the data pointer to the lower value and thus can be used to 'push' a header say and the opposite to 'pop' a header.

Copy link
Collaborator

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ok - some comments

/// Adjusts the head of the Packet by given 'delta' (both positive and negative values are
/// possible.)
#[inline(always)]
pub fn adjust_head(&mut self, delta: crate::cty::c_int) -> Result<(), ()> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and in the other methods I think we should use i32, not c_int.

unsafe {
match bpf_xdp_adjust_head(self.ctx, delta) {
0 => Ok(()),
_ => Err(()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not return the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya-bpf This is about aya-bpf (kernel) test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants