diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 38853e515..2d6d580ca 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,5 @@ + + -# Summary -# Related Issues -# Added/updated tests? +### Added/updated tests? _We strongly encourage you to add a test for your changes._ @@ -37,7 +42,7 @@ _We strongly encourage you to add a test for your changes._ have not been included_ - [ ] I need help with writing tests -# Checklist +### Checklist - [ ] Rust code has been formatted with `cargo +nightly fmt`. - [ ] All clippy lints have been fixed. @@ -48,4 +53,4 @@ _We strongly encourage you to add a test for your changes._ [Integration tests]: https://github.com/aya-rs/aya/blob/main/test/README.md -# (Optional) What GIF best describes this PR or how it makes you feel? +### (Optional) What GIF best describes this PR or how it makes you feel? diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 925cd6f1f..6403371bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: - run: git ls-files -- '*.c' '*.h' | xargs clang-format --dry-run --Werror - - uses: DavidAnson/markdownlint-cli2-action@v22 + - uses: DavidAnson/markdownlint-cli2-action@v23 - run: taplo fmt --check @@ -177,9 +177,10 @@ jobs: - uses: Swatinem/rust-cache@v2 - - run: cargo install --git https://github.com/aya-rs/bpf-linker.git bpf-linker - - - uses: taiki-e/install-action@cargo-hack + - uses: taiki-e/install-action@v2 + with: + tool: cargo-binstall,cargo-hack + - run: cargo binstall --force bpf-linker - name: Build & test for all BPF architectures env: @@ -288,11 +289,14 @@ jobs: sudo apt update # linux-libc-dev provides kernel UAPI headers for libbpf-sys cross-compilation. # + # llvm provides llvm-objcopy for integration tests. + # # See https://github.com/libbpf/libbpf-sys/issues/137. sudo apt -y install \ autopoint \ linux-libc-dev \ liblzma-dev \ + llvm \ lynx \ musl-tools \ qemu-system-{arm,x86} @@ -305,10 +309,6 @@ jobs: brew bundle echo $(brew --prefix curl)/bin >> $GITHUB_PATH echo $(brew --prefix llvm)/bin >> $GITHUB_PATH - # Point bpf-linker's build.rs to the brew prefixes with static - # libraries it needs. - echo "CXXSTDLIB_PATH=$(brew --prefix llvm)/lib/c++" >> $GITHUB_ENV - echo "ZLIB_PATH=$(brew --prefix zlib)/lib" >> $GITHUB_ENV # https://github.com/actions/setup-python/issues/577 find /usr/local/bin -type l -exec sh -c 'readlink -f "$1" \ @@ -325,60 +325,10 @@ jobs: - uses: Swatinem/rust-cache@v2 - - name: Install libLLVM - # Download libLLVM from Rust CI to ensure that the libLLVM version - # matches exactly with the version used by the current Rust nightly. A - # mismatch between libLLVM (used by bpf-linker) and Rust's LLVM version - # can lead to linking issues. - run: | - set -euxo pipefail - # Get the partial SHA from Rust nightly. - rustc_sha=$(rustc +nightly --version | grep -oE '[a-f0-9]{7,40}') - # Get the full SHA from GitHub. - rustc_sha=$(curl -sfSL https://api.github.com/repos/rust-lang/rust/commits/$rustc_sha \ - --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ - --header 'content-type: application/json' \ - | jq -r '.sha') - mkdir -p /tmp/rustc-llvm - case "${{ runner.arch }}" in - ARM64) - arch=aarch64 - ;; - X64) - arch=x86_64 - ;; - *) - echo "::error::Unsupported runner architecture: ${{ runner.arch }}" - exit 1 - ;; - esac - case "${{ runner.os }}" in - Linux) - target=${arch}-unknown-linux-gnu - ;; - macOS) - target=${arch}-apple-darwin - echo "LLVM_LINK_FEATURE=llvm-link-static" >> $GITHUB_ENV - ;; - *) - echo "::error::Unsupported runner OS: ${{ runner.os }}" - exit 1 - ;; - esac - curl -sfSL https://ci-artifacts.rust-lang.org/rustc-builds/$rustc_sha/rust-dev-nightly-${target}.tar.xz | \ - tar -xJ --strip-components 2 -C /tmp/rustc-llvm - echo /tmp/rustc-llvm/bin >> $GITHUB_PATH - - # NB: rustc doesn't ship libLLVM.so on macOS, so disable proxying (default feature). We also - # --force so that bpf-linker gets always relinked against the latest LLVM downloaded above. - # - # Add the downloaded LLVM to PATH for this build step. - # - # Do this on all system (not just macOS) to avoid relying on rustc-provided libLLVM.so. - - run: | - cargo install \ - --git https://github.com/aya-rs/bpf-linker.git bpf-linker \ - --no-default-features --features "llvm-22,${LLVM_LINK_FEATURE}" --force + - uses: taiki-e/install-action@v2 + with: + tool: cargo-binstall,cargo-hack + - run: cargo binstall --force bpf-linker - uses: actions/cache@v5 with: diff --git a/Brewfile b/Brewfile index 54aad4e51..6c78c23d7 100644 --- a/Brewfile +++ b/Brewfile @@ -17,9 +17,6 @@ brew "autoconf" brew "automake" brew "gawk" -# macOS provides only dynamic zlib. Install the static one. -brew "zlib" - # We need a musl C toolchain to compile our `test-distro` since some of our # dependencies have build scripts that compile C code (i.e xz2). tap "filosottile/musl-cross" diff --git a/Cargo.toml b/Cargo.toml index e135acb20..840d05ac9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ members = [ # ebpf crates "ebpf/aya-ebpf", "ebpf/aya-ebpf-bindings", + "ebpf/aya-ebpf-cty", "ebpf/aya-log-ebpf", "test/integration-ebpf", ] @@ -87,7 +88,7 @@ log = { version = "0.4", default-features = false } network-types = { version = "0.1.0", default-features = false } nix = { version = "0.31.1", default-features = false } num_enum = { version = "0.7", default-features = false } -object = { version = "0.38", default-features = false } +object = { version = "0.39", default-features = false } once_cell = { version = "1.20.1", default-features = false } proc-macro2 = { version = "1", default-features = false } proc-macro2-diagnostics = { version = "0.10.1", default-features = false } diff --git a/aya-obj/src/btf/types.rs b/aya-obj/src/btf/types.rs index 4c11fa2b6..e82cc7afa 100644 --- a/aya-obj/src/btf/types.rs +++ b/aya-obj/src/btf/types.rs @@ -271,7 +271,7 @@ impl Func { } pub(crate) fn linkage(&self) -> FuncLinkage { - (self.info & 0xFFF).into() + (self.info & 0xFFFF).into() } pub(crate) const fn set_linkage(&mut self, linkage: FuncLinkage) { diff --git a/aya-obj/src/obj.rs b/aya-obj/src/obj.rs index ccb37527e..7c3f8441e 100644 --- a/aya-obj/src/obj.rs +++ b/aya-obj/src/obj.rs @@ -32,7 +32,8 @@ use crate::{ }, maps::{BtfMap, BtfMapDef, LegacyMap, MINIMUM_MAP_SIZE, Map, PinningType, bpf_map_def}, programs::{ - CgroupSockAddrAttachType, CgroupSockAttachType, CgroupSockoptAttachType, XdpAttachType, + CgroupSkbAttachType, CgroupSockAddrAttachType, CgroupSockAttachType, + CgroupSockoptAttachType, SkSkbKind, XdpAttachType, }, relocation::{INS_SIZE, Relocation, Symbol}, util::HashMap, @@ -247,13 +248,14 @@ pub enum ProgramSection { attach_type: XdpAttachType, }, SkMsg, - SkSkbStreamParser, - SkSkbStreamVerdict, + SkSkbStream { + kind: SkSkbKind, + }, SockOps, SchedClassifier, - CgroupSkb, - CgroupSkbIngress, - CgroupSkbEgress, + CgroupSkb { + attach_type: Option, + }, CgroupSockAddr { attach_type: CgroupSockAddrAttachType, }, @@ -329,34 +331,36 @@ impl FromStr for ProgramSection { "sk_msg" => Self::SkMsg, "sk_skb" => { let name = next()?; - match name { - "stream_parser" => Self::SkSkbStreamParser, - "stream_verdict" => Self::SkSkbStreamVerdict, + let kind = match name { + "stream_parser" => SkSkbKind::StreamParser, + "stream_verdict" => SkSkbKind::StreamVerdict, _ => { return Err(ParseError::InvalidProgramSection { section: section.to_owned(), }); } - } + }; + Self::SkSkbStream { kind } } "sockops" => Self::SockOps, "classifier" => Self::SchedClassifier, "cgroup_skb" => { let name = next()?; - match name { - "ingress" => Self::CgroupSkbIngress, - "egress" => Self::CgroupSkbEgress, + let attach_type = Some(match name { + "ingress" => CgroupSkbAttachType::Ingress, + "egress" => CgroupSkbAttachType::Egress, _ => { return Err(ParseError::InvalidProgramSection { section: section.to_owned(), }); } - } + }); + Self::CgroupSkb { attach_type } } "cgroup" => { let name = next()?; match name { - "skb" => Self::CgroupSkb, + "skb" => Self::CgroupSkb { attach_type: None }, "sysctl" => Self::CgroupSysctl, "dev" => Self::CgroupDevice, "getsockopt" => Self::CgroupSockopt { @@ -2291,7 +2295,9 @@ mod tests { assert_matches!( obj.programs.get("stream_parser"), Some(Program { - section: ProgramSection::SkSkbStreamParser, + section: ProgramSection::SkSkbStream { + kind: SkSkbKind::StreamParser + }, .. }) ); @@ -2314,7 +2320,9 @@ mod tests { assert_matches!( obj.programs.get("my_parser"), Some(Program { - section: ProgramSection::SkSkbStreamParser, + section: ProgramSection::SkSkbStream { + kind: SkSkbKind::StreamParser + }, .. }) ); @@ -2435,7 +2443,9 @@ mod tests { assert_matches!( obj.programs.get("ingress"), Some(Program { - section: ProgramSection::CgroupSkbIngress, + section: ProgramSection::CgroupSkb { + attach_type: Some(CgroupSkbAttachType::Ingress), + }, .. }) ); @@ -2458,7 +2468,9 @@ mod tests { assert_matches!( obj.programs.get("foo"), Some(Program { - section: ProgramSection::CgroupSkbIngress, + section: ProgramSection::CgroupSkb { + attach_type: Some(CgroupSkbAttachType::Ingress), + }, .. }) ); @@ -2481,7 +2493,7 @@ mod tests { assert_matches!( obj.programs.get("skb"), Some(Program { - section: ProgramSection::CgroupSkb, + section: ProgramSection::CgroupSkb { attach_type: None }, .. }) ); @@ -2504,7 +2516,7 @@ mod tests { assert_matches!( obj.programs.get("foo"), Some(Program { - section: ProgramSection::CgroupSkb, + section: ProgramSection::CgroupSkb { attach_type: None }, .. }) ); diff --git a/aya-obj/src/programs/cgroup_skb.rs b/aya-obj/src/programs/cgroup_skb.rs new file mode 100644 index 000000000..820b587b7 --- /dev/null +++ b/aya-obj/src/programs/cgroup_skb.rs @@ -0,0 +1,20 @@ +//! Cgroup skb programs. +use crate::generated::bpf_attach_type; + +/// Defines where to attach a `CgroupSkb` program. +#[derive(Copy, Clone, Debug)] +pub enum CgroupSkbAttachType { + /// Attach to ingress. + Ingress, + /// Attach to egress. + Egress, +} + +impl From for bpf_attach_type { + fn from(s: CgroupSkbAttachType) -> Self { + match s { + CgroupSkbAttachType::Ingress => Self::BPF_CGROUP_INET_INGRESS, + CgroupSkbAttachType::Egress => Self::BPF_CGROUP_INET_EGRESS, + } + } +} diff --git a/aya-obj/src/programs/mod.rs b/aya-obj/src/programs/mod.rs index b6e91e7a0..dad3bf43e 100644 --- a/aya-obj/src/programs/mod.rs +++ b/aya-obj/src/programs/mod.rs @@ -1,12 +1,16 @@ //! Program struct and type bindings. +pub mod cgroup_skb; pub mod cgroup_sock; pub mod cgroup_sock_addr; pub mod cgroup_sockopt; +pub mod sk_skb; mod types; pub mod xdp; +pub use cgroup_skb::CgroupSkbAttachType; pub use cgroup_sock::CgroupSockAttachType; pub use cgroup_sock_addr::CgroupSockAddrAttachType; pub use cgroup_sockopt::CgroupSockoptAttachType; +pub use sk_skb::SkSkbKind; pub use xdp::XdpAttachType; diff --git a/aya-obj/src/programs/sk_skb.rs b/aya-obj/src/programs/sk_skb.rs new file mode 100644 index 000000000..76efdf340 --- /dev/null +++ b/aya-obj/src/programs/sk_skb.rs @@ -0,0 +1,20 @@ +//! Sk skb programs. +use crate::generated::bpf_attach_type; + +/// Defines the kind of a `SkSkb` program. +#[derive(Copy, Clone, Debug)] +pub enum SkSkbKind { + /// A Stream Parser + StreamParser, + /// A Stream Verdict + StreamVerdict, +} + +impl From for bpf_attach_type { + fn from(s: SkSkbKind) -> Self { + match s { + SkSkbKind::StreamParser => Self::BPF_SK_SKB_STREAM_PARSER, + SkSkbKind::StreamVerdict => Self::BPF_SK_SKB_STREAM_VERDICT, + } + } +} diff --git a/aya-obj/src/relocation.rs b/aya-obj/src/relocation.rs index 67a5d8307..69d70a314 100644 --- a/aya-obj/src/relocation.rs +++ b/aya-obj/src/relocation.rs @@ -475,7 +475,7 @@ impl<'a> FunctionLinker<'a> { }); program.line_info.line_info.extend(line_info); - program.line_info.num_info = program.func_info.func_info.len() as u32; + program.line_info.num_info = program.line_info.line_info.len() as u32; } } } diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index cf314d1cf..f20022781 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -19,11 +19,10 @@ use thiserror::Error; use crate::{ maps::{Map, MapData, MapError}, programs::{ - BtfTracePoint, CgroupDevice, CgroupSkb, CgroupSkbAttachType, CgroupSock, CgroupSockAddr, - CgroupSockopt, CgroupSysctl, Extension, FEntry, FExit, FlowDissector, Iter, KProbe, - LircMode2, Lsm, LsmCgroup, PerfEvent, ProbeKind, Program, ProgramData, ProgramError, - RawTracePoint, SchedClassifier, SkLookup, SkMsg, SkSkb, SkSkbKind, SockOps, SocketFilter, - TracePoint, UProbe, Xdp, + BtfTracePoint, CgroupDevice, CgroupSkb, CgroupSock, CgroupSockAddr, CgroupSockopt, + CgroupSysctl, Extension, FEntry, FExit, FlowDissector, Iter, KProbe, LircMode2, Lsm, + LsmCgroup, PerfEvent, ProbeKind, Program, ProgramData, ProgramError, RawTracePoint, + SchedClassifier, SkLookup, SkMsg, SkSkb, SockOps, SocketFilter, TracePoint, UProbe, Xdp, }, sys::{ bpf_load_btf, is_bpf_cookie_supported, is_bpf_global_data_supported, @@ -458,13 +457,10 @@ impl<'a> EbpfLoader<'a> { attach_type: _, } | ProgramSection::SkMsg - | ProgramSection::SkSkbStreamParser - | ProgramSection::SkSkbStreamVerdict + | ProgramSection::SkSkbStream { kind: _ } | ProgramSection::SockOps | ProgramSection::SchedClassifier - | ProgramSection::CgroupSkb - | ProgramSection::CgroupSkbIngress - | ProgramSection::CgroupSkbEgress + | ProgramSection::CgroupSkb { attach_type: _ } | ProgramSection::CgroupSockAddr { attach_type: _ } | ProgramSection::CgroupSysctl | ProgramSection::CgroupSockopt { attach_type: _ } @@ -637,13 +633,9 @@ impl<'a> EbpfLoader<'a> { attach_type: *attach_type, }) } - ProgramSection::SkSkbStreamParser => Program::SkSkb(SkSkb { + ProgramSection::SkSkbStream { kind } => Program::SkSkb(SkSkb { data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), - kind: SkSkbKind::StreamParser, - }), - ProgramSection::SkSkbStreamVerdict => Program::SkSkb(SkSkb { - data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), - kind: SkSkbKind::StreamVerdict, + kind: *kind, }), ProgramSection::SockOps => Program::SockOps(SockOps { data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), @@ -653,18 +645,12 @@ impl<'a> EbpfLoader<'a> { data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), }) } - ProgramSection::CgroupSkb => Program::CgroupSkb(CgroupSkb { - data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), - attach_type: None, - }), - ProgramSection::CgroupSkbIngress => Program::CgroupSkb(CgroupSkb { - data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), - attach_type: Some(CgroupSkbAttachType::Ingress), - }), - ProgramSection::CgroupSkbEgress => Program::CgroupSkb(CgroupSkb { - data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), - attach_type: Some(CgroupSkbAttachType::Egress), - }), + ProgramSection::CgroupSkb { attach_type } => { + Program::CgroupSkb(CgroupSkb { + data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), + attach_type: *attach_type, + }) + } ProgramSection::CgroupSockAddr { attach_type, .. } => { Program::CgroupSockAddr(CgroupSockAddr { data: ProgramData::new(prog_name, obj, btf_fd, *verifier_log_level), diff --git a/aya/src/programs/cgroup_device.rs b/aya/src/programs/cgroup_device.rs index 1b801caaa..63285c33d 100644 --- a/aya/src/programs/cgroup_device.rs +++ b/aya/src/programs/cgroup_device.rs @@ -9,7 +9,8 @@ use aya_obj::generated::{ use crate::{ programs::{ CgroupAttachMode, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, ProgramFd, - ProgramType, bpf_prog_get_fd_by_id, define_link_wrapper, id_as_key, load_program, query, + ProgramType, bpf_prog_get_fd_by_id, define_link_wrapper, id_as_key, + load_program_with_attach_type, query, }, sys::{LinkTarget, ProgQueryTarget, SyscallError, bpf_link_create}, util::KernelVersion, @@ -61,7 +62,8 @@ impl CgroupDevice { /// Loads the program inside the kernel pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_CGROUP_DEVICE, &mut self.data) + let Self { data } = self; + load_program_with_attach_type(BPF_PROG_TYPE_CGROUP_DEVICE, BPF_CGROUP_DEVICE, data) } /// Attaches the program to the given cgroup. @@ -75,12 +77,12 @@ impl CgroupDevice { let prog_fd = self.fd()?; let prog_fd = prog_fd.as_fd(); let cgroup_fd = cgroup.as_fd(); - + let attach_type = BPF_CGROUP_DEVICE; if KernelVersion::at_least(5, 7, 0) { let link_fd = bpf_link_create( prog_fd, LinkTarget::Fd(cgroup_fd), - BPF_CGROUP_DEVICE, + attach_type, mode.into(), None, ) @@ -94,7 +96,7 @@ impl CgroupDevice { FdLink::new(link_fd), ))) } else { - let link = ProgAttachLink::attach(prog_fd, cgroup_fd, BPF_CGROUP_DEVICE, mode)?; + let link = ProgAttachLink::attach(prog_fd, cgroup_fd, attach_type, mode)?; self.data .links diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs index cf3451a54..97bc5fe83 100644 --- a/aya/src/programs/cgroup_skb.rs +++ b/aya/src/programs/cgroup_skb.rs @@ -2,10 +2,8 @@ use std::{hash::Hash, os::fd::AsFd, path::Path}; -use aya_obj::generated::{ - bpf_attach_type::{BPF_CGROUP_INET_EGRESS, BPF_CGROUP_INET_INGRESS}, - bpf_prog_type::BPF_PROG_TYPE_CGROUP_SKB, -}; +use aya_obj::generated::bpf_prog_type::BPF_PROG_TYPE_CGROUP_SKB; +pub use aya_obj::programs::CgroupSkbAttachType; use crate::{ VerifierLogLevel, @@ -66,11 +64,8 @@ impl CgroupSkb { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - self.data.expected_attach_type = self.attach_type.map(|attach_type| match attach_type { - CgroupSkbAttachType::Ingress => BPF_CGROUP_INET_INGRESS, - CgroupSkbAttachType::Egress => BPF_CGROUP_INET_EGRESS, - }); - load_program(BPF_PROG_TYPE_CGROUP_SKB, &mut self.data) + let Self { data, attach_type } = self; + load_program(BPF_PROG_TYPE_CGROUP_SKB, attach_type.map(Into::into), data) } /// Returns the expected attach type of the program. @@ -95,11 +90,6 @@ impl CgroupSkb { let prog_fd = self.fd()?; let prog_fd = prog_fd.as_fd(); let cgroup_fd = cgroup.as_fd(); - - let attach_type = match attach_type { - CgroupSkbAttachType::Ingress => BPF_CGROUP_INET_INGRESS, - CgroupSkbAttachType::Egress => BPF_CGROUP_INET_EGRESS, - }; if KernelVersion::at_least(5, 7, 0) { let link_fd = bpf_link_create( prog_fd, @@ -185,12 +175,3 @@ define_link_wrapper!( ); impl_try_into_fdlink!(CgroupSkbLink, CgroupSkbLinkInner); - -/// Defines where to attach a [`CgroupSkb`] program. -#[derive(Copy, Clone, Debug)] -pub enum CgroupSkbAttachType { - /// Attach to ingress. - Ingress, - /// Attach to egress. - Egress, -} diff --git a/aya/src/programs/cgroup_sock.rs b/aya/src/programs/cgroup_sock.rs index b3d116f2e..69ba1a6e7 100644 --- a/aya/src/programs/cgroup_sock.rs +++ b/aya/src/programs/cgroup_sock.rs @@ -9,7 +9,7 @@ use crate::{ VerifierLogLevel, programs::{ CgroupAttachMode, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, ProgramType, - define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program, + define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_link_create}, util::KernelVersion, @@ -63,8 +63,8 @@ impl CgroupSock { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(self.attach_type.into()); - load_program(BPF_PROG_TYPE_CGROUP_SOCK, &mut self.data) + let Self { data, attach_type } = self; + load_program_with_attach_type(BPF_PROG_TYPE_CGROUP_SOCK, *attach_type, data) } /// Attaches the program to the given cgroup. @@ -75,15 +75,15 @@ impl CgroupSock { cgroup: T, mode: CgroupAttachMode, ) -> Result { - let prog_fd = self.fd()?; + let Self { data, attach_type } = self; + let prog_fd = data.fd()?; let prog_fd = prog_fd.as_fd(); let cgroup_fd = cgroup.as_fd(); - let attach_type = self.data.expected_attach_type.unwrap(); if KernelVersion::at_least(5, 7, 0) { let link_fd = bpf_link_create( prog_fd, LinkTarget::Fd(cgroup_fd), - attach_type, + *attach_type, mode.into(), None, ) @@ -91,16 +91,14 @@ impl CgroupSock { call: "bpf_link_create", io_error, })?; - self.data - .links + data.links .insert(CgroupSockLink::new(CgroupSockLinkInner::Fd(FdLink::new( link_fd, )))) } else { - let link = ProgAttachLink::attach(prog_fd, cgroup_fd, attach_type, mode)?; + let link = ProgAttachLink::attach(prog_fd, cgroup_fd, *attach_type, mode)?; - self.data - .links + data.links .insert(CgroupSockLink::new(CgroupSockLinkInner::ProgAttach(link))) } } diff --git a/aya/src/programs/cgroup_sock_addr.rs b/aya/src/programs/cgroup_sock_addr.rs index 0be64cab2..bc18ff618 100644 --- a/aya/src/programs/cgroup_sock_addr.rs +++ b/aya/src/programs/cgroup_sock_addr.rs @@ -9,7 +9,7 @@ use crate::{ VerifierLogLevel, programs::{ CgroupAttachMode, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, ProgramType, - define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program, + define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_link_create}, util::KernelVersion, @@ -64,8 +64,8 @@ impl CgroupSockAddr { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(self.attach_type.into()); - load_program(BPF_PROG_TYPE_CGROUP_SOCK_ADDR, &mut self.data) + let Self { data, attach_type } = self; + load_program_with_attach_type(BPF_PROG_TYPE_CGROUP_SOCK_ADDR, *attach_type, data) } /// Attaches the program to the given cgroup. @@ -76,15 +76,15 @@ impl CgroupSockAddr { cgroup: T, mode: CgroupAttachMode, ) -> Result { - let prog_fd = self.fd()?; + let Self { data, attach_type } = self; + let prog_fd = data.fd()?; let prog_fd = prog_fd.as_fd(); let cgroup_fd = cgroup.as_fd(); - let attach_type = self.data.expected_attach_type.unwrap(); if KernelVersion::at_least(5, 7, 0) { let link_fd = bpf_link_create( prog_fd, LinkTarget::Fd(cgroup_fd), - attach_type, + *attach_type, mode.into(), None, ) @@ -92,15 +92,14 @@ impl CgroupSockAddr { call: "bpf_link_create", io_error, })?; - self.data - .links + data.links .insert(CgroupSockAddrLink::new(CgroupSockAddrLinkInner::Fd( FdLink::new(link_fd), ))) } else { - let link = ProgAttachLink::attach(prog_fd, cgroup_fd, attach_type, mode)?; + let link = ProgAttachLink::attach(prog_fd, cgroup_fd, *attach_type, mode)?; - self.data.links.insert(CgroupSockAddrLink::new( + data.links.insert(CgroupSockAddrLink::new( CgroupSockAddrLinkInner::ProgAttach(link), )) } diff --git a/aya/src/programs/cgroup_sockopt.rs b/aya/src/programs/cgroup_sockopt.rs index 389c7d94f..97f860a3b 100644 --- a/aya/src/programs/cgroup_sockopt.rs +++ b/aya/src/programs/cgroup_sockopt.rs @@ -9,7 +9,7 @@ use crate::{ VerifierLogLevel, programs::{ CgroupAttachMode, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, ProgramType, - define_link_wrapper, id_as_key, load_program, + define_link_wrapper, id_as_key, load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_link_create}, util::KernelVersion, @@ -61,8 +61,8 @@ impl CgroupSockopt { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(self.attach_type.into()); - load_program(BPF_PROG_TYPE_CGROUP_SOCKOPT, &mut self.data) + let Self { data, attach_type } = self; + load_program_with_attach_type(BPF_PROG_TYPE_CGROUP_SOCKOPT, *attach_type, data) } /// Attaches the program to the given cgroup. @@ -73,15 +73,15 @@ impl CgroupSockopt { cgroup: T, mode: CgroupAttachMode, ) -> Result { - let prog_fd = self.fd()?; + let Self { data, attach_type } = self; + let prog_fd = data.fd()?; let prog_fd = prog_fd.as_fd(); let cgroup_fd = cgroup.as_fd(); - let attach_type = self.data.expected_attach_type.unwrap(); if KernelVersion::at_least(5, 7, 0) { let link_fd = bpf_link_create( prog_fd, LinkTarget::Fd(cgroup_fd), - attach_type, + *attach_type, mode.into(), None, ) @@ -89,16 +89,14 @@ impl CgroupSockopt { call: "bpf_link_create", io_error, })?; - self.data - .links + data.links .insert(CgroupSockoptLink::new(CgroupSockoptLinkInner::Fd( FdLink::new(link_fd), ))) } else { - let link = ProgAttachLink::attach(prog_fd, cgroup_fd, attach_type, mode)?; + let link = ProgAttachLink::attach(prog_fd, cgroup_fd, *attach_type, mode)?; - self.data - .links + data.links .insert(CgroupSockoptLink::new(CgroupSockoptLinkInner::ProgAttach( link, ))) diff --git a/aya/src/programs/cgroup_sysctl.rs b/aya/src/programs/cgroup_sysctl.rs index 07d82a083..bcae2ab47 100644 --- a/aya/src/programs/cgroup_sysctl.rs +++ b/aya/src/programs/cgroup_sysctl.rs @@ -9,7 +9,7 @@ use aya_obj::generated::{ use crate::{ programs::{ CgroupAttachMode, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, ProgramType, - define_link_wrapper, id_as_key, load_program, + define_link_wrapper, id_as_key, load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_link_create}, util::KernelVersion, @@ -60,7 +60,8 @@ impl CgroupSysctl { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_CGROUP_SYSCTL, &mut self.data) + let Self { data } = self; + load_program_with_attach_type(BPF_PROG_TYPE_CGROUP_SYSCTL, BPF_CGROUP_SYSCTL, data) } /// Attaches the program to the given cgroup. @@ -74,12 +75,12 @@ impl CgroupSysctl { let prog_fd = self.fd()?; let prog_fd = prog_fd.as_fd(); let cgroup_fd = cgroup.as_fd(); - + let attach_type = BPF_CGROUP_SYSCTL; if KernelVersion::at_least(5, 7, 0) { let link_fd = bpf_link_create( prog_fd, LinkTarget::Fd(cgroup_fd), - BPF_CGROUP_SYSCTL, + attach_type, mode.into(), None, ) @@ -93,7 +94,7 @@ impl CgroupSysctl { FdLink::new(link_fd), ))) } else { - let link = ProgAttachLink::attach(prog_fd, cgroup_fd, BPF_CGROUP_SYSCTL, mode)?; + let link = ProgAttachLink::attach(prog_fd, cgroup_fd, attach_type, mode)?; self.data .links diff --git a/aya/src/programs/extension.rs b/aya/src/programs/extension.rs index 7bfcc3c13..53e91152a 100644 --- a/aya/src/programs/extension.rs +++ b/aya/src/programs/extension.rs @@ -13,7 +13,7 @@ use crate::{ Btf, programs::{ FdLink, FdLinkId, ProgramData, ProgramError, ProgramFd, ProgramType, define_link_wrapper, - load_program, + load_program_without_attach_type, }, sys::{self, BpfLinkCreateArgs, LinkTarget, SyscallError, bpf_link_create}, }; @@ -77,12 +77,13 @@ impl Extension { /// There are no restrictions on what functions may be replaced, so you could replace /// the main entry point of your program with an extension. pub fn load(&mut self, program: ProgramFd, func_name: &str) -> Result<(), ProgramError> { + let Self { data } = self; let (btf_fd, btf_id) = get_btf_info(program.as_fd(), func_name)?; - self.data.attach_btf_obj_fd = Some(btf_fd); - self.data.attach_prog_fd = Some(program); - self.data.attach_btf_id = Some(btf_id); - load_program(BPF_PROG_TYPE_EXT, &mut self.data) + data.attach_btf_obj_fd = Some(btf_fd); + data.attach_prog_fd = Some(program); + data.attach_btf_id = Some(btf_id); + load_program_without_attach_type(BPF_PROG_TYPE_EXT, data) } /// Attaches the extension. diff --git a/aya/src/programs/fentry.rs b/aya/src/programs/fentry.rs index 8643c9c03..d11c0e2a6 100644 --- a/aya/src/programs/fentry.rs +++ b/aya/src/programs/fentry.rs @@ -6,8 +6,8 @@ use aya_obj::{ }; use crate::programs::{ - FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, load_program, - utils::attach_raw_tracepoint, + FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, + load_program_with_attach_type, utils::attach_raw_tracepoint, }; /// A program that can be attached to the entry point of (almost) any kernel @@ -60,9 +60,9 @@ impl FEntry { /// is entered. The `btf` argument must contain the BTF info for the /// running kernel. pub fn load(&mut self, fn_name: &str, btf: &Btf) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_TRACE_FENTRY); - self.data.attach_btf_id = Some(btf.id_by_type_name_kind(fn_name, BtfKind::Func)?); - load_program(BPF_PROG_TYPE_TRACING, &mut self.data) + let Self { data } = self; + data.attach_btf_id = Some(btf.id_by_type_name_kind(fn_name, BtfKind::Func)?); + load_program_with_attach_type(BPF_PROG_TYPE_TRACING, BPF_TRACE_FENTRY, data) } /// Attaches the program. diff --git a/aya/src/programs/fexit.rs b/aya/src/programs/fexit.rs index 1f90bfde8..9744da4d8 100644 --- a/aya/src/programs/fexit.rs +++ b/aya/src/programs/fexit.rs @@ -6,8 +6,8 @@ use aya_obj::{ }; use crate::programs::{ - FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, load_program, - utils::attach_raw_tracepoint, + FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, + load_program_with_attach_type, utils::attach_raw_tracepoint, }; /// A program that can be attached to the exit point of (almost) anny kernel @@ -60,9 +60,9 @@ impl FExit { /// is exited. The `btf` argument must contain the BTF info for the running /// kernel. pub fn load(&mut self, fn_name: &str, btf: &Btf) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_TRACE_FEXIT); - self.data.attach_btf_id = Some(btf.id_by_type_name_kind(fn_name, BtfKind::Func)?); - load_program(BPF_PROG_TYPE_TRACING, &mut self.data) + let Self { data } = self; + data.attach_btf_id = Some(btf.id_by_type_name_kind(fn_name, BtfKind::Func)?); + load_program_with_attach_type(BPF_PROG_TYPE_TRACING, BPF_TRACE_FEXIT, data) } /// Attaches the program. diff --git a/aya/src/programs/flow_dissector.rs b/aya/src/programs/flow_dissector.rs index 3a3bf9e6d..76d40fc55 100644 --- a/aya/src/programs/flow_dissector.rs +++ b/aya/src/programs/flow_dissector.rs @@ -9,7 +9,7 @@ use aya_obj::generated::{ use crate::{ programs::{ CgroupAttachMode, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, ProgramType, - define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program, + define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_link_create}, util::KernelVersion, @@ -70,8 +70,8 @@ impl FlowDissector { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_FLOW_DISSECTOR); - load_program(BPF_PROG_TYPE_FLOW_DISSECTOR, &mut self.data) + let Self { data } = self; + load_program_with_attach_type(BPF_PROG_TYPE_FLOW_DISSECTOR, BPF_FLOW_DISSECTOR, data) } /// Attaches the program to the given network namespace. @@ -81,19 +81,13 @@ impl FlowDissector { let prog_fd = self.fd()?; let prog_fd = prog_fd.as_fd(); let netns_fd = netns.as_fd(); - + let attach_type = BPF_FLOW_DISSECTOR; if KernelVersion::at_least(5, 7, 0) { - let link_fd = bpf_link_create( - prog_fd, - LinkTarget::Fd(netns_fd), - BPF_FLOW_DISSECTOR, - 0, - None, - ) - .map_err(|io_error| SyscallError { - call: "bpf_link_create", - io_error, - })?; + let link_fd = bpf_link_create(prog_fd, LinkTarget::Fd(netns_fd), attach_type, 0, None) + .map_err(|io_error| SyscallError { + call: "bpf_link_create", + io_error, + })?; self.data .links .insert(FlowDissectorLink::new(FlowDissectorLinkInner::Fd( @@ -103,7 +97,7 @@ impl FlowDissector { let link = ProgAttachLink::attach( prog_fd, netns_fd, - BPF_FLOW_DISSECTOR, + attach_type, CgroupAttachMode::default(), )?; diff --git a/aya/src/programs/iter.rs b/aya/src/programs/iter.rs index fb0d52795..069a9d97b 100644 --- a/aya/src/programs/iter.rs +++ b/aya/src/programs/iter.rs @@ -15,7 +15,7 @@ use aya_obj::{ use crate::{ programs::{ FdLink, LinkError, PerfLinkIdInner, PerfLinkInner, ProgramData, ProgramError, ProgramType, - define_link_wrapper, impl_try_into_fdlink, load_program, + define_link_wrapper, impl_try_into_fdlink, load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_create_iter, bpf_link_create, bpf_link_get_info_by_fd}, }; @@ -65,11 +65,10 @@ impl Iter { /// Loads the program inside the kernel. pub fn load(&mut self, iter_type: &str, btf: &Btf) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_TRACE_ITER); + let Self { data } = self; let type_name = format!("bpf_iter_{iter_type}"); - self.data.attach_btf_id = - Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Func)?); - load_program(BPF_PROG_TYPE_TRACING, &mut self.data) + data.attach_btf_id = Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Func)?); + load_program_with_attach_type(BPF_PROG_TYPE_TRACING, BPF_TRACE_ITER, data) } /// Attaches the program. diff --git a/aya/src/programs/kprobe.rs b/aya/src/programs/kprobe.rs index 3f4ea71da..68780e711 100644 --- a/aya/src/programs/kprobe.rs +++ b/aya/src/programs/kprobe.rs @@ -14,7 +14,7 @@ use crate::{ VerifierLogLevel, programs::{ FdLink, LinkError, ProgramData, ProgramError, ProgramType, define_link_wrapper, - impl_try_into_fdlink, load_program, + impl_try_into_fdlink, load_program_without_attach_type, perf_attach::{PerfLinkIdInner, PerfLinkInner}, probe::{Probe, ProbeKind, attach}, }, @@ -57,7 +57,8 @@ impl KProbe { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_KPROBE, &mut self.data) + let Self { data, kind: _ } = self; + load_program_without_attach_type(BPF_PROG_TYPE_KPROBE, data) } /// Returns [`ProbeKind::Entry`] if the program is a `kprobe`, or diff --git a/aya/src/programs/links.rs b/aya/src/programs/links.rs index e5bca358c..6cf2c73a5 100644 --- a/aya/src/programs/links.rs +++ b/aya/src/programs/links.rs @@ -394,7 +394,7 @@ impl ProgAttachLink { pub(crate) fn attach( prog_fd: BorrowedFd<'_>, target_fd: BorrowedFd<'_>, - attach_type: bpf_attach_type, + attach_type: impl Into, mode: CgroupAttachMode, ) -> Result { // The link is going to own this new file descriptor so we are @@ -405,6 +405,7 @@ impl ProgAttachLink { let prog_fd = crate::MockableFd::from_fd(prog_fd); let target_fd = target_fd.try_clone_to_owned()?; let target_fd = crate::MockableFd::from_fd(target_fd); + let attach_type = attach_type.into(); bpf_prog_attach(prog_fd.as_fd(), target_fd.as_fd(), attach_type, mode.into())?; let prog_fd = ProgramFd(prog_fd); diff --git a/aya/src/programs/lirc_mode2.rs b/aya/src/programs/lirc_mode2.rs index feb3b5351..d7ce43f12 100644 --- a/aya/src/programs/lirc_mode2.rs +++ b/aya/src/programs/lirc_mode2.rs @@ -8,7 +8,7 @@ use aya_obj::generated::{ use crate::{ programs::{ CgroupAttachMode, Link, ProgramData, ProgramError, ProgramFd, ProgramInfo, ProgramType, - id_as_key, load_program, query, + id_as_key, load_program_with_attach_type, query, }, sys::{ProgQueryTarget, bpf_prog_attach, bpf_prog_detach, bpf_prog_get_fd_by_id}, }; @@ -61,7 +61,8 @@ impl LircMode2 { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_LIRC_MODE2, &mut self.data) + let Self { data } = self; + load_program_with_attach_type(BPF_PROG_TYPE_LIRC_MODE2, BPF_LIRC_MODE2, data) } /// Attaches the program to the given lirc device. diff --git a/aya/src/programs/lsm.rs b/aya/src/programs/lsm.rs index bfee9308f..f60d47bb1 100644 --- a/aya/src/programs/lsm.rs +++ b/aya/src/programs/lsm.rs @@ -7,7 +7,7 @@ use aya_obj::{ use crate::programs::{ FdLink, FdLinkId, LsmAttachType, ProgramData, ProgramError, ProgramType, define_link_wrapper, - load_program, utils::attach_raw_tracepoint, + load_program_with_attach_type, utils::attach_raw_tracepoint, }; /// A program that attaches to Linux LSM hooks. Used to implement security policy and @@ -64,11 +64,10 @@ impl Lsm { /// * `lsm_hook_name` - full name of the LSM hook that the program should /// be attached to pub fn load(&mut self, lsm_hook_name: &str, btf: &Btf) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_LSM_MAC); + let Self { data } = self; let type_name = format!("bpf_lsm_{lsm_hook_name}"); - self.data.attach_btf_id = - Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Func)?); - load_program(BPF_PROG_TYPE_LSM, &mut self.data) + data.attach_btf_id = Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Func)?); + load_program_with_attach_type(BPF_PROG_TYPE_LSM, BPF_LSM_MAC, data) } /// Attaches the program. diff --git a/aya/src/programs/lsm_cgroup.rs b/aya/src/programs/lsm_cgroup.rs index f837732c6..8421a5083 100644 --- a/aya/src/programs/lsm_cgroup.rs +++ b/aya/src/programs/lsm_cgroup.rs @@ -9,7 +9,10 @@ use aya_obj::{ use crate::{ VerifierLogLevel, - programs::{FdLink, FdLinkId, ProgramData, ProgramError, define_link_wrapper, load_program}, + programs::{ + FdLink, FdLinkId, ProgramData, ProgramError, define_link_wrapper, + load_program_with_attach_type, + }, sys::{LinkTarget, SyscallError, bpf_link_create}, }; @@ -66,11 +69,10 @@ impl LsmCgroup { /// * `lsm_hook_name` - full name of the LSM hook that the program should /// be attached to pub fn load(&mut self, lsm_hook_name: &str, btf: &Btf) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_LSM_CGROUP); + let Self { data } = self; let type_name = format!("bpf_lsm_{lsm_hook_name}"); - self.data.attach_btf_id = - Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Func)?); - load_program(BPF_PROG_TYPE_LSM, &mut self.data) + data.attach_btf_id = Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Func)?); + load_program_with_attach_type(BPF_PROG_TYPE_LSM, BPF_LSM_CGROUP, data) } /// Creates a program from a pinned entry on a bpffs. @@ -80,8 +82,7 @@ impl LsmCgroup { /// On drop, any managed links are detached and the program is unloaded. This will not result in /// the program being unloaded from the kernel if it is still pinned. pub fn from_pin>(path: P) -> Result { - let mut data = ProgramData::from_pinned_path(path, VerifierLogLevel::default())?; - data.expected_attach_type = Some(BPF_LSM_CGROUP); + let data = ProgramData::from_pinned_path(path, VerifierLogLevel::default())?; Ok(Self { data }) } @@ -92,17 +93,10 @@ impl LsmCgroup { let prog_fd = self.fd()?; let prog_fd = prog_fd.as_fd(); let cgroup_fd = cgroup.as_fd(); - // Unwrap invariant: the function starts with `self.fd()?` that will succeed if and only - // if the program has been loaded, i.e. there is an fd. That happens if: - // - LsmCgroup::load has been called - // - LsmCgroup::from_pin has been called - // - // In all cases, expected_attach_type is guaranteed to be Some(_). - let attach_type = self.data.expected_attach_type.unwrap(); let link_fd = bpf_link_create( prog_fd, LinkTarget::Fd(cgroup_fd), - attach_type, + BPF_LSM_CGROUP, 0, // LSM cgroup links identify the hook through attach_btf_id at program load time. The // link_create union slot is reserved for cgroup anchor metadata instead, see diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs index 65185df20..3a894b515 100644 --- a/aya/src/programs/mod.rs +++ b/aya/src/programs/mod.rs @@ -523,7 +523,6 @@ pub(crate) struct ProgramData { pub(crate) obj: Option<(aya_obj::Program, aya_obj::Function)>, pub(crate) fd: Option, pub(crate) links: Links, - pub(crate) expected_attach_type: Option, pub(crate) attach_btf_obj_fd: Option, pub(crate) attach_btf_id: Option, pub(crate) attach_prog_fd: Option, @@ -545,7 +544,6 @@ impl ProgramData { obj: Some(obj), fd: None, links: Links::new(), - expected_attach_type: None, attach_btf_obj_fd: None, attach_btf_id: None, attach_prog_fd: None, @@ -573,7 +571,6 @@ impl ProgramData { obj: None, fd: Some(ProgramFd(fd)), links: Links::new(), - expected_attach_type: None, attach_btf_obj_fd, attach_btf_id, attach_prog_fd: None, @@ -640,8 +637,24 @@ fn pin_program>(data: &ProgramData, path: P) -> Resul Ok(()) } +fn load_program_without_attach_type( + prog_type: bpf_prog_type, + data: &mut ProgramData, +) -> Result<(), ProgramError> { + load_program(prog_type, None, data) +} + +fn load_program_with_attach_type, T: Link>( + prog_type: bpf_prog_type, + expected_attach_type: A, + data: &mut ProgramData, +) -> Result<(), ProgramError> { + load_program(prog_type, Some(expected_attach_type.into()), data) +} + fn load_program( prog_type: bpf_prog_type, + expected_attach_type: Option, data: &mut ProgramData, ) -> Result<(), ProgramError> { let ProgramData { @@ -649,7 +662,6 @@ fn load_program( obj, fd, links: _, - expected_attach_type, attach_btf_obj_fd, attach_btf_id, attach_prog_fd, @@ -702,7 +714,7 @@ fn load_program( insns: instructions, license, kernel_version: target_kernel_version, - expected_attach_type: *expected_attach_type, + expected_attach_type, prog_btf_fd: btf_fd.as_ref().map(|f| f.as_fd()), attach_btf_obj_fd: attach_btf_obj_fd.as_ref().map(|fd| fd.as_fd()), attach_btf_id: *attach_btf_id, diff --git a/aya/src/programs/perf_event.rs b/aya/src/programs/perf_event.rs index ef692c78b..d885d1845 100644 --- a/aya/src/programs/perf_event.rs +++ b/aya/src/programs/perf_event.rs @@ -13,7 +13,7 @@ use crate::{ programs::{ FdLink, LinkError, ProgramData, ProgramError, ProgramType, impl_try_into_fdlink, links::define_link_wrapper, - load_program, + load_program_without_attach_type, perf_attach::{PerfLinkIdInner, PerfLinkInner, perf_attach}, }, sys::{SyscallError, bpf_link_get_info_by_fd, perf_event_open}, @@ -437,7 +437,8 @@ impl PerfEvent { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_PERF_EVENT, &mut self.data) + let Self { data } = self; + load_program_without_attach_type(BPF_PROG_TYPE_PERF_EVENT, data) } /// Attaches to the given perf event. diff --git a/aya/src/programs/raw_trace_point.rs b/aya/src/programs/raw_trace_point.rs index 65d45b940..e004add15 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 aya_obj::generated::bpf_prog_type::BPF_PROG_TYPE_RAW_TRACEPOINT; use crate::programs::{ - FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, load_program, - utils::attach_raw_tracepoint, + FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, + load_program_without_attach_type, utils::attach_raw_tracepoint, }; /// A program that can be attached at a pre-defined kernel trace point. @@ -44,7 +44,8 @@ impl RawTracePoint { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_RAW_TRACEPOINT, &mut self.data) + let Self { data } = self; + load_program_without_attach_type(BPF_PROG_TYPE_RAW_TRACEPOINT, data) } /// Attaches the program to the given tracepoint. diff --git a/aya/src/programs/sk_lookup.rs b/aya/src/programs/sk_lookup.rs index 684880085..ff3fe74c7 100644 --- a/aya/src/programs/sk_lookup.rs +++ b/aya/src/programs/sk_lookup.rs @@ -6,7 +6,8 @@ use aya_obj::generated::{bpf_attach_type::BPF_SK_LOOKUP, bpf_prog_type::BPF_PROG use super::links::FdLink; use crate::{ programs::{ - FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, load_program, + FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, + load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_link_create}, }; @@ -59,8 +60,8 @@ impl SkLookup { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_SK_LOOKUP); - load_program(BPF_PROG_TYPE_SK_LOOKUP, &mut self.data) + let Self { data } = self; + load_program_with_attach_type(BPF_PROG_TYPE_SK_LOOKUP, BPF_SK_LOOKUP, data) } /// Attaches the program to the given network namespace. diff --git a/aya/src/programs/sk_msg.rs b/aya/src/programs/sk_msg.rs index a942599bd..b066e4e17 100644 --- a/aya/src/programs/sk_msg.rs +++ b/aya/src/programs/sk_msg.rs @@ -10,7 +10,7 @@ use crate::{ maps::sock::SockMapFd, programs::{ CgroupAttachMode, ProgAttachLink, ProgAttachLinkId, ProgramData, ProgramError, ProgramType, - define_link_wrapper, load_program, + define_link_wrapper, load_program_with_attach_type, }, }; @@ -77,7 +77,8 @@ impl SkMsg { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_SK_MSG, &mut self.data) + let Self { data } = self; + load_program_with_attach_type(BPF_PROG_TYPE_SK_MSG, BPF_SK_MSG_VERDICT, data) } /// Attaches the program to the given sockmap. diff --git a/aya/src/programs/sk_skb.rs b/aya/src/programs/sk_skb.rs index dbdb346f1..da3f865bc 100644 --- a/aya/src/programs/sk_skb.rs +++ b/aya/src/programs/sk_skb.rs @@ -2,29 +2,18 @@ use std::{os::fd::AsFd as _, path::Path}; -use aya_obj::generated::{ - bpf_attach_type::{BPF_SK_SKB_STREAM_PARSER, BPF_SK_SKB_STREAM_VERDICT}, - bpf_prog_type::BPF_PROG_TYPE_SK_SKB, -}; +use aya_obj::generated::bpf_prog_type::BPF_PROG_TYPE_SK_SKB; +pub use aya_obj::programs::SkSkbKind; use crate::{ VerifierLogLevel, maps::sock::SockMapFd, programs::{ CgroupAttachMode, ProgAttachLink, ProgAttachLinkId, ProgramData, ProgramError, ProgramType, - define_link_wrapper, load_program, + define_link_wrapper, load_program_without_attach_type, }, }; -/// The kind of [`SkSkb`] program. -#[derive(Copy, Clone, Debug)] -pub enum SkSkbKind { - /// A Stream Parser - StreamParser, - /// A Stream Verdict - StreamVerdict, -} - /// A program used to intercept ingress socket buffers. /// /// [`SkSkb`] programs are attached to [socket maps], and can be used to @@ -79,25 +68,20 @@ impl SkSkb { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_SK_SKB, &mut self.data) + let Self { data, kind: _ } = self; + load_program_without_attach_type(BPF_PROG_TYPE_SK_SKB, data) } /// Attaches the program to the given socket map. /// /// The returned value can be used to detach, see [`SkSkb::detach`]. pub fn attach(&mut self, map: &SockMapFd) -> Result { - let prog_fd = self.fd()?; + let Self { data, kind } = self; + let prog_fd = data.fd()?; let prog_fd = prog_fd.as_fd(); + let link = ProgAttachLink::attach(prog_fd, map.as_fd(), *kind, CgroupAttachMode::Single)?; - let attach_type = match self.kind { - SkSkbKind::StreamParser => BPF_SK_SKB_STREAM_PARSER, - SkSkbKind::StreamVerdict => BPF_SK_SKB_STREAM_VERDICT, - }; - - let link = - ProgAttachLink::attach(prog_fd, map.as_fd(), attach_type, CgroupAttachMode::Single)?; - - self.data.links.insert(SkSkbLink::new(link)) + data.links.insert(SkSkbLink::new(link)) } /// Creates a program from a pinned entry on a bpffs. diff --git a/aya/src/programs/sock_ops.rs b/aya/src/programs/sock_ops.rs index 2aa3cbb42..8a78a2fc8 100644 --- a/aya/src/programs/sock_ops.rs +++ b/aya/src/programs/sock_ops.rs @@ -8,7 +8,7 @@ use aya_obj::generated::{ use crate::{ programs::{ CgroupAttachMode, FdLink, Link, ProgAttachLink, ProgramData, ProgramError, ProgramType, - define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program, + define_link_wrapper, id_as_key, impl_try_into_fdlink, load_program_with_attach_type, }, sys::{LinkTarget, SyscallError, bpf_link_create}, util::KernelVersion, @@ -59,7 +59,8 @@ impl SockOps { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_SOCK_OPS, &mut self.data) + let Self { data } = self; + load_program_with_attach_type(BPF_PROG_TYPE_SOCK_OPS, BPF_CGROUP_SOCK_OPS, data) } /// Attaches the program to the given cgroup. diff --git a/aya/src/programs/socket_filter.rs b/aya/src/programs/socket_filter.rs index d258e169d..11c43f6b4 100644 --- a/aya/src/programs/socket_filter.rs +++ b/aya/src/programs/socket_filter.rs @@ -10,7 +10,9 @@ use aya_obj::generated::{ use libc::{SOL_SOCKET, setsockopt}; use thiserror::Error; -use crate::programs::{Link, ProgramData, ProgramError, ProgramType, id_as_key, load_program}; +use crate::programs::{ + Link, ProgramData, ProgramError, ProgramType, id_as_key, load_program_without_attach_type, +}; /// The type returned when attaching a [`SocketFilter`] fails. #[derive(Debug, Error)] @@ -69,7 +71,8 @@ impl SocketFilter { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_SOCKET_FILTER, &mut self.data) + let Self { data } = self; + load_program_without_attach_type(BPF_PROG_TYPE_SOCKET_FILTER, data) } /// Attaches the filter on the given socket. diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index b4240bc46..2187a287a 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -14,7 +14,7 @@ use crate::{ VerifierLogLevel, programs::{ Link, LinkError, LinkOrder, ProgramData, ProgramError, ProgramType, define_link_wrapper, - id_as_key, impl_try_into_fdlink, load_program, query, + id_as_key, impl_try_into_fdlink, load_program_without_attach_type, query, }, sys::{ BpfLinkCreateArgs, LinkTarget, NetlinkError, NetlinkSocket, ProgQueryTarget, SyscallError, @@ -156,7 +156,8 @@ impl SchedClassifier { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_SCHED_CLS, &mut self.data) + let Self { data } = self; + load_program_without_attach_type(BPF_PROG_TYPE_SCHED_CLS, data) } /// Attaches the program to the given `interface`. diff --git a/aya/src/programs/tp_btf.rs b/aya/src/programs/tp_btf.rs index 3da1529a9..f13fc3870 100644 --- a/aya/src/programs/tp_btf.rs +++ b/aya/src/programs/tp_btf.rs @@ -6,8 +6,8 @@ use aya_obj::{ }; use crate::programs::{ - FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, load_program, - utils::attach_raw_tracepoint, + FdLink, FdLinkId, ProgramData, ProgramError, ProgramType, define_link_wrapper, + load_program_with_attach_type, utils::attach_raw_tracepoint, }; /// Marks a function as a [BTF-enabled raw tracepoint][1] eBPF program that can be attached at @@ -62,11 +62,10 @@ impl BtfTracePoint { /// * `tracepoint` - full name of the tracepoint that we should attach to /// * `btf` - btf information for the target system pub fn load(&mut self, tracepoint: &str, btf: &Btf) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(BPF_TRACE_RAW_TP); + let Self { data } = self; let type_name = format!("btf_trace_{tracepoint}"); - self.data.attach_btf_id = - Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Typedef)?); - load_program(BPF_PROG_TYPE_TRACING, &mut self.data) + data.attach_btf_id = Some(btf.id_by_type_name_kind(type_name.as_str(), BtfKind::Typedef)?); + load_program_with_attach_type(BPF_PROG_TYPE_TRACING, BPF_TRACE_RAW_TP, data) } /// Attaches the program. diff --git a/aya/src/programs/trace_point.rs b/aya/src/programs/trace_point.rs index 46727e000..76e833656 100644 --- a/aya/src/programs/trace_point.rs +++ b/aya/src/programs/trace_point.rs @@ -11,7 +11,7 @@ use thiserror::Error; use crate::{ programs::{ FdLink, LinkError, ProgramData, ProgramError, ProgramType, define_link_wrapper, - impl_try_into_fdlink, load_program, + impl_try_into_fdlink, load_program_without_attach_type, perf_attach::{PerfLinkIdInner, PerfLinkInner, perf_attach}, utils::find_tracefs_path, }, @@ -65,7 +65,8 @@ impl TracePoint { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_TRACEPOINT, &mut self.data) + let Self { data } = self; + load_program_without_attach_type(BPF_PROG_TYPE_TRACEPOINT, data) } /// Attaches to a given trace point. diff --git a/aya/src/programs/uprobe.rs b/aya/src/programs/uprobe.rs index 78a5d57a6..05571a0fa 100644 --- a/aya/src/programs/uprobe.rs +++ b/aya/src/programs/uprobe.rs @@ -22,7 +22,7 @@ use crate::{ VerifierLogLevel, programs::{ FdLink, LinkError, ProgramData, ProgramError, ProgramType, define_link_wrapper, - impl_try_into_fdlink, load_program, + impl_try_into_fdlink, load_program_without_attach_type, perf_attach::{PerfLinkIdInner, PerfLinkInner}, probe::{OsStringExt as _, Probe, ProbeKind, attach}, }, @@ -98,7 +98,8 @@ impl UProbe { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - load_program(BPF_PROG_TYPE_KPROBE, &mut self.data) + let Self { data, kind: _ } = self; + load_program_without_attach_type(BPF_PROG_TYPE_KPROBE, data) } /// Returns [`ProbeKind::Entry`] if the program is a `uprobe`, or diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs index bab10f412..d719c2c49 100644 --- a/aya/src/programs/xdp.rs +++ b/aya/src/programs/xdp.rs @@ -10,7 +10,7 @@ use std::{ use aya_obj::{ generated::{ XDP_FLAGS_DRV_MODE, XDP_FLAGS_HW_MODE, XDP_FLAGS_REPLACE, XDP_FLAGS_SKB_MODE, - XDP_FLAGS_UPDATE_IF_NOEXIST, bpf_link_type, bpf_prog_type, + XDP_FLAGS_UPDATE_IF_NOEXIST, bpf_link_type, bpf_prog_type::BPF_PROG_TYPE_XDP, }, programs::XdpAttachType, }; @@ -20,7 +20,7 @@ use crate::{ VerifierLogLevel, programs::{ FdLink, Link, LinkError, ProgramData, ProgramError, ProgramType, define_link_wrapper, - id_as_key, impl_try_into_fdlink, load_program, + id_as_key, impl_try_into_fdlink, load_program_with_attach_type, }, sys::{ LinkTarget, NetlinkError, SyscallError, bpf_link_create, bpf_link_get_info_by_fd, @@ -88,8 +88,8 @@ impl Xdp { /// Loads the program inside the kernel. pub fn load(&mut self) -> Result<(), ProgramError> { - self.data.expected_attach_type = Some(self.attach_type.into()); - load_program(bpf_prog_type::BPF_PROG_TYPE_XDP, &mut self.data) + let Self { data, attach_type } = self; + load_program_with_attach_type(BPF_PROG_TYPE_XDP, *attach_type, data) } /// Attaches the program to the given `interface`. @@ -128,21 +128,13 @@ impl Xdp { if_index: u32, flags: XdpFlags, ) -> Result { - let prog_fd = self.fd()?; + let Self { data, attach_type } = self; + let prog_fd = data.fd()?; let prog_fd = prog_fd.as_fd(); - - // Unwrap invariant: the function starts with `self.fd()?` that will succeed if and only - // if the program has been loaded, i.e. there is an fd. We get one by: - // - Using `Xdp::from_pin` that sets `expected_attach_type` - // - Calling `Xdp::attach` that sets `expected_attach_type`, as geting an `Xdp` - // instance through `Xdp:try_from(Program)` does not set any fd. - // So, in all cases where we have an fd, we have an expected_attach_type. Thus, if we - // reach this point, expected_attach_type is guaranteed to be Some(_). - let attach_type = self.data.expected_attach_type.unwrap(); let link = match bpf_link_create( prog_fd, LinkTarget::IfIndex(if_index), - attach_type, + *attach_type, flags.bits(), None, ) { @@ -169,7 +161,7 @@ impl Xdp { }) } }; - self.data.links.insert(XdpLink::new(link)) + data.links.insert(XdpLink::new(link)) } /// Creates a program from a pinned entry on a bpffs. @@ -182,8 +174,7 @@ impl Xdp { path: P, attach_type: XdpAttachType, ) -> Result { - let mut data = ProgramData::from_pinned_path(path, VerifierLogLevel::default())?; - data.expected_attach_type = Some(attach_type.into()); + let data = ProgramData::from_pinned_path(path, VerifierLogLevel::default())?; Ok(Self { data, attach_type }) } diff --git a/aya/src/sys/bpf.rs b/aya/src/sys/bpf.rs index c9153ca4c..5714f01cb 100644 --- a/aya/src/sys/bpf.rs +++ b/aya/src/sys/bpf.rs @@ -397,7 +397,7 @@ pub(crate) enum BpfLinkCreateArgs<'a> { pub(crate) fn bpf_link_create( prog_fd: BorrowedFd<'_>, target: LinkTarget<'_>, - attach_type: bpf_attach_type, + attach_type: impl Into, flags: u32, args: Option>, ) -> io::Result { @@ -418,7 +418,7 @@ pub(crate) fn bpf_link_create( // https://github.com/torvalds/linux/blob/v6.12/kernel/bpf/bpf_iter.c#L517-L518 LinkTarget::Iter => {} } - attr.link_create.attach_type = attach_type as u32; + attr.link_create.attach_type = attach_type.into() as u32; attr.link_create.flags = flags; if let Some(args) = args { @@ -479,14 +479,14 @@ pub(crate) fn bpf_link_update( pub(crate) fn bpf_prog_attach( prog_fd: BorrowedFd<'_>, target_fd: BorrowedFd<'_>, - attach_type: bpf_attach_type, + attach_type: impl Into, flags: u32, ) -> Result<(), SyscallError> { let mut attr = unsafe { mem::zeroed::() }; attr.__bindgen_anon_5.attach_bpf_fd = prog_fd.as_raw_fd() as u32; attr.__bindgen_anon_5.__bindgen_anon_1.target_fd = target_fd.as_raw_fd() as u32; - attr.__bindgen_anon_5.attach_type = attach_type as u32; + attr.__bindgen_anon_5.attach_type = attach_type.into() as u32; attr.__bindgen_anon_5.attach_flags = flags; unit_sys_bpf(bpf_cmd::BPF_PROG_ATTACH, &mut attr).map_err(|io_error| SyscallError { diff --git a/aya/src/util.rs b/aya/src/util.rs index c7a80053f..a98d0f2ad 100644 --- a/aya/src/util.rs +++ b/aya/src/util.rs @@ -392,21 +392,19 @@ pub(crate) const fn tc_handler_make(major: u32, minor: u32) -> u32 { #[macro_export] macro_rules! include_bytes_aligned { ($path:expr) => {{ - #[repr(align(32))] - pub struct Aligned32; + // All eBPF programs are ELF64 objects (regardless of host target) with + // 8-byte aligned headers and all eBPF instructions are 8 bytes each. + #[repr(C, align(8))] + struct Aligned(T); - #[repr(C)] - pub struct Aligned { - pub _align: [Aligned32; 0], - pub bytes: Bytes, - } + // Must be a reference because `Aligned<[u8]>` is not `Sized` and we + // can't write `Aligned<[u8; N]>` since `N` is not nameable in the type + // in this context (even though the compiler knows it at compile time). + const ALIGNED: &Aligned<[u8]> = &Aligned(*include_bytes!($path)); - const ALIGNED: &Aligned<[u8]> = &Aligned { - _align: [], - bytes: *include_bytes!($path), - }; + let &Aligned(ref aligned) = ALIGNED; - &ALIGNED.bytes + aligned }}; } diff --git a/xtask/public-api/aya-obj.txt b/xtask/public-api/aya-obj.txt index 207acf59f..5bf038661 100644 --- a/xtask/public-api/aya-obj.txt +++ b/xtask/public-api/aya-obj.txt @@ -2319,12 +2319,16 @@ pub fn aya_obj::generated::bpf_attach_type::clone(&self) -> aya_obj::generated:: impl core::cmp::Eq for aya_obj::generated::bpf_attach_type impl core::cmp::PartialEq for aya_obj::generated::bpf_attach_type pub fn aya_obj::generated::bpf_attach_type::eq(&self, other: &aya_obj::generated::bpf_attach_type) -> bool +impl core::convert::From for aya_obj::generated::bpf_attach_type +pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::cgroup_skb::CgroupSkbAttachType) -> Self impl core::convert::From for aya_obj::generated::bpf_attach_type pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::cgroup_sock::CgroupSockAttachType) -> Self impl core::convert::From for aya_obj::generated::bpf_attach_type pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::cgroup_sock_addr::CgroupSockAddrAttachType) -> Self impl core::convert::From for aya_obj::generated::bpf_attach_type pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::cgroup_sockopt::CgroupSockoptAttachType) -> Self +impl core::convert::From for aya_obj::generated::bpf_attach_type +pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::sk_skb::SkSkbKind) -> Self impl core::convert::From for aya_obj::generated::bpf_attach_type pub fn aya_obj::generated::bpf_attach_type::from(value: aya_obj::programs::xdp::XdpAttachType) -> Self impl core::convert::TryFrom for aya_obj::generated::bpf_attach_type @@ -8800,8 +8804,7 @@ pub enum aya_obj::obj::ProgramSection pub aya_obj::obj::ProgramSection::BtfTracePoint pub aya_obj::obj::ProgramSection::CgroupDevice pub aya_obj::obj::ProgramSection::CgroupSkb -pub aya_obj::obj::ProgramSection::CgroupSkbEgress -pub aya_obj::obj::ProgramSection::CgroupSkbIngress +pub aya_obj::obj::ProgramSection::CgroupSkb::attach_type: core::option::Option pub aya_obj::obj::ProgramSection::CgroupSock pub aya_obj::obj::ProgramSection::CgroupSock::attach_type: aya_obj::programs::cgroup_sock::CgroupSockAttachType pub aya_obj::obj::ProgramSection::CgroupSockAddr @@ -8828,8 +8831,8 @@ pub aya_obj::obj::ProgramSection::RawTracePoint pub aya_obj::obj::ProgramSection::SchedClassifier pub aya_obj::obj::ProgramSection::SkLookup pub aya_obj::obj::ProgramSection::SkMsg -pub aya_obj::obj::ProgramSection::SkSkbStreamParser -pub aya_obj::obj::ProgramSection::SkSkbStreamVerdict +pub aya_obj::obj::ProgramSection::SkSkbStream +pub aya_obj::obj::ProgramSection::SkSkbStream::kind: aya_obj::programs::sk_skb::SkSkbKind pub aya_obj::obj::ProgramSection::SockOps pub aya_obj::obj::ProgramSection::SocketFilter pub aya_obj::obj::ProgramSection::TracePoint @@ -9079,6 +9082,46 @@ pub fn aya_obj::Program::from(t: T) -> T pub fn aya_obj::obj::copy_instructions(data: &[u8]) -> core::result::Result, aya_obj::ParseError> pub const fn aya_obj::obj::parse_map_info(info: aya_obj::generated::bpf_map_info, pinned: aya_obj::maps::PinningType) -> aya_obj::maps::Map pub mod aya_obj::programs +pub mod aya_obj::programs::cgroup_skb +pub enum aya_obj::programs::cgroup_skb::CgroupSkbAttachType +pub aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Egress +pub aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Ingress +impl core::clone::Clone for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::clone(&self) -> aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::convert::From for aya_obj::generated::bpf_attach_type +pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::cgroup_skb::CgroupSkbAttachType) -> Self +impl core::fmt::Debug for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl core::marker::Copy for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Freeze for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Send for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Sync for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Unpin for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::UnsafeUnpin for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::panic::unwind_safe::RefUnwindSafe for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::panic::unwind_safe::UnwindSafe for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::convert::Into for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::From +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::into(self) -> U +impl core::convert::TryFrom for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::Into +pub type aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Error = core::convert::Infallible +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::try_from(value: U) -> core::result::Result>::Error> +impl core::convert::TryInto for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::TryFrom +pub type aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Error = >::Error +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::try_into(self) -> core::result::Result>::Error> +impl alloc::borrow::ToOwned for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone +pub type aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Owned = T +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::clone_into(&self, target: &mut T) +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::to_owned(&self) -> T +impl core::any::Any for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: 'static + ?core::marker::Sized +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::type_id(&self) -> core::any::TypeId +impl core::borrow::Borrow for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::borrow(&self) -> &T +impl core::borrow::BorrowMut for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::borrow_mut(&mut self) -> &mut T +impl core::clone::CloneToUninit for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone +pub unsafe fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::clone_to_uninit(&self, dest: *mut u8) +impl core::convert::From for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::from(t: T) -> T pub mod aya_obj::programs::cgroup_sock pub enum aya_obj::programs::cgroup_sock::CgroupSockAttachType pub aya_obj::programs::cgroup_sock::CgroupSockAttachType::PostBind4 @@ -9213,6 +9256,46 @@ impl core::clone::CloneToUninit for aya_obj::programs::cgroup_sockopt::Cgroup pub unsafe fn aya_obj::programs::cgroup_sockopt::CgroupSockoptAttachType::clone_to_uninit(&self, dest: *mut u8) impl core::convert::From for aya_obj::programs::cgroup_sockopt::CgroupSockoptAttachType pub fn aya_obj::programs::cgroup_sockopt::CgroupSockoptAttachType::from(t: T) -> T +pub mod aya_obj::programs::sk_skb +pub enum aya_obj::programs::sk_skb::SkSkbKind +pub aya_obj::programs::sk_skb::SkSkbKind::StreamParser +pub aya_obj::programs::sk_skb::SkSkbKind::StreamVerdict +impl core::clone::Clone for aya_obj::programs::sk_skb::SkSkbKind +pub fn aya_obj::programs::sk_skb::SkSkbKind::clone(&self) -> aya_obj::programs::sk_skb::SkSkbKind +impl core::convert::From for aya_obj::generated::bpf_attach_type +pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::sk_skb::SkSkbKind) -> Self +impl core::fmt::Debug for aya_obj::programs::sk_skb::SkSkbKind +pub fn aya_obj::programs::sk_skb::SkSkbKind::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl core::marker::Copy for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Freeze for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Send for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Sync for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Unpin for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::UnsafeUnpin for aya_obj::programs::sk_skb::SkSkbKind +impl core::panic::unwind_safe::RefUnwindSafe for aya_obj::programs::sk_skb::SkSkbKind +impl core::panic::unwind_safe::UnwindSafe for aya_obj::programs::sk_skb::SkSkbKind +impl core::convert::Into for aya_obj::programs::sk_skb::SkSkbKind where U: core::convert::From +pub fn aya_obj::programs::sk_skb::SkSkbKind::into(self) -> U +impl core::convert::TryFrom for aya_obj::programs::sk_skb::SkSkbKind where U: core::convert::Into +pub type aya_obj::programs::sk_skb::SkSkbKind::Error = core::convert::Infallible +pub fn aya_obj::programs::sk_skb::SkSkbKind::try_from(value: U) -> core::result::Result>::Error> +impl core::convert::TryInto for aya_obj::programs::sk_skb::SkSkbKind where U: core::convert::TryFrom +pub type aya_obj::programs::sk_skb::SkSkbKind::Error = >::Error +pub fn aya_obj::programs::sk_skb::SkSkbKind::try_into(self) -> core::result::Result>::Error> +impl alloc::borrow::ToOwned for aya_obj::programs::sk_skb::SkSkbKind where T: core::clone::Clone +pub type aya_obj::programs::sk_skb::SkSkbKind::Owned = T +pub fn aya_obj::programs::sk_skb::SkSkbKind::clone_into(&self, target: &mut T) +pub fn aya_obj::programs::sk_skb::SkSkbKind::to_owned(&self) -> T +impl core::any::Any for aya_obj::programs::sk_skb::SkSkbKind where T: 'static + ?core::marker::Sized +pub fn aya_obj::programs::sk_skb::SkSkbKind::type_id(&self) -> core::any::TypeId +impl core::borrow::Borrow for aya_obj::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized +pub fn aya_obj::programs::sk_skb::SkSkbKind::borrow(&self) -> &T +impl core::borrow::BorrowMut for aya_obj::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized +pub fn aya_obj::programs::sk_skb::SkSkbKind::borrow_mut(&mut self) -> &mut T +impl core::clone::CloneToUninit for aya_obj::programs::sk_skb::SkSkbKind where T: core::clone::Clone +pub unsafe fn aya_obj::programs::sk_skb::SkSkbKind::clone_to_uninit(&self, dest: *mut u8) +impl core::convert::From for aya_obj::programs::sk_skb::SkSkbKind +pub fn aya_obj::programs::sk_skb::SkSkbKind::from(t: T) -> T pub mod aya_obj::programs::xdp pub enum aya_obj::programs::xdp::XdpAttachType pub aya_obj::programs::xdp::XdpAttachType::CpuMap @@ -9254,6 +9337,45 @@ impl core::clone::CloneToUninit for aya_obj::programs::xdp::XdpAttachType whe pub unsafe fn aya_obj::programs::xdp::XdpAttachType::clone_to_uninit(&self, dest: *mut u8) impl core::convert::From for aya_obj::programs::xdp::XdpAttachType pub fn aya_obj::programs::xdp::XdpAttachType::from(t: T) -> T +pub enum aya_obj::programs::CgroupSkbAttachType +pub aya_obj::programs::CgroupSkbAttachType::Egress +pub aya_obj::programs::CgroupSkbAttachType::Ingress +impl core::clone::Clone for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::clone(&self) -> aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::convert::From for aya_obj::generated::bpf_attach_type +pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::cgroup_skb::CgroupSkbAttachType) -> Self +impl core::fmt::Debug for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl core::marker::Copy for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Freeze for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Send for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Sync for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::Unpin for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::marker::UnsafeUnpin for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::panic::unwind_safe::RefUnwindSafe for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::panic::unwind_safe::UnwindSafe for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +impl core::convert::Into for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::From +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::into(self) -> U +impl core::convert::TryFrom for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::Into +pub type aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Error = core::convert::Infallible +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::try_from(value: U) -> core::result::Result>::Error> +impl core::convert::TryInto for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::TryFrom +pub type aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Error = >::Error +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::try_into(self) -> core::result::Result>::Error> +impl alloc::borrow::ToOwned for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone +pub type aya_obj::programs::cgroup_skb::CgroupSkbAttachType::Owned = T +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::clone_into(&self, target: &mut T) +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::to_owned(&self) -> T +impl core::any::Any for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: 'static + ?core::marker::Sized +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::type_id(&self) -> core::any::TypeId +impl core::borrow::Borrow for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::borrow(&self) -> &T +impl core::borrow::BorrowMut for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::borrow_mut(&mut self) -> &mut T +impl core::clone::CloneToUninit for aya_obj::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone +pub unsafe fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::clone_to_uninit(&self, dest: *mut u8) +impl core::convert::From for aya_obj::programs::cgroup_skb::CgroupSkbAttachType +pub fn aya_obj::programs::cgroup_skb::CgroupSkbAttachType::from(t: T) -> T pub enum aya_obj::programs::CgroupSockAddrAttachType pub aya_obj::programs::CgroupSockAddrAttachType::Bind4 pub aya_obj::programs::CgroupSockAddrAttachType::Bind6 @@ -9385,6 +9507,45 @@ impl core::clone::CloneToUninit for aya_obj::programs::cgroup_sockopt::Cgroup pub unsafe fn aya_obj::programs::cgroup_sockopt::CgroupSockoptAttachType::clone_to_uninit(&self, dest: *mut u8) impl core::convert::From for aya_obj::programs::cgroup_sockopt::CgroupSockoptAttachType pub fn aya_obj::programs::cgroup_sockopt::CgroupSockoptAttachType::from(t: T) -> T +pub enum aya_obj::programs::SkSkbKind +pub aya_obj::programs::SkSkbKind::StreamParser +pub aya_obj::programs::SkSkbKind::StreamVerdict +impl core::clone::Clone for aya_obj::programs::sk_skb::SkSkbKind +pub fn aya_obj::programs::sk_skb::SkSkbKind::clone(&self) -> aya_obj::programs::sk_skb::SkSkbKind +impl core::convert::From for aya_obj::generated::bpf_attach_type +pub fn aya_obj::generated::bpf_attach_type::from(s: aya_obj::programs::sk_skb::SkSkbKind) -> Self +impl core::fmt::Debug for aya_obj::programs::sk_skb::SkSkbKind +pub fn aya_obj::programs::sk_skb::SkSkbKind::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result +impl core::marker::Copy for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Freeze for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Send for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Sync for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::Unpin for aya_obj::programs::sk_skb::SkSkbKind +impl core::marker::UnsafeUnpin for aya_obj::programs::sk_skb::SkSkbKind +impl core::panic::unwind_safe::RefUnwindSafe for aya_obj::programs::sk_skb::SkSkbKind +impl core::panic::unwind_safe::UnwindSafe for aya_obj::programs::sk_skb::SkSkbKind +impl core::convert::Into for aya_obj::programs::sk_skb::SkSkbKind where U: core::convert::From +pub fn aya_obj::programs::sk_skb::SkSkbKind::into(self) -> U +impl core::convert::TryFrom for aya_obj::programs::sk_skb::SkSkbKind where U: core::convert::Into +pub type aya_obj::programs::sk_skb::SkSkbKind::Error = core::convert::Infallible +pub fn aya_obj::programs::sk_skb::SkSkbKind::try_from(value: U) -> core::result::Result>::Error> +impl core::convert::TryInto for aya_obj::programs::sk_skb::SkSkbKind where U: core::convert::TryFrom +pub type aya_obj::programs::sk_skb::SkSkbKind::Error = >::Error +pub fn aya_obj::programs::sk_skb::SkSkbKind::try_into(self) -> core::result::Result>::Error> +impl alloc::borrow::ToOwned for aya_obj::programs::sk_skb::SkSkbKind where T: core::clone::Clone +pub type aya_obj::programs::sk_skb::SkSkbKind::Owned = T +pub fn aya_obj::programs::sk_skb::SkSkbKind::clone_into(&self, target: &mut T) +pub fn aya_obj::programs::sk_skb::SkSkbKind::to_owned(&self) -> T +impl core::any::Any for aya_obj::programs::sk_skb::SkSkbKind where T: 'static + ?core::marker::Sized +pub fn aya_obj::programs::sk_skb::SkSkbKind::type_id(&self) -> core::any::TypeId +impl core::borrow::Borrow for aya_obj::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized +pub fn aya_obj::programs::sk_skb::SkSkbKind::borrow(&self) -> &T +impl core::borrow::BorrowMut for aya_obj::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized +pub fn aya_obj::programs::sk_skb::SkSkbKind::borrow_mut(&mut self) -> &mut T +impl core::clone::CloneToUninit for aya_obj::programs::sk_skb::SkSkbKind where T: core::clone::Clone +pub unsafe fn aya_obj::programs::sk_skb::SkSkbKind::clone_to_uninit(&self, dest: *mut u8) +impl core::convert::From for aya_obj::programs::sk_skb::SkSkbKind +pub fn aya_obj::programs::sk_skb::SkSkbKind::from(t: T) -> T pub enum aya_obj::programs::XdpAttachType pub aya_obj::programs::XdpAttachType::CpuMap pub aya_obj::programs::XdpAttachType::DevMap @@ -9682,8 +9843,7 @@ pub enum aya_obj::ProgramSection pub aya_obj::ProgramSection::BtfTracePoint pub aya_obj::ProgramSection::CgroupDevice pub aya_obj::ProgramSection::CgroupSkb -pub aya_obj::ProgramSection::CgroupSkbEgress -pub aya_obj::ProgramSection::CgroupSkbIngress +pub aya_obj::ProgramSection::CgroupSkb::attach_type: core::option::Option pub aya_obj::ProgramSection::CgroupSock pub aya_obj::ProgramSection::CgroupSock::attach_type: aya_obj::programs::cgroup_sock::CgroupSockAttachType pub aya_obj::ProgramSection::CgroupSockAddr @@ -9710,8 +9870,8 @@ pub aya_obj::ProgramSection::RawTracePoint pub aya_obj::ProgramSection::SchedClassifier pub aya_obj::ProgramSection::SkLookup pub aya_obj::ProgramSection::SkMsg -pub aya_obj::ProgramSection::SkSkbStreamParser -pub aya_obj::ProgramSection::SkSkbStreamVerdict +pub aya_obj::ProgramSection::SkSkbStream +pub aya_obj::ProgramSection::SkSkbStream::kind: aya_obj::programs::sk_skb::SkSkbKind pub aya_obj::ProgramSection::SockOps pub aya_obj::ProgramSection::SocketFilter pub aya_obj::ProgramSection::TracePoint diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt index fd6a16eeb..0bebf3720 100644 --- a/xtask/public-api/aya.txt +++ b/xtask/public-api/aya.txt @@ -2613,9 +2613,11 @@ pub fn aya::pin::PinError::borrow_mut(&mut self) -> &mut T impl core::convert::From for aya::pin::PinError pub fn aya::pin::PinError::from(t: T) -> T pub mod aya::programs +pub use aya::programs::CgroupSkbAttachType pub use aya::programs::CgroupSockAddrAttachType pub use aya::programs::CgroupSockAttachType pub use aya::programs::CgroupSockoptAttachType +pub use aya::programs::SkSkbKind pub mod aya::programs::cgroup_device pub struct aya::programs::cgroup_device::CgroupDevice impl aya::programs::cgroup_device::CgroupDevice @@ -2750,49 +2752,13 @@ pub fn aya::programs::cgroup_device::CgroupDeviceLinkId::borrow_mut(&mut self) - impl core::convert::From for aya::programs::cgroup_device::CgroupDeviceLinkId pub fn aya::programs::cgroup_device::CgroupDeviceLinkId::from(t: T) -> T pub mod aya::programs::cgroup_skb -pub enum aya::programs::cgroup_skb::CgroupSkbAttachType -pub aya::programs::cgroup_skb::CgroupSkbAttachType::Egress -pub aya::programs::cgroup_skb::CgroupSkbAttachType::Ingress -impl core::clone::Clone for aya::programs::cgroup_skb::CgroupSkbAttachType -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::clone(&self) -> aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::fmt::Debug for aya::programs::cgroup_skb::CgroupSkbAttachType -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result -impl core::marker::Copy for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Freeze for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Send for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Sync for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Unpin for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::UnsafeUnpin for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::panic::unwind_safe::UnwindSafe for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::convert::Into for aya::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::From -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::into(self) -> U -impl core::convert::TryFrom for aya::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::Into -pub type aya::programs::cgroup_skb::CgroupSkbAttachType::Error = core::convert::Infallible -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::try_from(value: U) -> core::result::Result>::Error> -impl core::convert::TryInto for aya::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::TryFrom -pub type aya::programs::cgroup_skb::CgroupSkbAttachType::Error = >::Error -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::try_into(self) -> core::result::Result>::Error> -impl alloc::borrow::ToOwned for aya::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone -pub type aya::programs::cgroup_skb::CgroupSkbAttachType::Owned = T -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::clone_into(&self, target: &mut T) -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::to_owned(&self) -> T -impl core::any::Any for aya::programs::cgroup_skb::CgroupSkbAttachType where T: 'static + ?core::marker::Sized -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::type_id(&self) -> core::any::TypeId -impl core::borrow::Borrow for aya::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::borrow(&self) -> &T -impl core::borrow::BorrowMut for aya::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::borrow_mut(&mut self) -> &mut T -impl core::clone::CloneToUninit for aya::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone -pub unsafe fn aya::programs::cgroup_skb::CgroupSkbAttachType::clone_to_uninit(&self, dest: *mut u8) -impl core::convert::From for aya::programs::cgroup_skb::CgroupSkbAttachType -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::from(t: T) -> T +pub use aya::programs::cgroup_skb::CgroupSkbAttachType pub struct aya::programs::cgroup_skb::CgroupSkb impl aya::programs::cgroup_skb::CgroupSkb pub const aya::programs::cgroup_skb::CgroupSkb::PROGRAM_TYPE: aya::programs::ProgramType -pub fn aya::programs::cgroup_skb::CgroupSkb::attach(&mut self, cgroup: T, attach_type: aya::programs::cgroup_skb::CgroupSkbAttachType, mode: aya::programs::links::CgroupAttachMode) -> core::result::Result -pub const fn aya::programs::cgroup_skb::CgroupSkb::expected_attach_type(&self) -> &core::option::Option -pub fn aya::programs::cgroup_skb::CgroupSkb::from_pin>(path: P, expected_attach_type: aya::programs::cgroup_skb::CgroupSkbAttachType) -> core::result::Result +pub fn aya::programs::cgroup_skb::CgroupSkb::attach(&mut self, cgroup: T, attach_type: aya_obj::programs::cgroup_skb::CgroupSkbAttachType, mode: aya::programs::links::CgroupAttachMode) -> core::result::Result +pub const fn aya::programs::cgroup_skb::CgroupSkb::expected_attach_type(&self) -> &core::option::Option +pub fn aya::programs::cgroup_skb::CgroupSkb::from_pin>(path: P, expected_attach_type: aya_obj::programs::cgroup_skb::CgroupSkbAttachType) -> core::result::Result pub fn aya::programs::cgroup_skb::CgroupSkb::load(&mut self) -> core::result::Result<(), aya::programs::ProgramError> impl aya::programs::cgroup_skb::CgroupSkb pub fn aya::programs::cgroup_skb::CgroupSkb::detach(&mut self, link_id: aya::programs::cgroup_skb::CgroupSkbLinkId) -> core::result::Result<(), aya::programs::ProgramError> @@ -2800,7 +2766,7 @@ pub fn aya::programs::cgroup_skb::CgroupSkb::take_link(&mut self, link_id: aya:: impl aya::programs::cgroup_skb::CgroupSkb pub fn aya::programs::cgroup_skb::CgroupSkb::fd(&self) -> core::result::Result<&aya::programs::ProgramFd, aya::programs::ProgramError> impl aya::programs::cgroup_skb::CgroupSkb -pub fn aya::programs::cgroup_skb::CgroupSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, attach_type: core::option::Option) -> core::result::Result +pub fn aya::programs::cgroup_skb::CgroupSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, attach_type: core::option::Option) -> core::result::Result impl aya::programs::cgroup_skb::CgroupSkb pub fn aya::programs::cgroup_skb::CgroupSkb::info(&self) -> core::result::Result impl aya::programs::cgroup_skb::CgroupSkb @@ -6413,48 +6379,12 @@ pub fn aya::programs::sk_msg::SkMsgLinkId::borrow_mut(&mut self) -> &mut T impl core::convert::From for aya::programs::sk_msg::SkMsgLinkId pub fn aya::programs::sk_msg::SkMsgLinkId::from(t: T) -> T pub mod aya::programs::sk_skb -pub enum aya::programs::sk_skb::SkSkbKind -pub aya::programs::sk_skb::SkSkbKind::StreamParser -pub aya::programs::sk_skb::SkSkbKind::StreamVerdict -impl core::clone::Clone for aya::programs::sk_skb::SkSkbKind -pub fn aya::programs::sk_skb::SkSkbKind::clone(&self) -> aya::programs::sk_skb::SkSkbKind -impl core::fmt::Debug for aya::programs::sk_skb::SkSkbKind -pub fn aya::programs::sk_skb::SkSkbKind::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result -impl core::marker::Copy for aya::programs::sk_skb::SkSkbKind -impl core::marker::Freeze for aya::programs::sk_skb::SkSkbKind -impl core::marker::Send for aya::programs::sk_skb::SkSkbKind -impl core::marker::Sync for aya::programs::sk_skb::SkSkbKind -impl core::marker::Unpin for aya::programs::sk_skb::SkSkbKind -impl core::marker::UnsafeUnpin for aya::programs::sk_skb::SkSkbKind -impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::sk_skb::SkSkbKind -impl core::panic::unwind_safe::UnwindSafe for aya::programs::sk_skb::SkSkbKind -impl core::convert::Into for aya::programs::sk_skb::SkSkbKind where U: core::convert::From -pub fn aya::programs::sk_skb::SkSkbKind::into(self) -> U -impl core::convert::TryFrom for aya::programs::sk_skb::SkSkbKind where U: core::convert::Into -pub type aya::programs::sk_skb::SkSkbKind::Error = core::convert::Infallible -pub fn aya::programs::sk_skb::SkSkbKind::try_from(value: U) -> core::result::Result>::Error> -impl core::convert::TryInto for aya::programs::sk_skb::SkSkbKind where U: core::convert::TryFrom -pub type aya::programs::sk_skb::SkSkbKind::Error = >::Error -pub fn aya::programs::sk_skb::SkSkbKind::try_into(self) -> core::result::Result>::Error> -impl alloc::borrow::ToOwned for aya::programs::sk_skb::SkSkbKind where T: core::clone::Clone -pub type aya::programs::sk_skb::SkSkbKind::Owned = T -pub fn aya::programs::sk_skb::SkSkbKind::clone_into(&self, target: &mut T) -pub fn aya::programs::sk_skb::SkSkbKind::to_owned(&self) -> T -impl core::any::Any for aya::programs::sk_skb::SkSkbKind where T: 'static + ?core::marker::Sized -pub fn aya::programs::sk_skb::SkSkbKind::type_id(&self) -> core::any::TypeId -impl core::borrow::Borrow for aya::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized -pub fn aya::programs::sk_skb::SkSkbKind::borrow(&self) -> &T -impl core::borrow::BorrowMut for aya::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized -pub fn aya::programs::sk_skb::SkSkbKind::borrow_mut(&mut self) -> &mut T -impl core::clone::CloneToUninit for aya::programs::sk_skb::SkSkbKind where T: core::clone::Clone -pub unsafe fn aya::programs::sk_skb::SkSkbKind::clone_to_uninit(&self, dest: *mut u8) -impl core::convert::From for aya::programs::sk_skb::SkSkbKind -pub fn aya::programs::sk_skb::SkSkbKind::from(t: T) -> T +pub use aya::programs::sk_skb::SkSkbKind pub struct aya::programs::sk_skb::SkSkb impl aya::programs::sk_skb::SkSkb pub const aya::programs::sk_skb::SkSkb::PROGRAM_TYPE: aya::programs::ProgramType pub fn aya::programs::sk_skb::SkSkb::attach(&mut self, map: &aya::maps::sock::SockMapFd) -> core::result::Result -pub fn aya::programs::sk_skb::SkSkb::from_pin>(path: P, kind: aya::programs::sk_skb::SkSkbKind) -> core::result::Result +pub fn aya::programs::sk_skb::SkSkb::from_pin>(path: P, kind: aya_obj::programs::sk_skb::SkSkbKind) -> core::result::Result pub fn aya::programs::sk_skb::SkSkb::load(&mut self) -> core::result::Result<(), aya::programs::ProgramError> impl aya::programs::sk_skb::SkSkb pub fn aya::programs::sk_skb::SkSkb::detach(&mut self, link_id: aya::programs::sk_skb::SkSkbLinkId) -> core::result::Result<(), aya::programs::ProgramError> @@ -6462,7 +6392,7 @@ pub fn aya::programs::sk_skb::SkSkb::take_link(&mut self, link_id: aya::programs impl aya::programs::sk_skb::SkSkb pub fn aya::programs::sk_skb::SkSkb::fd(&self) -> core::result::Result<&aya::programs::ProgramFd, aya::programs::ProgramError> impl aya::programs::sk_skb::SkSkb -pub fn aya::programs::sk_skb::SkSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, kind: aya::programs::sk_skb::SkSkbKind) -> core::result::Result +pub fn aya::programs::sk_skb::SkSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, kind: aya_obj::programs::sk_skb::SkSkbKind) -> core::result::Result impl aya::programs::sk_skb::SkSkb pub fn aya::programs::sk_skb::SkSkb::info(&self) -> core::result::Result impl aya::programs::sk_skb::SkSkb @@ -8114,43 +8044,6 @@ impl core::clone::CloneToUninit for aya::programs::links::CgroupAttachMode wh pub unsafe fn aya::programs::links::CgroupAttachMode::clone_to_uninit(&self, dest: *mut u8) impl core::convert::From for aya::programs::links::CgroupAttachMode pub fn aya::programs::links::CgroupAttachMode::from(t: T) -> T -pub enum aya::programs::CgroupSkbAttachType -pub aya::programs::CgroupSkbAttachType::Egress -pub aya::programs::CgroupSkbAttachType::Ingress -impl core::clone::Clone for aya::programs::cgroup_skb::CgroupSkbAttachType -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::clone(&self) -> aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::fmt::Debug for aya::programs::cgroup_skb::CgroupSkbAttachType -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result -impl core::marker::Copy for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Freeze for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Send for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Sync for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::Unpin for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::marker::UnsafeUnpin for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::panic::unwind_safe::UnwindSafe for aya::programs::cgroup_skb::CgroupSkbAttachType -impl core::convert::Into for aya::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::From -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::into(self) -> U -impl core::convert::TryFrom for aya::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::Into -pub type aya::programs::cgroup_skb::CgroupSkbAttachType::Error = core::convert::Infallible -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::try_from(value: U) -> core::result::Result>::Error> -impl core::convert::TryInto for aya::programs::cgroup_skb::CgroupSkbAttachType where U: core::convert::TryFrom -pub type aya::programs::cgroup_skb::CgroupSkbAttachType::Error = >::Error -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::try_into(self) -> core::result::Result>::Error> -impl alloc::borrow::ToOwned for aya::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone -pub type aya::programs::cgroup_skb::CgroupSkbAttachType::Owned = T -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::clone_into(&self, target: &mut T) -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::to_owned(&self) -> T -impl core::any::Any for aya::programs::cgroup_skb::CgroupSkbAttachType where T: 'static + ?core::marker::Sized -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::type_id(&self) -> core::any::TypeId -impl core::borrow::Borrow for aya::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::borrow(&self) -> &T -impl core::borrow::BorrowMut for aya::programs::cgroup_skb::CgroupSkbAttachType where T: ?core::marker::Sized -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::borrow_mut(&mut self) -> &mut T -impl core::clone::CloneToUninit for aya::programs::cgroup_skb::CgroupSkbAttachType where T: core::clone::Clone -pub unsafe fn aya::programs::cgroup_skb::CgroupSkbAttachType::clone_to_uninit(&self, dest: *mut u8) -impl core::convert::From for aya::programs::cgroup_skb::CgroupSkbAttachType -pub fn aya::programs::cgroup_skb::CgroupSkbAttachType::from(t: T) -> T pub enum aya::programs::ExtensionError pub aya::programs::ExtensionError::NoBTF impl core::convert::From for aya::programs::ProgramError @@ -8677,43 +8570,6 @@ impl core::clone::CloneToUninit for aya::programs::ProgramType where T: core: pub unsafe fn aya::programs::ProgramType::clone_to_uninit(&self, dest: *mut u8) impl core::convert::From for aya::programs::ProgramType pub fn aya::programs::ProgramType::from(t: T) -> T -pub enum aya::programs::SkSkbKind -pub aya::programs::SkSkbKind::StreamParser -pub aya::programs::SkSkbKind::StreamVerdict -impl core::clone::Clone for aya::programs::sk_skb::SkSkbKind -pub fn aya::programs::sk_skb::SkSkbKind::clone(&self) -> aya::programs::sk_skb::SkSkbKind -impl core::fmt::Debug for aya::programs::sk_skb::SkSkbKind -pub fn aya::programs::sk_skb::SkSkbKind::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result -impl core::marker::Copy for aya::programs::sk_skb::SkSkbKind -impl core::marker::Freeze for aya::programs::sk_skb::SkSkbKind -impl core::marker::Send for aya::programs::sk_skb::SkSkbKind -impl core::marker::Sync for aya::programs::sk_skb::SkSkbKind -impl core::marker::Unpin for aya::programs::sk_skb::SkSkbKind -impl core::marker::UnsafeUnpin for aya::programs::sk_skb::SkSkbKind -impl core::panic::unwind_safe::RefUnwindSafe for aya::programs::sk_skb::SkSkbKind -impl core::panic::unwind_safe::UnwindSafe for aya::programs::sk_skb::SkSkbKind -impl core::convert::Into for aya::programs::sk_skb::SkSkbKind where U: core::convert::From -pub fn aya::programs::sk_skb::SkSkbKind::into(self) -> U -impl core::convert::TryFrom for aya::programs::sk_skb::SkSkbKind where U: core::convert::Into -pub type aya::programs::sk_skb::SkSkbKind::Error = core::convert::Infallible -pub fn aya::programs::sk_skb::SkSkbKind::try_from(value: U) -> core::result::Result>::Error> -impl core::convert::TryInto for aya::programs::sk_skb::SkSkbKind where U: core::convert::TryFrom -pub type aya::programs::sk_skb::SkSkbKind::Error = >::Error -pub fn aya::programs::sk_skb::SkSkbKind::try_into(self) -> core::result::Result>::Error> -impl alloc::borrow::ToOwned for aya::programs::sk_skb::SkSkbKind where T: core::clone::Clone -pub type aya::programs::sk_skb::SkSkbKind::Owned = T -pub fn aya::programs::sk_skb::SkSkbKind::clone_into(&self, target: &mut T) -pub fn aya::programs::sk_skb::SkSkbKind::to_owned(&self) -> T -impl core::any::Any for aya::programs::sk_skb::SkSkbKind where T: 'static + ?core::marker::Sized -pub fn aya::programs::sk_skb::SkSkbKind::type_id(&self) -> core::any::TypeId -impl core::borrow::Borrow for aya::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized -pub fn aya::programs::sk_skb::SkSkbKind::borrow(&self) -> &T -impl core::borrow::BorrowMut for aya::programs::sk_skb::SkSkbKind where T: ?core::marker::Sized -pub fn aya::programs::sk_skb::SkSkbKind::borrow_mut(&mut self) -> &mut T -impl core::clone::CloneToUninit for aya::programs::sk_skb::SkSkbKind where T: core::clone::Clone -pub unsafe fn aya::programs::sk_skb::SkSkbKind::clone_to_uninit(&self, dest: *mut u8) -impl core::convert::From for aya::programs::sk_skb::SkSkbKind -pub fn aya::programs::sk_skb::SkSkbKind::from(t: T) -> T pub enum aya::programs::SocketFilterError pub aya::programs::SocketFilterError::SoAttachEbpfError pub aya::programs::SocketFilterError::SoAttachEbpfError::io_error: std::io::error::Error @@ -9071,9 +8927,9 @@ pub fn aya::programs::cgroup_device::CgroupDevice::from(t: T) -> T pub struct aya::programs::CgroupSkb impl aya::programs::cgroup_skb::CgroupSkb pub const aya::programs::cgroup_skb::CgroupSkb::PROGRAM_TYPE: aya::programs::ProgramType -pub fn aya::programs::cgroup_skb::CgroupSkb::attach(&mut self, cgroup: T, attach_type: aya::programs::cgroup_skb::CgroupSkbAttachType, mode: aya::programs::links::CgroupAttachMode) -> core::result::Result -pub const fn aya::programs::cgroup_skb::CgroupSkb::expected_attach_type(&self) -> &core::option::Option -pub fn aya::programs::cgroup_skb::CgroupSkb::from_pin>(path: P, expected_attach_type: aya::programs::cgroup_skb::CgroupSkbAttachType) -> core::result::Result +pub fn aya::programs::cgroup_skb::CgroupSkb::attach(&mut self, cgroup: T, attach_type: aya_obj::programs::cgroup_skb::CgroupSkbAttachType, mode: aya::programs::links::CgroupAttachMode) -> core::result::Result +pub const fn aya::programs::cgroup_skb::CgroupSkb::expected_attach_type(&self) -> &core::option::Option +pub fn aya::programs::cgroup_skb::CgroupSkb::from_pin>(path: P, expected_attach_type: aya_obj::programs::cgroup_skb::CgroupSkbAttachType) -> core::result::Result pub fn aya::programs::cgroup_skb::CgroupSkb::load(&mut self) -> core::result::Result<(), aya::programs::ProgramError> impl aya::programs::cgroup_skb::CgroupSkb pub fn aya::programs::cgroup_skb::CgroupSkb::detach(&mut self, link_id: aya::programs::cgroup_skb::CgroupSkbLinkId) -> core::result::Result<(), aya::programs::ProgramError> @@ -9081,7 +8937,7 @@ pub fn aya::programs::cgroup_skb::CgroupSkb::take_link(&mut self, link_id: aya:: impl aya::programs::cgroup_skb::CgroupSkb pub fn aya::programs::cgroup_skb::CgroupSkb::fd(&self) -> core::result::Result<&aya::programs::ProgramFd, aya::programs::ProgramError> impl aya::programs::cgroup_skb::CgroupSkb -pub fn aya::programs::cgroup_skb::CgroupSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, attach_type: core::option::Option) -> core::result::Result +pub fn aya::programs::cgroup_skb::CgroupSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, attach_type: core::option::Option) -> core::result::Result impl aya::programs::cgroup_skb::CgroupSkb pub fn aya::programs::cgroup_skb::CgroupSkb::info(&self) -> core::result::Result impl aya::programs::cgroup_skb::CgroupSkb @@ -10228,7 +10084,7 @@ pub struct aya::programs::SkSkb impl aya::programs::sk_skb::SkSkb pub const aya::programs::sk_skb::SkSkb::PROGRAM_TYPE: aya::programs::ProgramType pub fn aya::programs::sk_skb::SkSkb::attach(&mut self, map: &aya::maps::sock::SockMapFd) -> core::result::Result -pub fn aya::programs::sk_skb::SkSkb::from_pin>(path: P, kind: aya::programs::sk_skb::SkSkbKind) -> core::result::Result +pub fn aya::programs::sk_skb::SkSkb::from_pin>(path: P, kind: aya_obj::programs::sk_skb::SkSkbKind) -> core::result::Result pub fn aya::programs::sk_skb::SkSkb::load(&mut self) -> core::result::Result<(), aya::programs::ProgramError> impl aya::programs::sk_skb::SkSkb pub fn aya::programs::sk_skb::SkSkb::detach(&mut self, link_id: aya::programs::sk_skb::SkSkbLinkId) -> core::result::Result<(), aya::programs::ProgramError> @@ -10236,7 +10092,7 @@ pub fn aya::programs::sk_skb::SkSkb::take_link(&mut self, link_id: aya::programs impl aya::programs::sk_skb::SkSkb pub fn aya::programs::sk_skb::SkSkb::fd(&self) -> core::result::Result<&aya::programs::ProgramFd, aya::programs::ProgramError> impl aya::programs::sk_skb::SkSkb -pub fn aya::programs::sk_skb::SkSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, kind: aya::programs::sk_skb::SkSkbKind) -> core::result::Result +pub fn aya::programs::sk_skb::SkSkb::from_program_info(info: aya::programs::ProgramInfo, name: alloc::borrow::Cow<'static, str>, kind: aya_obj::programs::sk_skb::SkSkbKind) -> core::result::Result impl aya::programs::sk_skb::SkSkb pub fn aya::programs::sk_skb::SkSkb::info(&self) -> core::result::Result impl aya::programs::sk_skb::SkSkb