pub struct SchedClassifier { /* private fields */ }
Expand description
A network traffic control classifier.
SchedClassifier
programs can be used to inspect, filter or redirect
network packets in both ingress and egress. They are executed as part of the
linux network traffic control system. See
https://man7.org/linux/man-pages/man8/tc-bpf.8.html.
Examples
Minimum kernel version
The minimum kernel version required to use this feature is 4.1.
use std::convert::TryInto;
use aya::programs::{tc, SchedClassifier, TcAttachType};
// the clsact qdisc needs to be added before SchedClassifier programs can be
// attached
tc::qdisc_add_clsact("eth0")?;
let prog: &mut SchedClassifier = bpf.program_mut("redirect_ingress").unwrap().try_into()?;
prog.load()?;
prog.attach("eth0", TcAttachType::Ingress)?;
Implementations
sourceimpl SchedClassifier
impl SchedClassifier
sourcepub fn load(&mut self) -> Result<(), ProgramError>
pub fn load(&mut self) -> Result<(), ProgramError>
Loads the program inside the kernel.
See also Program::load
.
sourcepub fn attach(
&mut self,
interface: &str,
attach_type: TcAttachType
) -> Result<LinkRef, ProgramError>
pub fn attach(
&mut self,
interface: &str,
attach_type: TcAttachType
) -> Result<LinkRef, ProgramError>
Attaches the program to the given interface
.
Errors
TcError::NetlinkError
is returned if attaching fails. A common cause
of failure is not having added the clsact
qdisc to the given
interface, see qdisc_add_clsact
Trait Implementations
sourceimpl Debug for SchedClassifier
impl Debug for SchedClassifier
sourceimpl ProgramFd for SchedClassifier
impl ProgramFd for SchedClassifier
sourceimpl ProgramFd for &mut SchedClassifier
impl ProgramFd for &mut SchedClassifier
sourceimpl<'a> TryFrom<&'a Program> for &'a SchedClassifier
impl<'a> TryFrom<&'a Program> for &'a SchedClassifier
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.
sourcefn try_from(program: &'a Program) -> Result<&'a SchedClassifier, ProgramError>
fn try_from(program: &'a Program) -> Result<&'a SchedClassifier, ProgramError>
Performs the conversion.
sourceimpl<'a> TryFrom<&'a mut Program> for &'a mut SchedClassifier
impl<'a> TryFrom<&'a mut Program> for &'a mut SchedClassifier
type Error = ProgramError
type Error = ProgramError
The type returned in the event of a conversion error.
sourcefn try_from(
program: &'a mut Program
) -> Result<&'a mut SchedClassifier, ProgramError>
fn try_from(
program: &'a mut Program
) -> Result<&'a mut SchedClassifier, ProgramError>
Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for SchedClassifier
impl !Send for SchedClassifier
impl !Sync for SchedClassifier
impl Unpin for SchedClassifier
impl !UnwindSafe for SchedClassifier
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more