diff --git a/Cargo.toml b/Cargo.toml index 44fa78c1..7ee4e6b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,6 @@ tokio = { version = "1.24.0", default-features = false } which = { version = "6.0.0", default-features = false } xdpilone = { version = "1.0.5", default-features = false } xtask = { path = "xtask", default-features = false } -chrono = { version = "0.4" } [profile.dev] panic = "abort" diff --git a/aya/src/programs/cgroup_device.rs b/aya/src/programs/cgroup_device.rs index 8f6705a5..7fab7791 100644 --- a/aya/src/programs/cgroup_device.rs +++ b/aya/src/programs/cgroup_device.rs @@ -77,7 +77,6 @@ impl CgroupDevice { BPF_CGROUP_DEVICE, None, mode.into(), - Some(0), None, None, ) diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs index af5b56e7..fc28158b 100644 --- a/aya/src/programs/cgroup_skb.rs +++ b/aya/src/programs/cgroup_skb.rs @@ -105,7 +105,6 @@ impl CgroupSkb { attach_type, None, mode.into(), - Some(0), None, None, ) diff --git a/aya/src/programs/cgroup_sock.rs b/aya/src/programs/cgroup_sock.rs index bf66d5f8..33d5ce63 100644 --- a/aya/src/programs/cgroup_sock.rs +++ b/aya/src/programs/cgroup_sock.rs @@ -83,7 +83,6 @@ impl CgroupSock { attach_type, None, mode.into(), - Some(0), None, None, ) diff --git a/aya/src/programs/cgroup_sock_addr.rs b/aya/src/programs/cgroup_sock_addr.rs index bbca3fa8..622d0e61 100644 --- a/aya/src/programs/cgroup_sock_addr.rs +++ b/aya/src/programs/cgroup_sock_addr.rs @@ -84,7 +84,6 @@ impl CgroupSockAddr { attach_type, None, mode.into(), - Some(0), None, None, ) diff --git a/aya/src/programs/cgroup_sockopt.rs b/aya/src/programs/cgroup_sockopt.rs index 0170b72b..7f07f7c6 100644 --- a/aya/src/programs/cgroup_sockopt.rs +++ b/aya/src/programs/cgroup_sockopt.rs @@ -81,7 +81,6 @@ impl CgroupSockopt { attach_type, None, mode.into(), - Some(0), None, None, ) diff --git a/aya/src/programs/cgroup_sysctl.rs b/aya/src/programs/cgroup_sysctl.rs index baa69f6e..00b9b720 100644 --- a/aya/src/programs/cgroup_sysctl.rs +++ b/aya/src/programs/cgroup_sysctl.rs @@ -76,7 +76,6 @@ impl CgroupSysctl { BPF_CGROUP_SYSCTL, None, mode.into(), - Some(0), None, None, ) diff --git a/aya/src/programs/extension.rs b/aya/src/programs/extension.rs index 5587d248..12e64a96 100644 --- a/aya/src/programs/extension.rs +++ b/aya/src/programs/extension.rs @@ -105,7 +105,6 @@ impl Extension { 0, None, None, - None, ) .map_err(|(_, io_error)| SyscallError { call: "bpf_link_create", @@ -145,7 +144,6 @@ impl Extension { 0, None, None, - None, ) .map_err(|(_, io_error)| SyscallError { call: "bpf_link_create", diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs index b855bafb..880be363 100644 --- a/aya/src/programs/links.rs +++ b/aya/src/programs/links.rs @@ -15,7 +15,7 @@ use crate::{ BPF_F_ID, BPF_F_LINK, BPF_F_REPLACE, }, pin::PinError, - programs::{MprogLink, MprogProgram, ProgramError, ProgramFd, ProgramId}, + programs::{MultiProgLink, MultiProgProgram, ProgramError, ProgramFd, ProgramId}, sys::{bpf_get_object, bpf_pin_object, bpf_prog_attach, bpf_prog_detach, SyscallError}, }; @@ -409,6 +409,12 @@ impl LinkId { } } +#[derive(Debug)] +pub(crate) enum LinkRef { + Id(u32), + Fd(RawFd), +} + bitflags::bitflags! { /// Flags which are use to build a set of MprogOptions. #[derive(Clone, Copy, Debug, Default)] @@ -426,7 +432,7 @@ bitflags::bitflags! { /// /// # Minimum kernel version /// -/// The minimum kernel version required to use this feature is 6.6. +/// The minimum kernel version required to use this feature is 6.6.0. /// /// # Example /// @@ -443,8 +449,7 @@ bitflags::bitflags! { /// ``` #[derive(Debug)] pub struct LinkOrder { - pub(crate) id: Option, - pub(crate) fd: Option, + pub(crate) link_ref: LinkRef, pub(crate) expected_revision: Option, pub(crate) flags: MprogFlags, } @@ -453,8 +458,7 @@ pub struct LinkOrder { impl Default for LinkOrder { fn default() -> Self { Self { - id: Some(0), - fd: None, + link_ref: LinkRef::Fd(0), flags: MprogFlags::AFTER, expected_revision: None, } @@ -465,8 +469,7 @@ impl LinkOrder { /// Ensure the link is created before all other links at a given attachment point. pub fn first() -> Self { Self { - id: Some(0), - fd: None, + link_ref: LinkRef::Id(0), flags: MprogFlags::BEFORE, expected_revision: None, } @@ -475,28 +478,25 @@ impl LinkOrder { /// Ensure the link is created after all other links for a given attachment point. pub fn last() -> Self { Self { - id: Some(0), - fd: None, + link_ref: LinkRef::Id(0), flags: MprogFlags::AFTER, expected_revision: None, } } /// Ensure the link is created before the specified aya-owned link for a given attachment point. - pub fn before_link(link: &L) -> Result { + pub fn before_link(link: &L) -> Result { Ok(Self { - id: None, - fd: Some(link.fd()?.as_raw_fd()), + link_ref: LinkRef::Fd(link.fd()?.as_raw_fd()), flags: MprogFlags::BEFORE | MprogFlags::LINK, expected_revision: None, }) } /// Ensure the link is created after the specified aya-owned link for a given attachment point. - pub fn after_link(link: &L) -> Result { + pub fn after_link(link: &L) -> Result { Ok(Self { - id: None, - fd: Some(link.fd()?.as_raw_fd()), + link_ref: LinkRef::Fd(link.fd()?.as_raw_fd()), flags: MprogFlags::AFTER | MprogFlags::LINK, expected_revision: None, }) @@ -505,8 +505,7 @@ impl LinkOrder { /// Ensure the link is created before a link specified by its kernel id for a given attachment point. pub fn before_link_id(id: LinkId) -> Result { Ok(Self { - id: Some(id.0), - fd: None, + link_ref: LinkRef::Id(id.0), flags: MprogFlags::BEFORE | MprogFlags::LINK | MprogFlags::ID, expected_revision: None, }) @@ -515,28 +514,25 @@ impl LinkOrder { /// Ensure the link is created after a link specified by its kernel id for a given attachment point. pub fn after_link_id(id: LinkId) -> Result { Ok(Self { - id: Some(id.0), - fd: None, + link_ref: LinkRef::Id(id.0), flags: MprogFlags::AFTER | MprogFlags::LINK | MprogFlags::ID, expected_revision: None, }) } /// Ensure the link is created before the specified aya-owned program for a given attachment point. - pub fn before_program(program: &P) -> Result { + pub fn before_program(program: &P) -> Result { Ok(Self { - id: None, - fd: Some(program.fd()?.as_raw_fd()), + link_ref: LinkRef::Fd(program.fd()?.as_raw_fd()), flags: MprogFlags::BEFORE, expected_revision: None, }) } /// Ensure the link is created after the specified aya-owned program for a given attachment point. - pub fn after_program(program: &P) -> Result { + pub fn after_program(program: &P) -> Result { Ok(Self { - id: None, - fd: Some(program.fd()?.as_raw_fd()), + link_ref: LinkRef::Fd(program.fd()?.as_raw_fd()), flags: MprogFlags::AFTER, expected_revision: None, }) @@ -545,8 +541,7 @@ impl LinkOrder { /// Ensure the link is created before a program specified by its kernel id for a given attachment point. pub fn before_program_id(id: ProgramId) -> Self { Self { - id: Some(id.0), - fd: None, + link_ref: LinkRef::Id(id.0), flags: MprogFlags::BEFORE | MprogFlags::ID, expected_revision: None, } @@ -555,8 +550,7 @@ impl LinkOrder { /// Ensure the link is created after a program specified by its kernel id for a given attachment point. pub fn after_program_id(id: ProgramId) -> Self { Self { - id: Some(id.0), - fd: None, + link_ref: LinkRef::Id(id.0), flags: MprogFlags::AFTER | MprogFlags::ID, expected_revision: None, } diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs index 4d29fdf5..34ffe52f 100644 --- a/aya/src/programs/mod.rs +++ b/aya/src/programs/mod.rs @@ -816,17 +816,17 @@ impl_fd!( /// /// # Minimum kernel version /// -/// The minimum kernel version required to use this feature is 6.6. -pub trait MprogProgram { +/// The minimum kernel version required to use this feature is 6.6.0. +pub trait MultiProgProgram { /// Returns a borrowed reference to the file descriptor of a given /// [`Program`] which has support for the kernel's generic multi-prog API. fn fd(&self) -> Result, ProgramError>; } -macro_rules! impl_mprog_fd { +macro_rules! impl_multiprog_fd { ($($struct_name:ident),+ $(,)?) => { $( - impl MprogProgram for $struct_name { + impl MultiProgProgram for $struct_name { /// Returns the a borrowed reference file descriptor of this Program. fn fd(&self) -> Result, ProgramError> { Ok(self.fd()?.as_fd()) @@ -836,24 +836,23 @@ macro_rules! impl_mprog_fd { } } -impl_mprog_fd!(SchedClassifier,); +impl_multiprog_fd!(SchedClassifier); -/// Defines which [`Link`]s support the kernel's -/// generic multi-prog API. +/// Defines the [Link] types which support the kernel's [generic multi-prog API](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=053c8e1f235dc3f69d13375b32f4209228e1cb96). /// /// # Minimum kernel version /// -/// The minimum kernel version required to use this feature is 6.6. -pub trait MprogLink { +/// The minimum kernel version required to use this feature is 6.6.0. +pub trait MultiProgLink { /// Returns a borrowed reference to the file descriptor of a given /// [`Link`] which has support for the kernel's generic multi-prog API. fn fd(&self) -> Result, LinkError>; } -macro_rules! impl_mproglink_fd { +macro_rules! impl_multiproglink_fd { ($($struct_name:ident),+ $(,)?) => { $( - impl MprogLink for $struct_name { + impl MultiProgLink for $struct_name { /// Returns the a borrowed reference file descriptor of this Program. fn fd(&self) -> Result, LinkError> { let link: &FdLink = self.try_into()?; @@ -864,7 +863,7 @@ macro_rules! impl_mproglink_fd { } } -impl_mproglink_fd!(SchedClassifierLink); +impl_multiproglink_fd!(SchedClassifierLink); macro_rules! impl_program_pin{ ($($struct_name:ident),+ $(,)?) => { diff --git a/aya/src/programs/perf_attach.rs b/aya/src/programs/perf_attach.rs index 2f62a278..ae2556f7 100644 --- a/aya/src/programs/perf_attach.rs +++ b/aya/src/programs/perf_attach.rs @@ -83,7 +83,6 @@ pub(crate) fn perf_attach( 0, None, None, - None, ) .map_err(|(_, io_error)| SyscallError { call: "bpf_link_create", diff --git a/aya/src/programs/sk_lookup.rs b/aya/src/programs/sk_lookup.rs index 8fa516a2..095c4972 100644 --- a/aya/src/programs/sk_lookup.rs +++ b/aya/src/programs/sk_lookup.rs @@ -73,7 +73,6 @@ impl SkLookup { 0, None, None, - None, ) .map_err(|(_, io_error)| SyscallError { call: "bpf_link_create", diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index f9f30187..e6a0a038 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -98,11 +98,11 @@ pub enum TcError { #[error("the clsact qdisc is already attached")] AlreadyAttached, /// tcx links can only be attached to ingress or egress - #[error("tcx links can only be attached to ingress or egress")] - InvalidTcxAttach, + #[error("tcx links can only be attached to ingress or egress, custom attachment: {0} is not supported")] + InvalidTcxAttach(u32), /// program was loaded via tcx not netlink #[error("program was loaded via tcx not netlink")] - InvalidTcLink, + InvalidLink, } impl TcAttachType { @@ -118,33 +118,23 @@ impl TcAttachType { match self { Self::Ingress => Ok(BPF_TCX_INGRESS), Self::Egress => Ok(BPF_TCX_EGRESS), - Self::Custom(_) => Err(TcError::InvalidTcxAttach), + Self::Custom(i) => Err(TcError::InvalidTcxAttach(i.to_owned())), } } } -/// Options for a SchedClassifier attach operation. The options vary based on -/// what is supported by the current kernel. Kernels older than 6.6 must utilize -/// netlink for attachements, while newer kernels can utilize the modern TCX eBPF -/// link type which support's the kernel's mprog ordering api. +/// Options for a SchedClassifier attach operation. +/// +/// The options vary based on what is supported by the current kernel. Kernels +/// older than 6.6.0 must utilize netlink for attachments, while newer kernels +/// can utilize the modern TCX eBPF link type which support's the kernel's +/// multi-prog api. +#[derive(Debug)] pub enum TcAttachOptions { /// Netlink attach options. - NlOptions(NlOptions), + Netlink(NlOptions), /// Tcx attach options. - TCXOptions(LinkOrder), -} - -impl TcAttachOptions { - /// Create a new set of tcx attach options with a specified link ordering - pub fn tcxoptions(order: LinkOrder) -> Self { - Self::TCXOptions(order) - } - - /// Create a new set of netlink attach options with a specified priority and - /// handle. - pub fn nloptions(nl: NlOptions) -> Self { - Self::NlOptions(nl) - } + TcxOrder(LinkOrder), } /// Options for SchedClassifier attach via netlink @@ -164,17 +154,22 @@ impl SchedClassifier { load_program(BPF_PROG_TYPE_SCHED_CLS, &mut self.data) } - /// Attaches the program to the given `interface` using the TCX link - /// API in the first position by default, revert to the legacy netlink API otherwise. - /// For fine-grain control over link ordering use [`SchedClassifier::attach_with_options`]. + /// Attaches the program to the given `interface`. + /// + /// On kernels >= 6.6.0, it will attempt to use the TCX interface and attach as + /// the first program. On older kernels, it will fallback to using the + /// legacy netlink interface. + /// + /// For finer grained control over link ordering use [`SchedClassifier::attach_with_options`]. /// /// The returned value can be used to detach, see [SchedClassifier::detach]. /// /// # Errors /// - /// [`TcError::NetlinkError`] is returned if attaching via netlink fails. A - /// common cause of failure is not having added the `clsact` qdisc to the given - /// interface, seeĀ [`qdisc_add_clsact`] + /// When attaching fails, [`ProgramError::SyscallError`] is returned for + /// kernels `>= 6.6.0`, and instead [`TcError::NetlinkError`] is returned for + /// older kernels. A common cause of netlink attachment failure is not having added + /// the `clsact` qdisc to the given interface, seeĀ [`qdisc_add_clsact`] /// pub fn attach( &mut self, @@ -182,18 +177,18 @@ impl SchedClassifier { attach_type: TcAttachType, ) -> Result { if KernelVersion::current().unwrap() >= KernelVersion::new(6, 6, 0) { - debug!("attaching schedClassifier program via txc link API"); + debug!("attaching schedClassifier program via tcx link API"); self.attach_with_options( interface, attach_type, - TcAttachOptions::TCXOptions(LinkOrder::default()), + TcAttachOptions::TcxOrder(LinkOrder::default()), ) } else { debug!("attaching SchedClassifier program via netlink API"); self.attach_with_options( interface, attach_type, - TcAttachOptions::NlOptions(NlOptions::default()), + TcAttachOptions::Netlink(NlOptions::default()), ) } } @@ -254,7 +249,7 @@ impl SchedClassifier { }) => self.do_attach( if_index, attach_type, - TcAttachOptions::NlOptions(NlOptions { priority, handle }), + TcAttachOptions::Netlink(NlOptions { priority, handle }), false, ), } @@ -271,7 +266,7 @@ impl SchedClassifier { let prog_fd = prog_fd.as_fd(); match options { - TcAttachOptions::NlOptions(options) => { + TcAttachOptions::Netlink(options) => { let name = self.data.name.as_deref().unwrap_or_default(); // TODO: avoid this unwrap by adding a new error variant. let name = CString::new(name).unwrap(); @@ -297,16 +292,15 @@ impl SchedClassifier { handle, }))) } - TcAttachOptions::TCXOptions(options) => { + TcAttachOptions::TcxOrder(options) => { let link_fd = bpf_link_create( prog_fd, LinkTarget::IfIndex(if_index), attach_type.tcx_attach()?, None, options.flags.bits(), - options.id, - options.fd, - None, + Some(&options.link_ref), + options.expected_revision, ) .map_err(|(_, io_error)| SyscallError { call: "bpf_mprog_attach", @@ -512,7 +506,7 @@ impl SchedClassifierLink { if let TcLinkInner::NlLink(n) = self.inner() { Ok(n.attach_type) } else { - Err(TcError::InvalidTcLink.into()) + Err(TcError::InvalidLink.into()) } } @@ -521,7 +515,7 @@ impl SchedClassifierLink { if let TcLinkInner::NlLink(n) = self.inner() { Ok(n.priority) } else { - Err(TcError::InvalidTcLink.into()) + Err(TcError::InvalidLink.into()) } } @@ -530,7 +524,7 @@ impl SchedClassifierLink { if let TcLinkInner::NlLink(n) = self.inner() { Ok(n.handle) } else { - Err(TcError::InvalidTcLink.into()) + Err(TcError::InvalidLink.into()) } } } diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs index 223fe539..90931005 100644 --- a/aya/src/programs/xdp.rs +++ b/aya/src/programs/xdp.rs @@ -152,7 +152,6 @@ impl Xdp { flags.bits(), None, None, - None, ) .map_err(|(_, io_error)| SyscallError { call: "bpf_link_create", diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs index d0949fb0..58cd6afb 100644 --- a/aya/src/sys/bpf.rs +++ b/aya/src/sys/bpf.rs @@ -30,6 +30,7 @@ use crate::{ }, copy_instructions, }, + programs::links::LinkRef, sys::{syscall, SysResult, Syscall, SyscallError}, util::KernelVersion, Btf, Pod, VerifierLogLevel, BPF_OBJ_NAME_LEN, FEATURES, @@ -379,15 +380,13 @@ pub(crate) enum LinkTarget<'f> { } // since kernel 5.7 -#[allow(clippy::too_many_arguments)] pub(crate) fn bpf_link_create( prog_fd: BorrowedFd<'_>, target: LinkTarget<'_>, attach_type: bpf_attach_type, btf_id: Option, flags: u32, - relative_id: Option, - relative_fd: Option, + link_ref: Option<&LinkRef>, expected_revision: Option, ) -> SysResult { let mut attr = unsafe { mem::zeroed::() }; @@ -415,20 +414,20 @@ pub(crate) fn bpf_link_create( attr.link_create.__bindgen_anon_3.tcx.expected_revision = expected_revision; } - match (relative_fd, relative_id) { - (Some(fd), None) => { + match link_ref { + Some(LinkRef::Fd(fd)) => { attr.link_create .__bindgen_anon_3 .tcx .__bindgen_anon_1 - .relative_fd = fd as u32; + .relative_fd = fd.to_owned() as u32; } - (None, Some(id)) => { + Some(LinkRef::Id(id)) => { attr.link_create .__bindgen_anon_3 .tcx .__bindgen_anon_1 - .relative_id = id; + .relative_id = id.to_owned(); } _ => {} }; @@ -855,7 +854,7 @@ pub(crate) fn is_perf_link_supported() -> bool { let fd = fd.as_fd(); matches!( // Uses an invalid target FD so we get EBADF if supported. - bpf_link_create(fd, LinkTarget::IfIndex(u32::MAX), bpf_attach_type::BPF_PERF_EVENT, None, 0, None, None, None), + bpf_link_create(fd, LinkTarget::IfIndex(u32::MAX), bpf_attach_type::BPF_PERF_EVENT, None, 0, None, None), // Returns EINVAL if unsupported. EBADF if supported. Err((_, e)) if e.raw_os_error() == Some(libc::EBADF), ) diff --git a/test/integration-ebpf/src/tcx.rs b/test/integration-ebpf/src/tcx.rs index 19a10383..324a1788 100644 --- a/test/integration-ebpf/src/tcx.rs +++ b/test/integration-ebpf/src/tcx.rs @@ -19,7 +19,6 @@ use network_types::{ static ORDER: i32 = 0; // Gives us raw pointers to a specific offset in the packet -#[inline(always)] unsafe fn ptr_at(ctx: &TcContext, offset: usize) -> Result<*mut T, i64> { let start = ctx.data(); let end = ctx.data_end(); diff --git a/test/integration-test/Cargo.toml b/test/integration-test/Cargo.toml index 7150d54c..5e0d81c2 100644 --- a/test/integration-test/Cargo.toml +++ b/test/integration-test/Cargo.toml @@ -27,8 +27,6 @@ test-case = { workspace = true } test-log = { workspace = true, features = ["log"] } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "time"] } xdpilone = { workspace = true } -chrono = { workspace = true } - [build-dependencies] cargo_metadata = { workspace = true } # TODO(https://github.com/rust-lang/cargo/issues/12375): this should be an artifact dependency, but diff --git a/test/integration-test/src/tests/log.rs b/test/integration-test/src/tests/log.rs index e3c00767..e59ddea7 100644 --- a/test/integration-test/src/tests/log.rs +++ b/test/integration-test/src/tests/log.rs @@ -1,11 +1,11 @@ use std::{ borrow::Cow, sync::{Arc, Mutex}, + time::Instant, }; use aya::{programs::UProbe, Ebpf}; use aya_log::EbpfLogger; -use chrono::{DateTime, Utc}; use log::{Level, Log, Record}; use test_log::test; @@ -37,7 +37,7 @@ pub(crate) struct CapturedLog<'a> { pub(crate) body: Cow<'a, str>, pub(crate) level: Level, pub(crate) target: Cow<'a, str>, - pub(crate) timestamp: Option>, + pub(crate) timestamp: Option, } #[test(tokio::test)] diff --git a/test/integration-test/src/tests/tcx.rs b/test/integration-test/src/tests/tcx.rs index d90b8011..6e270a42 100644 --- a/test/integration-test/src/tests/tcx.rs +++ b/test/integration-test/src/tests/tcx.rs @@ -1,7 +1,7 @@ use std::{ net::UdpSocket, sync::{Arc, Mutex}, - time::Duration, + time::{Duration, Instant}, }; use aya::{ @@ -10,7 +10,6 @@ use aya::{ Ebpf, EbpfLoader, }; use aya_log::EbpfLogger; -use chrono::Utc; use log::{debug, Record}; use test_log::test; @@ -30,7 +29,7 @@ fn setup_logs(loader: &mut Ebpf, logs: &Arc>>>) { body: format!("{}", record.args()).into(), level: record.level(), target: record.target().to_string().into(), - timestamp: Some(Utc::now()), + timestamp: Some(Instant::now()), }); }, }, @@ -105,15 +104,23 @@ async fn tcx_ordering() { .unwrap(); prog3.load().unwrap(); - // Test LinkOrder::first() - let options = TcAttachOptions::tcxoptions(LinkOrder::first()); + // Test LinkOrder::first() and LinkOrder::set_expected_revision() + let mut order: LinkOrder = LinkOrder::last(); + order.set_expected_revision(u64::MAX); + let options = TcAttachOptions::TcxOrder(order); + let result = prog0.attach_with_options("lo", TcAttachType::Ingress, options); + assert!(result.is_err()); + + let mut order: LinkOrder = LinkOrder::last(); + order.set_expected_revision(0); + let options = TcAttachOptions::TcxOrder(order); prog0 .attach_with_options("lo", TcAttachType::Ingress, options) .unwrap(); // Test LinkOrder::after_program() let order = LinkOrder::after_program(prog0).unwrap(); - let options = TcAttachOptions::tcxoptions(order); + let options = TcAttachOptions::TcxOrder(order); let prog1_link_id = prog1 .attach_with_options("lo", TcAttachType::Ingress, options) .unwrap(); @@ -122,13 +129,13 @@ async fn tcx_ordering() { // Test LinkOrder::after_link() let order = LinkOrder::after_link(&prog1_link).unwrap(); - let options = TcAttachOptions::tcxoptions(order); + let options = TcAttachOptions::TcxOrder(order); prog2 .attach_with_options("lo", TcAttachType::Ingress, options) .unwrap(); // Test LinkOrder::last() - let options = TcAttachOptions::tcxoptions(LinkOrder::last()); + let options = TcAttachOptions::TcxOrder(LinkOrder::last()); prog3 .attach_with_options("lo", TcAttachType::Ingress, options) .unwrap(); @@ -139,7 +146,7 @@ async fn tcx_ordering() { let addr = sock.local_addr().unwrap(); sock.set_read_timeout(Some(Duration::from_secs(60))) .unwrap(); - // We only need to send data since we're attaching tx programs to the ingress hook + // We only need to send data since we're attaching tcx programs to the ingress hook sock.send_to(PAYLOAD.as_bytes(), addr).unwrap(); // Allow logs to populate diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt index dd7d6756..2102c41d 100644 --- a/xtask/public-api/aya.txt +++ b/xtask/public-api/aya.txt @@ -4045,13 +4045,13 @@ impl core::convert::From for aya::programs::links::LinkId pub fn aya::programs::links::LinkId::from(t: T) -> T pub struct aya::programs::links::LinkOrder impl aya::programs::links::LinkOrder -pub fn aya::programs::links::LinkOrder::after_link(link: &L) -> core::result::Result +pub fn aya::programs::links::LinkOrder::after_link(link: &L) -> core::result::Result pub fn aya::programs::links::LinkOrder::after_link_id(id: aya::programs::links::LinkId) -> core::result::Result -pub fn aya::programs::links::LinkOrder::after_program(program: &P) -> core::result::Result +pub fn aya::programs::links::LinkOrder::after_program(program: &P) -> core::result::Result pub fn aya::programs::links::LinkOrder::after_program_id(id: aya::programs::ProgramId) -> Self -pub fn aya::programs::links::LinkOrder::before_link(link: &L) -> core::result::Result +pub fn aya::programs::links::LinkOrder::before_link(link: &L) -> core::result::Result pub fn aya::programs::links::LinkOrder::before_link_id(id: aya::programs::links::LinkId) -> core::result::Result -pub fn aya::programs::links::LinkOrder::before_program(program: &P) -> core::result::Result +pub fn aya::programs::links::LinkOrder::before_program(program: &P) -> core::result::Result pub fn aya::programs::links::LinkOrder::before_program_id(id: aya::programs::ProgramId) -> Self pub fn aya::programs::links::LinkOrder::first() -> Self pub fn aya::programs::links::LinkOrder::last() -> Self @@ -5624,11 +5624,10 @@ impl core::convert::From for aya::programs::socket_filter::SocketFilterLin pub fn aya::programs::socket_filter::SocketFilterLinkId::from(t: T) -> T pub mod aya::programs::tc pub enum aya::programs::tc::TcAttachOptions -pub aya::programs::tc::TcAttachOptions::NlOptions(aya::programs::tc::NlOptions) -pub aya::programs::tc::TcAttachOptions::TCXOptions(aya::programs::links::LinkOrder) -impl aya::programs::tc::TcAttachOptions -pub fn aya::programs::tc::TcAttachOptions::nloptions(nl: aya::programs::tc::NlOptions) -> Self -pub fn aya::programs::tc::TcAttachOptions::tcxoptions(order: aya::programs::links::LinkOrder) -> Self +pub aya::programs::tc::TcAttachOptions::Netlink(aya::programs::tc::NlOptions) +pub aya::programs::tc::TcAttachOptions::TcxOrder(aya::programs::links::LinkOrder) +impl core::fmt::Debug for aya::programs::tc::TcAttachOptions +pub fn aya::programs::tc::TcAttachOptions::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result impl core::marker::Freeze for aya::programs::tc::TcAttachOptions impl core::marker::Send for aya::programs::tc::TcAttachOptions impl core::marker::Sync for aya::programs::tc::TcAttachOptions @@ -5700,8 +5699,8 @@ impl core::convert::From for aya::programs::tc::TcAttachType pub fn aya::programs::tc::TcAttachType::from(t: T) -> T pub enum aya::programs::tc::TcError pub aya::programs::tc::TcError::AlreadyAttached -pub aya::programs::tc::TcError::InvalidTcLink -pub aya::programs::tc::TcError::InvalidTcxAttach +pub aya::programs::tc::TcError::InvalidLink +pub aya::programs::tc::TcError::InvalidTcxAttach(u32) pub aya::programs::tc::TcError::NetlinkError pub aya::programs::tc::TcError::NetlinkError::io_error: std::io::error::Error impl core::convert::From for aya::programs::ProgramError @@ -5793,7 +5792,7 @@ pub fn aya::programs::tc::SchedClassifier::pin core::result::Result<(), std::io::error::Error> impl aya::programs::tc::SchedClassifier pub fn aya::programs::tc::SchedClassifier::unload(&mut self) -> core::result::Result<(), aya::programs::ProgramError> -impl aya::programs::MprogProgram for aya::programs::tc::SchedClassifier +impl aya::programs::MultiProgProgram for aya::programs::tc::SchedClassifier pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result, aya::programs::ProgramError> impl core::fmt::Debug for aya::programs::tc::SchedClassifier pub fn aya::programs::tc::SchedClassifier::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result @@ -5833,7 +5832,7 @@ pub fn aya::programs::tc::SchedClassifierLink::attach_type(&self) -> core::resul pub fn aya::programs::tc::SchedClassifierLink::attached(if_name: &str, attach_type: aya::programs::tc::TcAttachType, priority: u16, handle: u32) -> core::result::Result pub fn aya::programs::tc::SchedClassifierLink::handle(&self) -> core::result::Result pub fn aya::programs::tc::SchedClassifierLink::priority(&self) -> core::result::Result -impl aya::programs::MprogLink for aya::programs::tc::SchedClassifierLink +impl aya::programs::MultiProgLink for aya::programs::tc::SchedClassifierLink pub fn aya::programs::tc::SchedClassifierLink::fd(&self) -> core::result::Result, aya::programs::links::LinkError> impl aya::programs::links::Link for aya::programs::tc::SchedClassifierLink pub type aya::programs::tc::SchedClassifierLink::Id = aya::programs::tc::SchedClassifierLinkId @@ -7396,8 +7395,8 @@ impl core::convert::From for aya::programs::tc::TcAttachType pub fn aya::programs::tc::TcAttachType::from(t: T) -> T pub enum aya::programs::TcError pub aya::programs::TcError::AlreadyAttached -pub aya::programs::TcError::InvalidTcLink -pub aya::programs::TcError::InvalidTcxAttach +pub aya::programs::TcError::InvalidLink +pub aya::programs::TcError::InvalidTcxAttach(u32) pub aya::programs::TcError::NetlinkError pub aya::programs::TcError::NetlinkError::io_error: std::io::error::Error impl core::convert::From for aya::programs::ProgramError @@ -8086,13 +8085,13 @@ impl core::convert::From for aya::programs::kprobe::KProbe pub fn aya::programs::kprobe::KProbe::from(t: T) -> T pub struct aya::programs::LinkOrder impl aya::programs::links::LinkOrder -pub fn aya::programs::links::LinkOrder::after_link(link: &L) -> core::result::Result +pub fn aya::programs::links::LinkOrder::after_link(link: &L) -> core::result::Result pub fn aya::programs::links::LinkOrder::after_link_id(id: aya::programs::links::LinkId) -> core::result::Result -pub fn aya::programs::links::LinkOrder::after_program(program: &P) -> core::result::Result +pub fn aya::programs::links::LinkOrder::after_program(program: &P) -> core::result::Result pub fn aya::programs::links::LinkOrder::after_program_id(id: aya::programs::ProgramId) -> Self -pub fn aya::programs::links::LinkOrder::before_link(link: &L) -> core::result::Result +pub fn aya::programs::links::LinkOrder::before_link(link: &L) -> core::result::Result pub fn aya::programs::links::LinkOrder::before_link_id(id: aya::programs::links::LinkId) -> core::result::Result -pub fn aya::programs::links::LinkOrder::before_program(program: &P) -> core::result::Result +pub fn aya::programs::links::LinkOrder::before_program(program: &P) -> core::result::Result pub fn aya::programs::links::LinkOrder::before_program_id(id: aya::programs::ProgramId) -> Self pub fn aya::programs::links::LinkOrder::first() -> Self pub fn aya::programs::links::LinkOrder::last() -> Self @@ -8436,7 +8435,7 @@ pub fn aya::programs::tc::SchedClassifier::pin core::result::Result<(), std::io::error::Error> impl aya::programs::tc::SchedClassifier pub fn aya::programs::tc::SchedClassifier::unload(&mut self) -> core::result::Result<(), aya::programs::ProgramError> -impl aya::programs::MprogProgram for aya::programs::tc::SchedClassifier +impl aya::programs::MultiProgProgram for aya::programs::tc::SchedClassifier pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result, aya::programs::ProgramError> impl core::fmt::Debug for aya::programs::tc::SchedClassifier pub fn aya::programs::tc::SchedClassifier::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result @@ -9087,13 +9086,13 @@ impl aya::programs::links::Link for aya::programs::xdp::XdpLink pub type aya::programs::xdp::XdpLink::Id = aya::programs::xdp::XdpLinkId pub fn aya::programs::xdp::XdpLink::detach(self) -> core::result::Result<(), aya::programs::ProgramError> pub fn aya::programs::xdp::XdpLink::id(&self) -> Self::Id -pub trait aya::programs::MprogLink -pub fn aya::programs::MprogLink::fd(&self) -> core::result::Result, aya::programs::links::LinkError> -impl aya::programs::MprogLink for aya::programs::tc::SchedClassifierLink +pub trait aya::programs::MultiProgLink +pub fn aya::programs::MultiProgLink::fd(&self) -> core::result::Result, aya::programs::links::LinkError> +impl aya::programs::MultiProgLink for aya::programs::tc::SchedClassifierLink pub fn aya::programs::tc::SchedClassifierLink::fd(&self) -> core::result::Result, aya::programs::links::LinkError> -pub trait aya::programs::MprogProgram -pub fn aya::programs::MprogProgram::fd(&self) -> core::result::Result, aya::programs::ProgramError> -impl aya::programs::MprogProgram for aya::programs::tc::SchedClassifier +pub trait aya::programs::MultiProgProgram +pub fn aya::programs::MultiProgProgram::fd(&self) -> core::result::Result, aya::programs::ProgramError> +impl aya::programs::MultiProgProgram for aya::programs::tc::SchedClassifier pub fn aya::programs::tc::SchedClassifier::fd(&self) -> core::result::Result, aya::programs::ProgramError> pub fn aya::programs::loaded_programs() -> impl core::iter::traits::iterator::Iterator> pub mod aya::sys