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

aya: Rename forget_link to take_link #306

Merged
merged 1 commit into from Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions aya/src/programs/cgroup_skb.rs
Expand Up @@ -128,11 +128,11 @@ impl CgroupSkb {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: CgroupSkbLinkId,
) -> Result<OwnedLink<CgroupSkbLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}

/// Detaches the program.
Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/cgroup_sock_addr.rs
Expand Up @@ -107,11 +107,11 @@ impl CgroupSockAddr {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: CgroupSockAddrLinkId,
) -> Result<OwnedLink<CgroupSockAddrLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}

/// Detaches the program.
Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/cgroup_sockopt.rs
Expand Up @@ -103,11 +103,11 @@ impl CgroupSockopt {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: CgroupSockoptLinkId,
) -> Result<OwnedLink<CgroupSockoptLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}

/// Detaches the program.
Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/cgroup_sysctl.rs
Expand Up @@ -99,11 +99,11 @@ impl CgroupSysctl {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: CgroupSysctlLinkId,
) -> Result<OwnedLink<CgroupSysctlLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}

/// Detaches the program.
Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/extension.rs
Expand Up @@ -154,11 +154,11 @@ impl Extension {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: ExtensionLinkId,
) -> Result<OwnedLink<ExtensionLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/fentry.rs
Expand Up @@ -80,11 +80,11 @@ impl FEntry {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: FEntryLinkId,
) -> Result<OwnedLink<FEntryLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/fexit.rs
Expand Up @@ -80,11 +80,11 @@ impl FExit {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: FExitLinkId,
) -> Result<OwnedLink<FExitLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/kprobe.rs
Expand Up @@ -81,11 +81,11 @@ impl KProbe {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: KProbeLinkId,
) -> Result<OwnedLink<KProbeLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
7 changes: 2 additions & 5 deletions aya/src/programs/lirc_mode2.rs
Expand Up @@ -86,11 +86,8 @@ impl LircMode2 {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
&mut self,
link_id: LircLinkId,
) -> Result<OwnedLink<LircLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
pub fn take_link(&mut self, link_id: LircLinkId) -> Result<OwnedLink<LircLink>, ProgramError> {
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}

/// Queries the lirc device for attached programs.
Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/lsm.rs
Expand Up @@ -85,8 +85,8 @@ impl Lsm {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(&mut self, link_id: LsmLinkId) -> Result<OwnedLink<LsmLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
pub fn take_link(&mut self, link_id: LsmLinkId) -> Result<OwnedLink<LsmLink>, ProgramError> {
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/mod.rs
Expand Up @@ -381,7 +381,7 @@ impl<T: Link> ProgramData<T> {
Ok(())
}

pub(crate) fn forget_link(&mut self, link_id: T::Id) -> Result<T, ProgramError> {
pub(crate) fn take_link(&mut self, link_id: T::Id) -> Result<T, ProgramError> {
self.links.forget(link_id)
}
}
Expand Down Expand Up @@ -556,7 +556,7 @@ macro_rules! impl_program_unload {
/// Unloads the program from the kernel.
///
/// Links will be detached before unloading the program. Note
/// that owned links obtained using `forget_link()` will not be
/// that owned links obtained using `take_link()` will not be
/// detached.
pub fn unload(&mut self) -> Result<(), ProgramError> {
unload_program(&mut self.data)
Expand Down
7 changes: 2 additions & 5 deletions aya/src/programs/perf_event.rs
Expand Up @@ -182,10 +182,7 @@ impl PerfEvent {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
&mut self,
link_id: PerfLinkId,
) -> Result<OwnedLink<PerfLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
pub fn take_link(&mut self, link_id: PerfLinkId) -> Result<OwnedLink<PerfLink>, ProgramError> {
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}
4 changes: 2 additions & 2 deletions aya/src/programs/raw_trace_point.rs
Expand Up @@ -64,11 +64,11 @@ impl RawTracePoint {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: RawTracePointLinkId,
) -> Result<OwnedLink<RawTracePointLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/sk_lookup.rs
Expand Up @@ -78,11 +78,11 @@ impl SkLookup {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: SkLookupLinkId,
) -> Result<OwnedLink<SkLookupLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}

/// Detaches the program.
Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/sk_msg.rs
Expand Up @@ -100,11 +100,11 @@ impl SkMsg {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: SkMsgLinkId,
) -> Result<OwnedLink<SkMsgLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/sk_skb.rs
Expand Up @@ -95,11 +95,11 @@ impl SkSkb {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: SkSkbLinkId,
) -> Result<OwnedLink<SkSkbLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/sock_ops.rs
Expand Up @@ -87,11 +87,11 @@ impl SockOps {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: SockOpsLinkId,
) -> Result<OwnedLink<SockOpsLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/socket_filter.rs
Expand Up @@ -107,11 +107,11 @@ impl SocketFilter {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: SocketFilterLinkId,
) -> Result<OwnedLink<SocketFilterLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/tc.rs
Expand Up @@ -146,11 +146,11 @@ impl SchedClassifier {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: SchedClassifierLinkId,
) -> Result<OwnedLink<SchedClassifierLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/tp_btf.rs
Expand Up @@ -83,11 +83,11 @@ impl BtfTracePoint {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: BtfTracePointLinkId,
) -> Result<OwnedLink<BtfTracePointLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/trace_point.rs
Expand Up @@ -100,11 +100,11 @@ impl TracePoint {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: TracePointLinkId,
) -> Result<OwnedLink<TracePointLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/uprobe.rs
Expand Up @@ -133,11 +133,11 @@ impl UProbe {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(
pub fn take_link(
&mut self,
link_id: UProbeLinkId,
) -> Result<OwnedLink<UProbeLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
4 changes: 2 additions & 2 deletions aya/src/programs/xdp.rs
Expand Up @@ -138,8 +138,8 @@ impl Xdp {
///
/// The link will be detached on `Drop` and the caller is now responsible
/// for managing its lifetime.
pub fn forget_link(&mut self, link_id: XdpLinkId) -> Result<OwnedLink<XdpLink>, ProgramError> {
Ok(OwnedLink::new(self.data.forget_link(link_id)?))
pub fn take_link(&mut self, link_id: XdpLinkId) -> Result<OwnedLink<XdpLink>, ProgramError> {
Ok(OwnedLink::new(self.data.take_link(link_id)?))
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/cases/010_load/030_unload/test.rs
Expand Up @@ -34,7 +34,7 @@ fn main() {
let link = dispatcher.attach("eth0", XdpFlags::default()).unwrap();

{
let link_owned = dispatcher.forget_link(link);
let link_owned = dispatcher.take_link(link);

dispatcher.unload().unwrap();

Expand Down