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

Support reconstruction of SchedClassifierLink #445

Merged
merged 11 commits into from
Jan 30, 2023

Conversation

anfredette
Copy link
Contributor

@anfredette anfredette commented Nov 18, 2022

This is the proposed solution for Step 2 of issue #414

For cases where you have done program.take_link() to manage ownership of TcLink we need an API similar to PinnedLink::from_pin that can reconstruct a TcLink

As long as a user application continues to run after executing take_link(), the SchedClassifierLink returned can be used to detach the program. However, if we want to handle cases where the application exits or crashes, we need a way to save and reconstruct the link, and to do that, we also need to know the information required for the reconstruction -- namely, the interface, attach_type, priority, and handle. The user knows the first two because they are required to execute attach() in the first place; however, the user will not know the others if they let the system choose them.

This pr solves the problems by adding an impl for SchedClassifierLink with accessors for priority and handle, and a new() function.

Signed-off-by: Andre Fredette afredette@redhat.com

@netlify
Copy link

netlify bot commented Nov 18, 2022

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7855a0e
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/63d7e216eb019f000a4b0e08
😎 Deploy Preview https://deploy-preview-445--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 settings.

aya/src/programs/tc.rs Outdated Show resolved Hide resolved
@anfredette anfredette force-pushed the tc-link-recon branch 3 times, most recently from bed7e8b to 0d8fd95 Compare November 21, 2022 22:12
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.

Looks good, but docs need work.

aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
Copy link
Member

@vadorovsky vadorovsky left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

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

@dave-tucker
Copy link
Member

Ping @alessandrod - this one is good to go but requires a LGTM from you since API changes are involved.

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.

Great work as always! See comments

aya/src/programs/tc.rs Outdated Show resolved Hide resolved
handle: u32,
) -> Result<SchedClassifierLink, ProgramError> {
let if_index =
ifindex_from_ifname(if_name).map_err(|io_error| TcError::NetlinkError { io_error })?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shoulld just return io::Error I think? if_nametoindex uses ioctls not netlink

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds fine. I copied the error mapping from the original attach() function, but I can change this, and I guess I should change the other instance as well.

aya/src/programs/tc.rs Outdated Show resolved Hide resolved
anfredette added a commit to anfredette/tchandle that referenced this pull request Dec 16, 2022
It is based on aya with the following prs:
aya-rs/aya#462
aya-rs/aya#445
(w/445 modified to work with 462)

Signed-off-by: Andre Fredette <afredette@redhat.com>
anfredette added a commit to anfredette/tchandle that referenced this pull request Dec 16, 2022
It is based on aya with the following prs:
aya-rs/aya#462
aya-rs/aya#445
(w/445 modified to work with 462)

Signed-off-by: Andre Fredette <afredette@redhat.com>
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
@anfredette
Copy link
Contributor Author

I think I've addressed the comments. Please take a look when you get a chance.

@anfredette anfredette requested review from alessandrod and vadorovsky and removed request for alessandrod and vadorovsky December 22, 2022 12:58
Copy link
Member

@vadorovsky vadorovsky left a comment

Choose a reason for hiding this comment

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

Thanks!

anfredette and others added 8 commits January 25, 2023 14:12
This is the proposed solution for Step 2 of issue aya-rs#414

“For cases where you have done program.take_link() to manage
ownership of TcLink we need an API similar to PinnedLink::from_pin
that can reconstruct a TcLink”

As long as a user application continues to run after executing
`take_link()`, the `SchedClassifierLink` returned can be used to
detach the program.  However, if we want to handle cases where the
application exits or crashes, we need a way to save and reconstruct
the link, and to do that, we also need to know the information
required for the reconstruction -- namely, the `interface`,
`attach_type`, `priority`, and `handle`.  The user knows the first
two because they are required to execute `attach()` in the first
place; however, the user will not know the others if they let the
system choose them.

This pr solves the problems by adding an `impl` for
`SchedClassifierLink` with an accessor for `tc_options` and a `new()`
function.

Signed-off-by: Andre Fredette <afredette@redhat.com>
Also modified the impl a bit to work as described in the example.

Signed-off-by: Andre Fredette <afredette@redhat.com>
Co-authored-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Andre Fredette <afredette@redhat.com>
Signed-off-by: Andre Fredette <afredette@redhat.com>
Avoids name confilct with pr aya-rs#462

Signed-off-by: Andre Fredette <afredette@redhat.com>
Signed-off-by: Andre Fredette <afredette@redhat.com>
- Rename `new_tc_link` to `attached`
- Simplified example for `attached`

The following was not requested in reviews:
- Moved example from `SchedClassifierLink` tor
  `SchedClassifierLink::attached' since we're only showing an
  example of that one method

Signed-off-by: Andre Fredette <afredette@redhat.com>
It was redundant with the one provided in define_link_wrapper

Signed-off-by: Andre Fredette <afredette@redhat.com>
Signed-off-by: Andre Fredette <afredette@redhat.com>
@anfredette
Copy link
Contributor Author

@alessandrod, I'd appreciate it if you could take a look when you get a chance.

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.

Thanks! Just a couple of docs nits

aya/src/programs/tc.rs Outdated Show resolved Hide resolved
aya/src/programs/tc.rs Outdated Show resolved Hide resolved
Signed-off-by: Andre Fredette <afredette@redhat.com>
Signed-off-by: Andre Fredette <afredette@redhat.com>
@alessandrod alessandrod merged commit 22d7931 into aya-rs:main Jan 30, 2023
@dave-tucker dave-tucker added feature A PR that implements a new feature or enhancement aya This is about aya (userspace) labels Feb 23, 2023
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.

4 participants