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: Use OwnedFd in FdLink. #709

Merged
merged 1 commit into from
Aug 2, 2023
Merged

aya: Use OwnedFd in FdLink. #709

merged 1 commit into from
Aug 2, 2023

Conversation

nrxus
Copy link
Contributor

@nrxus nrxus commented Aug 1, 2023

I had to add a few into_raw_fd() to avoid ballooning up this PR with changes to MapData or to ProgramData (because the syscall to BPF_OBJ_GET now returns an OwnedFd) Those are more involved so they should each be their own PR.

As far as I could tell there weren't any leaked file descriptors being fixed by this, this is just future proofing.


This change is Reviewable

@netlify
Copy link

netlify bot commented Aug 1, 2023

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8ebf0ac
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/64ca84f38c1d6d00096d56b1
😎 Deploy Preview https://deploy-preview-709--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 the aya This is about aya (userspace) label Aug 1, 2023
call: "BPF_OBJ_GET",
io_error,
})?;
pub fn from_fd(fd: OwnedFd) -> Result<MapData, MapError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

technically a breaking API change but the old API was unsafe as it relied on the user knowing not to close the RawFd after the fact. This makes it more explicit that this function will take ownership of the file descriptor.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should do this in a separate PR? You're only changing the signature
but otherwise everything else stays the same. Why not do the signature change
when we actually change the impl?

Copy link
Member

Choose a reason for hiding this comment

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

That would mean the bpf_map_info_by_fd call on line 591 would require an unsafe call to BorrowedFd::borrow_raw.

I'm OK with either approach.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah the bpf_map_info_by_fd change is also not related to links (it's for maps), so I think it could have gone in a separate PR too (the PR does state this is about links).

MapData::from_fd is effectively the only public API change in this PR - without this change I wouldn't have had to look at the PR at all :P

That said no need to add more churn! Thanks a lot @nrxus, looks good I'm approving

@mergify
Copy link

mergify bot commented Aug 1, 2023

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

@mergify mergify bot requested a review from alessandrod August 1, 2023 08:57
@mergify mergify bot added api/needs-review Makes an API change that needs review test A PR that improves test cases or CI labels Aug 1, 2023
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 20 of 20 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @alessandrod and @nrxus)

a discussion (no related file):

Previously, nrxus (Andres) wrote…

(Reviewable was unable to map this GitHub inline comment thread to the right spot — sorry!)

technically a breaking API change but the old API was unsafe as it relied on the user knowing not to close the RawFd after the fact. This makes it more explicit that this function will take ownership of the file descriptor.

Looks like a win to me.



aya/src/maps/mod.rs line 584 at r1 (raw file):

    }

    /// Loads a map from an [`OwnedFd`].

I think it'd be better avoid repeating the type here.

Code quote:

OwnedFd

Copy link
Contributor Author

@nrxus nrxus 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: 19 of 20 files reviewed, 1 unresolved discussion (waiting on @alessandrod and @tamird)


aya/src/maps/mod.rs line 584 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

I think it'd be better avoid repeating the type here.

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 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @alessandrod)

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.

A couple of nits but other than that LGTM

aya/src/maps/mod.rs Show resolved Hide resolved
aya/src/programs/cgroup_device.rs Show resolved Hide resolved
aya/src/programs/cgroup_skb.rs Show resolved Hide resolved
aya/src/maps/mod.rs Show resolved Hide resolved
@nrxus nrxus requested a review from dave-tucker August 1, 2023 17:47
@mergify
Copy link

mergify bot commented Aug 2, 2023

@nrxus, this pull request is now in conflict and requires a rebase.

@mergify mergify bot added the needs-rebase label Aug 2, 2023
@tamird
Copy link
Member

tamird commented Aug 2, 2023

@nrxus apologies for the conflict. Let's rebase and get this landed.

@tamird
Copy link
Member

tamird commented Aug 2, 2023

I took care of the conflict.

@mergify mergify bot removed the needs-rebase label Aug 2, 2023
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 20 of 20 files at r3, all commit messages.
Dismissed @dave-tucker from 4 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @nrxus)

@tamird tamird merged commit bd5442a into aya-rs:main Aug 2, 2023
19 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.

4 participants