Coder Social home page Coder Social logo

aya is missing query features about aya HOT 6 CLOSED

aya-rs avatar aya-rs commented on May 20, 2024
aya is missing query features

from aya.

Comments (6)

alessandrod avatar alessandrod commented on May 20, 2024

The query I'm thinking should probably be a helper function in the aya::programs, and be something like

fn query<T: AsRawFd>(target_fd: T, attach_type: XXX, flags: u32) -> Result<(Vec<u32>, u32), io::Error>

Where the result is a Vec of prog ids and the attach flags. As for the XXX type , we could re-export crate::generated::bpf_attach_type as aya::programs::AttachType for now, or we could create a new enum and keep it in sync, bpf_attach_type doesn't change that often anyway.

To get the name then you'd use a separate syscall right?

As for detaching, I'm not sure yet what we could do. I know I want to add a forget() method to the Link trait (related to your other PR), but haven't thought about what the API to detach an arbitrary fd/type would look like.

from aya.

seanyoung avatar seanyoung commented on May 20, 2024

I do wonder if it is possible to create a higher level of abstraction than (Vec<u32>, u32). I think it would be nicer if we returned a list of programs, which had a detach() and info() method of some sort. struct bpf_prog_info contains a lot of information, not just the name.

from aya.

alessandrod avatar alessandrod commented on May 20, 2024

Yes you're right, we should definitely create a higher level API. I guess my thinking was that coming up with a higher level interface would probably require some work (see below), so we could start by wrapping the syscall. Now that I've thought about it though, I think I was overthinking it.

Agreed on info(), we should have it return a type that contains everything useful from struct bpf_prog_info. And about detach(), I was thinking that it would be tricky ensuring that it doesn't break things if you have other Links laying around, but that's not the case. All the existing Link::detach() impls already ignore errors on detach. And regardless of what interface we come up with, we need to handle other programs (eg bpftool) potentially detaching our links anyway.

So yeah, this is easier than I first thought :)

from aya.

alessandrod avatar alessandrod commented on May 20, 2024

@seanyoung are you planning to do or have you done any work on this? Otherwise I might get to it next week

from aya.

seanyoung avatar seanyoung commented on May 20, 2024

@alessandrod I had started on this, see my query branch https://github.com/seanyoung/aya/commits/query. The query of programs and their names works, but not detaching or any other field than name.

There are some issues which I haven't figured out yet. This where I am at.

  • The query interface is bpf program dependent, for example the query_flags are bpf program/attach dependent, so I think the query interface should exist on the specific program type (e.g. LircMode2)
  • The interface for querying the bpf_info is generic and can be shared
  • The interface for detaching the program is specific for the program type and should probably be shared with the bpf program specific detach code (for programs which were attached, not found via query interface).

So I was kind of stuck on how to model this. The QueryProgram isn't going to work for detaching, but will work for a generic info querying.

from aya.

tamird avatar tamird commented on May 20, 2024

Looks like #32 was meant to close this.

from aya.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.