|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
//! Program links.
|
|
|
|
use libc::{close, dup};
|
|
|
|
use libc::{close, dup};
|
|
|
|
|
|
|
|
|
|
|
|
use std::{
|
|
|
|
use std::{
|
|
|
@ -9,7 +10,7 @@ use std::{
|
|
|
|
|
|
|
|
|
|
|
|
use crate::{generated::bpf_attach_type, programs::ProgramError, sys::bpf_prog_detach};
|
|
|
|
use crate::{generated::bpf_attach_type, programs::ProgramError, sys::bpf_prog_detach};
|
|
|
|
|
|
|
|
|
|
|
|
/// A Link
|
|
|
|
/// A Link.
|
|
|
|
pub trait Link: std::fmt::Debug + 'static {
|
|
|
|
pub trait Link: std::fmt::Debug + 'static {
|
|
|
|
/// Unique Id
|
|
|
|
/// Unique Id
|
|
|
|
type Id: std::fmt::Debug + std::hash::Hash + Eq + PartialEq;
|
|
|
|
type Id: std::fmt::Debug + std::hash::Hash + Eq + PartialEq;
|
|
|
@ -91,11 +92,13 @@ impl<T: Link> Drop for LinkMap<T> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The identifier of an `FdLink`.
|
|
|
|
#[derive(Debug, Hash, Eq, PartialEq)]
|
|
|
|
#[derive(Debug, Hash, Eq, PartialEq)]
|
|
|
|
pub(crate) struct FdLinkId(pub(crate) RawFd);
|
|
|
|
pub struct FdLinkId(pub(crate) RawFd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// A file descriptor link.
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub(crate) struct FdLink {
|
|
|
|
pub struct FdLink {
|
|
|
|
pub(crate) fd: RawFd,
|
|
|
|
pub(crate) fd: RawFd,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -118,11 +121,13 @@ impl Link for FdLink {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The identifier of a `ProgAttachLink`.
|
|
|
|
#[derive(Debug, Hash, Eq, PartialEq)]
|
|
|
|
#[derive(Debug, Hash, Eq, PartialEq)]
|
|
|
|
pub(crate) struct ProgAttachLinkId(RawFd, RawFd, bpf_attach_type);
|
|
|
|
pub struct ProgAttachLinkId(RawFd, RawFd, bpf_attach_type);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The Link type used by programs that are attached with `bpf_prog_attach`.
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub(crate) struct ProgAttachLink {
|
|
|
|
pub struct ProgAttachLink {
|
|
|
|
prog_fd: RawFd,
|
|
|
|
prog_fd: RawFd,
|
|
|
|
target_fd: RawFd,
|
|
|
|
target_fd: RawFd,
|
|
|
|
attach_type: bpf_attach_type,
|
|
|
|
attach_type: bpf_attach_type,
|
|
|
|