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::programs::uprobe: add support for cookies #1133

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

ajwerner
Copy link
Member

@ajwerner ajwerner commented Jan 10, 2025

Fixes #1132.

Note that this change does not add support in the public API for kprobes or tracepoints, but it's a trivial matter of plumbing.

Along the way, the Uprobe::attach API is cleaned up to make the attachment location more coherent. The logic being: if we're going to be breaking the API anyway, may as well clean it up a bit.


This change is Reviewable

Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 628b7fb
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/678151d7f374570008099e92
😎 Deploy Preview https://deploy-preview-1133--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 This is about aya (userspace) test A PR that improves test cases or CI labels Jan 10, 2025
@ajwerner ajwerner force-pushed the uprobe-cookie branch 4 times, most recently from b31736c to 0c77783 Compare January 10, 2025 05:25
Copy link
Member

@tamird tamird left a comment

Choose a reason for hiding this comment

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

You'll need to run CARGO_CFG_BPF_TARGET_ARCH=x86_64 cargo +nightly xtask public-api --bless --target x86_64-unknown-linux-gnu to regenerate the API fixtures I think.

Reviewed 33 of 33 files at r1, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @ajwerner)


aya/src/programs/mod.rs line 223 at r1 (raw file):

    IOError(#[from] io::Error),

    /// Providing a bpf cookie for perf event links is not supported.

pretty far away from "perf event links" here and it's not in the variant name


test/integration-test/src/tests/uprobe_cookie.rs line 45 at r1 (raw file):

        let read: [u8; 8] = (*read)
            .try_into()
            .with_context(|| format!("data: {:?}", read.len()))

data: {read:x}? IOW do we want the data or just its length?


aya/src/sys/bpf.rs line 408 at r1 (raw file):

    attach_type: bpf_attach_type,
    flags: u32,
    args: Option<BpfLinkCreateArgs<'_>>,

nice.


aya/src/sys/bpf.rs line 903 at r1 (raw file):

            link,
            Err((_, e)) if e.raw_os_error() == Some(libc::EBADF),
        )

Might fit on one line

Code quote:

        matches!(
            link,
            Err((_, e)) if e.raw_os_error() == Some(libc::EBADF),
        )

aya/src/programs/uprobe.rs line 51 at r1 (raw file):

}

/// The location of in the target object file to which the uprobe is attached.

"of in"


aya/src/programs/uprobe.rs line 62 at r1 (raw file):

}

impl<'a> From<&'a str> for UProbeAttachLocation<'a> {

should there be a From<u64> impl?

Copy link
Member Author

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

You'll need to run CARGO_CFG_BPF_TARGET_ARCH=x86_64 cargo +nightly xtask public-api --bless --target x86_64-unknown-linux-gnu to regenerate the API fixtures I think.

Needed a rustup update to get this working, should be good now.

Reviewable status: 27 of 34 files reviewed, 5 unresolved discussions (waiting on @tamird)


aya/src/programs/mod.rs line 223 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

pretty far away from "perf event links" here and it's not in the variant name

Made the error more specific to the cause rather than the source.


aya/src/programs/uprobe.rs line 51 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

"of in"

Done.


aya/src/programs/uprobe.rs line 62 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

should there be a From<u64> impl?

Sure, done.


aya/src/sys/bpf.rs line 903 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

Might fit on one line

Done.


test/integration-test/src/tests/uprobe_cookie.rs line 45 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

data: {read:x}? IOW do we want the data or just its length?

Done.

Copy link

mergify bot commented Jan 10, 2025

Hey @alessandrod, this pull request changes the Aya Public API and requires your review.

@mergify mergify bot added the api/needs-review Makes an API change that needs review label Jan 10, 2025
@mergify mergify bot requested a review from alessandrod January 10, 2025 16:38
Copy link
Member

@tamird tamird left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 7 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ajwerner and @alessandrod)


aya/src/programs/uprobe.rs line 51 at r1 (raw file):

Previously, ajwerner wrote…

Done.

"to which the uprobe is to be attached"?


test/integration-test/src/tests/uprobe_cookie.rs line 45 at r2 (raw file):

        match read.try_into() {
            Ok(read) => seen.push(u64::from_le_bytes(read)),
            Err(_) => panic!("invalid ring buffer data: {read:x?}"),

Err(std::array::TryFromSliceError { .. }) for the OCD

Fixes aya-rs#1132.

Note that this change does not add support in the public API for kprobes
or tracepoints, but it's a trivial matter of plumbing.

Along the way, the Uprobe::attach API is cleaned up to make the
attachment location more coherent. The logic being: if we're going to be
breaking the API anyway, may as well clean it up a bit.

Furthermore, the aya::sys::bpf_link_attach function is cleaned up by
properly modeling the the union in the final field with a rust enum.
Copy link
Member Author

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

Reviewable status: 32 of 34 files reviewed, 2 unresolved discussions (waiting on @alessandrod and @tamird)


aya/src/programs/uprobe.rs line 51 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

"to which the uprobe is to be attached"?

Done.


test/integration-test/src/tests/uprobe_cookie.rs line 45 at r2 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

Err(std::array::TryFromSliceError { .. }) for the OCD

Done.

Copy link
Member

@tamird tamird left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @alessandrod)

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.

10/10 no notes thanks both!

@ajwerner ajwerner merged commit 114e7a6 into aya-rs:main Jan 11, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api/needs-review Makes an API change that needs review aya This is about aya (userspace) test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support cookies for uprobe attachment
3 participants