From 4abaad6a463ce6253ce5593031c17b0274b39646 Mon Sep 17 00:00:00 2001 From: Davide Bertola Date: Wed, 1 Jun 2022 19:27:00 +0200 Subject: [PATCH] Use a macro for program unload api --- aya/src/programs/cgroup_skb.rs | 12 ++------- aya/src/programs/cgroup_sysctl.rs | 12 ++------- aya/src/programs/fentry.rs | 12 ++------- aya/src/programs/fexit.rs | 12 ++------- aya/src/programs/kprobe.rs | 10 ------- aya/src/programs/lirc_mode2.rs | 13 +-------- aya/src/programs/lsm.rs | 12 ++------- aya/src/programs/mod.rs | 41 +++++++++++++++++++++++++++++ aya/src/programs/perf_event.rs | 10 +------ aya/src/programs/raw_trace_point.rs | 12 ++------- aya/src/programs/sk_msg.rs | 12 ++------- aya/src/programs/sk_skb.rs | 12 ++------- aya/src/programs/sock_ops.rs | 12 ++------- aya/src/programs/socket_filter.rs | 10 +------ aya/src/programs/tc.rs | 13 +-------- aya/src/programs/tp_btf.rs | 12 ++------- aya/src/programs/trace_point.rs | 10 ------- aya/src/programs/uprobe.rs | 10 +------ aya/src/programs/xdp.rs | 11 +------- 19 files changed, 67 insertions(+), 181 deletions(-) diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs index c64f2e15..6852407a 100644 --- a/aya/src/programs/cgroup_skb.rs +++ b/aya/src/programs/cgroup_skb.rs @@ -10,8 +10,8 @@ use crate::{ bpf_prog_type::BPF_PROG_TYPE_CGROUP_SKB, }, programs::{ - define_link_wrapper, load_program, unload_program, FdLink, Link, OwnedLink, ProgAttachLink, - ProgramData, ProgramError, + define_link_wrapper, load_program, FdLink, Link, OwnedLink, ProgAttachLink, ProgramData, + ProgramError, }, sys::{bpf_link_create, bpf_prog_attach, kernel_version}, }; @@ -72,14 +72,6 @@ impl CgroupSkb { load_program(BPF_PROG_TYPE_CGROUP_SKB, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Returns the expected attach type of the program. /// /// [`CgroupSkb`] programs can specify the expected attach type in their ELF diff --git a/aya/src/programs/cgroup_sysctl.rs b/aya/src/programs/cgroup_sysctl.rs index f5330ded..756702b7 100644 --- a/aya/src/programs/cgroup_sysctl.rs +++ b/aya/src/programs/cgroup_sysctl.rs @@ -7,8 +7,8 @@ use std::{ use crate::{ generated::{bpf_attach_type::BPF_CGROUP_SYSCTL, bpf_prog_type::BPF_PROG_TYPE_CGROUP_SYSCTL}, programs::{ - define_link_wrapper, load_program, unload_program, FdLink, Link, OwnedLink, ProgAttachLink, - ProgramData, ProgramError, + define_link_wrapper, load_program, FdLink, Link, OwnedLink, ProgAttachLink, ProgramData, + ProgramError, }, sys::{bpf_link_create, bpf_prog_attach, kernel_version}, }; @@ -59,14 +59,6 @@ impl CgroupSysctl { load_program(BPF_PROG_TYPE_CGROUP_SYSCTL, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given cgroup. /// /// The returned value can be used to detach, see [CgroupSysctl::detach]. diff --git a/aya/src/programs/fentry.rs b/aya/src/programs/fentry.rs index ff4d3380..86c35326 100644 --- a/aya/src/programs/fentry.rs +++ b/aya/src/programs/fentry.rs @@ -4,8 +4,8 @@ use crate::{ generated::{bpf_attach_type::BPF_TRACE_FENTRY, bpf_prog_type::BPF_PROG_TYPE_TRACING}, obj::btf::{Btf, BtfKind}, programs::{ - define_link_wrapper, load_program, unload_program, utils::attach_raw_tracepoint, FdLink, - FdLinkId, OwnedLink, ProgramData, ProgramError, + define_link_wrapper, load_program, utils::attach_raw_tracepoint, FdLink, FdLinkId, + OwnedLink, ProgramData, ProgramError, }, }; @@ -62,14 +62,6 @@ impl FEntry { load_program(BPF_PROG_TYPE_TRACING, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program. /// /// The returned value can be used to detach, see [FEntry::detach]. diff --git a/aya/src/programs/fexit.rs b/aya/src/programs/fexit.rs index 8c9de97b..408896c2 100644 --- a/aya/src/programs/fexit.rs +++ b/aya/src/programs/fexit.rs @@ -4,8 +4,8 @@ use crate::{ generated::{bpf_attach_type::BPF_TRACE_FEXIT, bpf_prog_type::BPF_PROG_TYPE_TRACING}, obj::btf::{Btf, BtfKind}, programs::{ - define_link_wrapper, load_program, unload_program, utils::attach_raw_tracepoint, FdLink, - FdLinkId, OwnedLink, ProgramData, ProgramError, + define_link_wrapper, load_program, utils::attach_raw_tracepoint, FdLink, FdLinkId, + OwnedLink, ProgramData, ProgramError, }, }; @@ -62,14 +62,6 @@ impl FExit { load_program(BPF_PROG_TYPE_TRACING, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program. /// /// The returned value can be used to detach, see [FExit::detach]. diff --git a/aya/src/programs/kprobe.rs b/aya/src/programs/kprobe.rs index 3856fb20..a5bf0475 100644 --- a/aya/src/programs/kprobe.rs +++ b/aya/src/programs/kprobe.rs @@ -12,8 +12,6 @@ use crate::{ }, }; -use super::unload_program; - /// A kernel probe. /// /// Kernel probes are eBPF programs that can be attached to almost any function inside @@ -51,14 +49,6 @@ impl KProbe { load_program(BPF_PROG_TYPE_KPROBE, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Returns `KProbe` if the program is a `kprobe`, or `KRetProbe` if the /// program is a `kretprobe`. pub fn kind(&self) -> ProbeKind { diff --git a/aya/src/programs/lirc_mode2.rs b/aya/src/programs/lirc_mode2.rs index e9eecf3e..e210a734 100644 --- a/aya/src/programs/lirc_mode2.rs +++ b/aya/src/programs/lirc_mode2.rs @@ -3,10 +3,7 @@ use std::os::unix::prelude::{AsRawFd, RawFd}; use crate::{ generated::{bpf_attach_type::BPF_LIRC_MODE2, bpf_prog_type::BPF_PROG_TYPE_LIRC_MODE2}, - programs::{ - load_program, query, unload_program, Link, OwnedLink, ProgramData, ProgramError, - ProgramInfo, - }, + programs::{load_program, query, Link, OwnedLink, ProgramData, ProgramError, ProgramInfo}, sys::{bpf_obj_get_info_by_fd, bpf_prog_attach, bpf_prog_detach, bpf_prog_get_fd_by_id}, }; @@ -61,14 +58,6 @@ impl LircMode2 { load_program(BPF_PROG_TYPE_LIRC_MODE2, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given lirc device. /// /// The returned value can be used to detach, see [LircMode2::detach]. diff --git a/aya/src/programs/lsm.rs b/aya/src/programs/lsm.rs index abfc6c7b..87109df9 100644 --- a/aya/src/programs/lsm.rs +++ b/aya/src/programs/lsm.rs @@ -3,8 +3,8 @@ use crate::{ generated::{bpf_attach_type::BPF_LSM_MAC, bpf_prog_type::BPF_PROG_TYPE_LSM}, obj::btf::{Btf, BtfKind}, programs::{ - define_link_wrapper, load_program, unload_program, utils::attach_raw_tracepoint, FdLink, - FdLinkId, OwnedLink, ProgramData, ProgramError, + define_link_wrapper, load_program, utils::attach_raw_tracepoint, FdLink, FdLinkId, + OwnedLink, ProgramData, ProgramError, }, }; @@ -67,14 +67,6 @@ impl Lsm { load_program(BPF_PROG_TYPE_LSM, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program. /// /// The returned value can be used to detach, see [Lsm::detach]. diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs index 8065770b..782de125 100644 --- a/aya/src/programs/mod.rs +++ b/aya/src/programs/mod.rs @@ -552,6 +552,47 @@ impl<'a, P: ProgramFd> ProgramFd for &'a P { } } +macro_rules! impl_program_unload { + ($($struct_name:ident),+ $(,)?) => { + $( + impl $struct_name { + /// Unloads the program from the kernel. + /// + /// If `detach` is true, links will be detached before unloading the program. + /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. + pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { + unload_program(&mut self.data, detach) + } + } + )+ + } +} + +impl_program_unload!( + KProbe, + UProbe, + TracePoint, + SocketFilter, + Xdp, + SkMsg, + SkSkb, + SchedClassifier, + CgroupSkb, + CgroupSysctl, + CgroupSockopt, + LircMode2, + PerfEvent, + Lsm, + RawTracePoint, + BtfTracePoint, + FEntry, + FExit, + Extension, + CgroupSockAddr, + SkLookup, + SockOps +); + macro_rules! impl_program_fd { ($($struct_name:ident),+ $(,)?) => { $( diff --git a/aya/src/programs/perf_event.rs b/aya/src/programs/perf_event.rs index 750a6a11..44c15c3e 100644 --- a/aya/src/programs/perf_event.rs +++ b/aya/src/programs/perf_event.rs @@ -14,7 +14,7 @@ use crate::{ programs::{ load_program, perf_attach, perf_attach::{PerfLink, PerfLinkId}, - unload_program, OwnedLink, ProgramData, ProgramError, + OwnedLink, ProgramData, ProgramError, }, sys::perf_event_open, }; @@ -128,14 +128,6 @@ impl PerfEvent { load_program(BPF_PROG_TYPE_PERF_EVENT, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches to the given perf event. /// /// The possible values and encoding of the `config` argument depends on the diff --git a/aya/src/programs/raw_trace_point.rs b/aya/src/programs/raw_trace_point.rs index 2497c82f..fd4656fa 100644 --- a/aya/src/programs/raw_trace_point.rs +++ b/aya/src/programs/raw_trace_point.rs @@ -4,8 +4,8 @@ use std::ffi::CString; use crate::{ generated::bpf_prog_type::BPF_PROG_TYPE_RAW_TRACEPOINT, programs::{ - define_link_wrapper, load_program, unload_program, utils::attach_raw_tracepoint, FdLink, - FdLinkId, OwnedLink, ProgramData, ProgramError, + define_link_wrapper, load_program, utils::attach_raw_tracepoint, FdLink, FdLinkId, + OwnedLink, ProgramData, ProgramError, }, }; @@ -45,14 +45,6 @@ impl RawTracePoint { load_program(BPF_PROG_TYPE_RAW_TRACEPOINT, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given tracepoint. /// /// The returned value can be used to detach, see [RawTracePoint::detach]. diff --git a/aya/src/programs/sk_msg.rs b/aya/src/programs/sk_msg.rs index fbaf4893..7568e3be 100644 --- a/aya/src/programs/sk_msg.rs +++ b/aya/src/programs/sk_msg.rs @@ -3,8 +3,8 @@ use crate::{ generated::{bpf_attach_type::BPF_SK_MSG_VERDICT, bpf_prog_type::BPF_PROG_TYPE_SK_MSG}, maps::sock::SocketMap, programs::{ - define_link_wrapper, load_program, unload_program, OwnedLink, ProgAttachLink, - ProgAttachLinkId, ProgramData, ProgramError, + define_link_wrapper, load_program, OwnedLink, ProgAttachLink, ProgAttachLinkId, + ProgramData, ProgramError, }, sys::bpf_prog_attach, }; @@ -69,14 +69,6 @@ impl SkMsg { load_program(BPF_PROG_TYPE_SK_MSG, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given sockmap. /// /// The returned value can be used to detach, see [SkMsg::detach]. diff --git a/aya/src/programs/sk_skb.rs b/aya/src/programs/sk_skb.rs index 433ce933..bf4f2777 100644 --- a/aya/src/programs/sk_skb.rs +++ b/aya/src/programs/sk_skb.rs @@ -6,8 +6,8 @@ use crate::{ }, maps::sock::SocketMap, programs::{ - define_link_wrapper, load_program, unload_program, OwnedLink, ProgAttachLink, - ProgAttachLinkId, ProgramData, ProgramError, + define_link_wrapper, load_program, OwnedLink, ProgAttachLink, ProgAttachLinkId, + ProgramData, ProgramError, }, sys::bpf_prog_attach, }; @@ -62,14 +62,6 @@ impl SkSkb { load_program(BPF_PROG_TYPE_SK_SKB, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given socket map. /// /// The returned value can be used to detach, see [SkSkb::detach]. diff --git a/aya/src/programs/sock_ops.rs b/aya/src/programs/sock_ops.rs index 77ac2d01..d4a4d385 100644 --- a/aya/src/programs/sock_ops.rs +++ b/aya/src/programs/sock_ops.rs @@ -4,8 +4,8 @@ use std::os::unix::io::AsRawFd; use crate::{ generated::{bpf_attach_type::BPF_CGROUP_SOCK_OPS, bpf_prog_type::BPF_PROG_TYPE_SOCK_OPS}, programs::{ - define_link_wrapper, load_program, unload_program, OwnedLink, ProgAttachLink, - ProgAttachLinkId, ProgramData, ProgramError, + define_link_wrapper, load_program, OwnedLink, ProgAttachLink, ProgAttachLinkId, + ProgramData, ProgramError, }, sys::bpf_prog_attach, }; @@ -56,14 +56,6 @@ impl SockOps { load_program(BPF_PROG_TYPE_SOCK_OPS, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given cgroup. /// /// The returned value can be used to detach, see [SockOps::detach]. diff --git a/aya/src/programs/socket_filter.rs b/aya/src/programs/socket_filter.rs index 4b43cbcb..ef9e0830 100644 --- a/aya/src/programs/socket_filter.rs +++ b/aya/src/programs/socket_filter.rs @@ -8,7 +8,7 @@ use thiserror::Error; use crate::{ generated::{bpf_prog_type::BPF_PROG_TYPE_SOCKET_FILTER, SO_ATTACH_BPF, SO_DETACH_BPF}, - programs::{load_program, unload_program, Link, OwnedLink, ProgramData, ProgramError}, + programs::{load_program, Link, OwnedLink, ProgramData, ProgramError}, }; /// The type returned when attaching a [`SocketFilter`] fails. @@ -70,14 +70,6 @@ impl SocketFilter { load_program(BPF_PROG_TYPE_SOCKET_FILTER, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the filter on the given socket. /// /// The returned value can be used to detach from the socket, see [SocketFilter::detach]. diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 0cfe872a..941ed18e 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -10,10 +10,7 @@ use crate::{ generated::{ bpf_prog_type::BPF_PROG_TYPE_SCHED_CLS, TC_H_CLSACT, TC_H_MIN_EGRESS, TC_H_MIN_INGRESS, }, - programs::{ - define_link_wrapper, load_program, unload_program, Link, OwnedLink, ProgramData, - ProgramError, - }, + programs::{define_link_wrapper, load_program, Link, OwnedLink, ProgramData, ProgramError}, sys::{ netlink_find_filter_with_name, netlink_qdisc_add_clsact, netlink_qdisc_attach, netlink_qdisc_detach, @@ -109,14 +106,6 @@ impl SchedClassifier { load_program(BPF_PROG_TYPE_SCHED_CLS, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given `interface`. /// /// The returned value can be used to detach, see [SchedClassifier::detach]. diff --git a/aya/src/programs/tp_btf.rs b/aya/src/programs/tp_btf.rs index 9c510b6a..d68785f3 100644 --- a/aya/src/programs/tp_btf.rs +++ b/aya/src/programs/tp_btf.rs @@ -3,8 +3,8 @@ use crate::{ generated::{bpf_attach_type::BPF_TRACE_RAW_TP, bpf_prog_type::BPF_PROG_TYPE_TRACING}, obj::btf::{Btf, BtfKind}, programs::{ - define_link_wrapper, load_program, unload_program, utils::attach_raw_tracepoint, FdLink, - FdLinkId, OwnedLink, ProgramData, ProgramError, + define_link_wrapper, load_program, utils::attach_raw_tracepoint, FdLink, FdLinkId, + OwnedLink, ProgramData, ProgramError, }, }; @@ -65,14 +65,6 @@ impl BtfTracePoint { load_program(BPF_PROG_TYPE_TRACING, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program. /// /// The returned value can be used to detach, see [BtfTracePoint::detach]. diff --git a/aya/src/programs/trace_point.rs b/aya/src/programs/trace_point.rs index 12fd21a9..43d35606 100644 --- a/aya/src/programs/trace_point.rs +++ b/aya/src/programs/trace_point.rs @@ -12,8 +12,6 @@ use crate::{ sys::perf_event_open_trace_point, }; -use super::unload_program; - /// The type returned when attaching a [`TracePoint`] fails. #[derive(Debug, Error)] pub enum TracePointError { @@ -73,14 +71,6 @@ impl TracePoint { load_program(BPF_PROG_TYPE_TRACEPOINT, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches to a given trace point. /// /// For a list of the available event categories and names, see diff --git a/aya/src/programs/uprobe.rs b/aya/src/programs/uprobe.rs index f458fe58..fa1f7a9a 100644 --- a/aya/src/programs/uprobe.rs +++ b/aya/src/programs/uprobe.rs @@ -19,7 +19,7 @@ use crate::{ define_link_wrapper, load_program, perf_attach::{PerfLink, PerfLinkId}, probe::{attach, ProbeKind}, - unload_program, OwnedLink, ProgramData, ProgramError, + OwnedLink, ProgramData, ProgramError, }, }; @@ -51,14 +51,6 @@ impl UProbe { load_program(BPF_PROG_TYPE_KPROBE, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Returns `UProbe` if the program is a `uprobe`, or `URetProbe` if the /// program is a `uretprobe`. pub fn kind(&self) -> ProbeKind { diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs index fe6ef4d8..713d4b7d 100644 --- a/aya/src/programs/xdp.rs +++ b/aya/src/programs/xdp.rs @@ -12,8 +12,7 @@ use crate::{ XDP_FLAGS_UPDATE_IF_NOEXIST, }, programs::{ - define_link_wrapper, load_program, unload_program, FdLink, Link, OwnedLink, ProgramData, - ProgramError, + define_link_wrapper, load_program, FdLink, Link, OwnedLink, ProgramData, ProgramError, }, sys::{bpf_link_create, kernel_version, netlink_set_xdp_fd}, }; @@ -82,14 +81,6 @@ impl Xdp { load_program(BPF_PROG_TYPE_XDP, &mut self.data) } - /// Unloads the program from the kernel. - /// - /// If `detach` is true, links will be detached before unloading the program. - /// Note that OwnedLinks you obtained using [KProbe::forget_link] will not be detached. - pub fn unload(&mut self, detach: bool) -> Result<(), ProgramError> { - unload_program(&mut self.data, detach) - } - /// Attaches the program to the given `interface`. /// /// The returned value can be used to detach, see [Xdp::detach].