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: Implement forget_link #253

Merged
merged 1 commit into from May 12, 2022
Merged

aya: Implement forget_link #253

merged 1 commit into from May 12, 2022

Conversation

dave-tucker
Copy link
Member

Fixes #51

Signed-off-by: Dave Tucker dave@dtucker.co.uk

@dave-tucker dave-tucker added feature A PR that implements a new feature or enhancement aya This is about aya (userspace) labels May 6, 2022
@dave-tucker
Copy link
Member Author

@alessandrod The impl is a bit rough, perhaps a trait would reduce the copy/paste... but this SHOULD work (and I've verified that nothing calls detach() on the link).
however, the integration test case fails because the XDP program isn't attached after the program has stopped.
Could do with some fresh set of eyes on this to see if I've missed something 👀

@dave-tucker
Copy link
Member Author

@alessandrod per discussion on Discord an OwnedLink type was added to deal ensure that we detach links on drop. I've verified with strace that program::forget_link will detach on drop and that mem::forget(link) does not detach on drop....

however, the link does not stay alive after the userspace program exits.
I've tried mem::forget()ing everything (Program, Bpf, OwnedLink) and can't get the program to persist at all - even without these changes - so I've got to conclude that either something broke in the links refactor... i'm doing it wrong,... or the kernel is doing something helpful

@alessandrod
Copy link
Collaborator

@alessandrod per discussion on Discord an OwnedLink type was added to deal ensure that we detach links on drop. I've verified with strace that program::forget_link will detach on drop and that mem::forget(link) does not detach on drop...

Amazing! 😊 I think we should have OwnedLink::forget so that you don't have to mem::forget explicitly which seems ugly.

however, the link does not stay alive after the userspace program exits. I've tried mem::forget()ing everything (Program, Bpf, OwnedLink) and can't get the program to persist at all - even without these changes - so I've got to conclude that either something broke in the links refactor... i'm doing it wrong,... or the kernel is doing something helpful

Hrm ok, I'm going to take a look at this

@dave-tucker
Copy link
Member Author

@alessandrod per discord discuission,

1, Removed the failing test as it relied on mem::forget, which won't work as we cant intentionally leak fds to make this work
2. Implemented Deref for OwnedLink

Should be ready for review now.

@dave-tucker dave-tucker force-pushed the forget branch 4 times, most recently from c07356a to 03cf302 Compare May 10, 2022 23:16
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.

Smol mostly doc nits, almost there!

aya/src/programs/cgroup_skb.rs Outdated Show resolved Hide resolved
aya/src/programs/extension.rs Outdated Show resolved Hide resolved
aya/src/programs/links.rs Outdated Show resolved Hide resolved
aya/src/programs/links.rs Outdated Show resolved Hide resolved
aya/src/programs/links.rs Outdated Show resolved Hide resolved
aya/src/programs/links.rs Outdated Show resolved Hide resolved
Fixes aya-rs#51

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aya This is about aya (userspace) feature A PR that implements a new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lifecyle: Add a forget() API for Link
2 participants