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

Add support for Flow Dissector programs #1222

Merged
merged 1 commit into from
Mar 20, 2025
Merged

Conversation

tamird
Copy link
Member

@tamird tamird commented Mar 17, 2025

This picks up from #802.

I've addressed comments in a separate commit to somwhat ease review; this will
be squashed before merging.


This change is Reviewable

@tamird tamird requested a review from dave-tucker March 17, 2025 16:17
Copy link

netlify bot commented Mar 17, 2025

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ab8efd7
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/67dc3a7492aeb40008aba109
😎 Deploy Preview https://deploy-preview-1222--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.

Copy link

mergify bot commented Mar 17, 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 Mar 17, 2025
@mergify mergify bot requested a review from alessandrod March 17, 2025 16:18
@mergify mergify bot added aya This is about aya (userspace) aya-bpf This is about aya-bpf (kernel) aya-obj Relating to the aya-obj crate test A PR that improves test cases or CI labels Mar 17, 2025
Copy link
Member

@dave-tucker dave-tucker left a comment

Choose a reason for hiding this comment

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

Reviewed 14 of 14 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @alessandrod)


aya/src/programs/flow_dissector.rs line 95 at r2 (raw file):

                .insert(FlowDissectorLink::new(FdLink::new(link_fd)))
        } else {
            todo!("support attachment via BPF_PROG_ATTACH")

rather than marking TODO, can we add the implementation here? ISTR linking to one that could be basically copy/pasted from another program type with similar attach semantics - you'd just need to change a couple of constants.


test/integration-ebpf/src/test.rs line 51 at r2 (raw file):

#[flow_dissector]
pub fn test_flow(_ctx: FlowDissectorContext) -> u32 {
    // TODO: write an actual flow dissector. See tools/testing/selftests/bpf/progs/bpf_flow.c in the

I'm torn, I'd prefer a program here vs. a TODO.
Without a program written to exercise the aya-ebpf API it's hard to know if we have enough implemented to support a trivial example. For Aya userspace, this doesn't matter so much since you could bring a program written in C.

That said I can see value in merging what we have to encourage others to contribute or give us feedback on what's missing.


aya-ebpf-macros/src/lib.rs line 571 at r2 (raw file):

/// pub fn dissect(_ctx: FlowDissectorContext) -> u32 {
///     // TODO: do something useful here.
///     return 0

perhaps return one of the constants described in the doc here instead?
BPF_FLOW_DISSECTOR_CONTINUE?

@tamird tamird requested a review from dave-tucker March 17, 2025 16:50
Copy link
Member Author

@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.

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @alessandrod and @dave-tucker)


aya/src/programs/flow_dissector.rs line 95 at r2 (raw file):

Previously, dave-tucker (Dave Tucker) wrote…

rather than marking TODO, can we add the implementation here? ISTR linking to one that could be basically copy/pasted from another program type with similar attach semantics - you'd just need to change a couple of constants.

Ok, done, I think.


aya-ebpf-macros/src/lib.rs line 571 at r2 (raw file):

Previously, dave-tucker (Dave Tucker) wrote…

perhaps return one of the constants described in the doc here instead?
BPF_FLOW_DISSECTOR_CONTINUE?

Done.


test/integration-ebpf/src/test.rs line 51 at r2 (raw file):

Previously, dave-tucker (Dave Tucker) wrote…

I'm torn, I'd prefer a program here vs. a TODO.
Without a program written to exercise the aya-ebpf API it's hard to know if we have enough implemented to support a trivial example. For Aya userspace, this doesn't matter so much since you could bring a program written in C.

That said I can see value in merging what we have to encourage others to contribute or give us feedback on what's missing.

That's basically where I am with it :/

@tamird tamird force-pushed the flow-dissector branch 4 times, most recently from 2168292 to 401edc1 Compare March 17, 2025 18:37
Copy link
Member

@dave-tucker dave-tucker left a comment

Choose a reason for hiding this comment

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

:lgtm:

one small nit, but happy for this to merge either way.

Reviewable status: 8 of 14 files reviewed, 3 unresolved discussions (waiting on @alessandrod)


aya/src/programs/flow_dissector.rs line 104 at r4 (raw file):

                netns_fd,
                BPF_FLOW_DISSECTOR,
                CgroupAttachMode::Single,

nit. This could be CgroupAttachMode::default() which I think better captures the intent - we don't actually care about the value here.

Closes aya-rs#216.

Co-authored-by: Zenna Allwein <[email protected]>
Signed-off-by: Tamir Duberstein <[email protected]>
@tamird tamird requested a review from dave-tucker March 20, 2025 15:56
Copy link
Member Author

@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.

Reviewable status: 8 of 14 files reviewed, 2 unresolved discussions (waiting on @alessandrod and @dave-tucker)


aya/src/programs/flow_dissector.rs line 104 at r4 (raw file):

Previously, dave-tucker (Dave Tucker) wrote…

nit. This could be CgroupAttachMode::default() which I think better captures the intent - we don't actually care about the value here.

Done!

@tamird tamird merged commit 77b1c61 into aya-rs:main Mar 20, 2025
30 of 31 checks passed
@tamird tamird deleted the flow-dissector branch March 20, 2025 17:54
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) aya-bpf This is about aya-bpf (kernel) aya-obj Relating to the aya-obj crate test A PR that improves test cases or CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants