From cdf960aaa1fae42f1197e173f029255d3e827942 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 19 Feb 2021 09:18:00 +0000 Subject: [PATCH] bpf: initial bpf bindings --- Cargo.toml | 2 +- bpf/Cargo.toml | 2 + bpf/aya-bpf-cty/.travis.yml | 32 + bpf/aya-bpf-cty/CHANGELOG.md | 66 + bpf/aya-bpf-cty/Cargo.toml | 8 + bpf/aya-bpf-cty/LICENSE-APACHE | 201 +++ bpf/aya-bpf-cty/LICENSE-MIT | 25 + bpf/aya-bpf-cty/README.md | 22 + bpf/aya-bpf-cty/build.rs | 9 + bpf/aya-bpf-cty/ci/install.sh | 7 + bpf/aya-bpf-cty/ci/script.sh | 10 + bpf/aya-bpf-cty/src/lib.rs | 139 ++ bpf/aya-bpf-macros/Cargo.toml | 13 + bpf/aya-bpf-macros/src/expand.rs | 122 ++ bpf/aya-bpf-macros/src/lib.rs | 46 + bpf/aya-bpf/Cargo.toml | 9 + bpf/aya-bpf/include/aya_bpf_bindings.h | 3 + bpf/aya-bpf/src/bpf/generated/bindings.rs | 932 +++++++++++ bpf/aya-bpf/src/bpf/generated/helpers.rs | 1826 +++++++++++++++++++++ bpf/aya-bpf/src/bpf/generated/mod.rs | 4 + bpf/aya-bpf/src/bpf/helpers.rs | 37 + bpf/aya-bpf/src/bpf/mod.rs | 4 + bpf/aya-bpf/src/lib.rs | 34 + bpf/aya-bpf/src/maps/mod.rs | 3 + bpf/aya-bpf/src/maps/perf_map.rs | 58 + bpf/aya-bpf/src/programs/mod.rs | 3 + bpf/aya-bpf/src/programs/probe.rs | 21 + xtask/Cargo.toml | 14 + xtask/src/codegen/aya_bpf.rs | 140 ++ xtask/src/codegen/mod.rs | 22 + xtask/src/main.rs | 29 + 31 files changed, 3842 insertions(+), 1 deletion(-) create mode 100644 bpf/Cargo.toml create mode 100644 bpf/aya-bpf-cty/.travis.yml create mode 100644 bpf/aya-bpf-cty/CHANGELOG.md create mode 100644 bpf/aya-bpf-cty/Cargo.toml create mode 100644 bpf/aya-bpf-cty/LICENSE-APACHE create mode 100644 bpf/aya-bpf-cty/LICENSE-MIT create mode 100644 bpf/aya-bpf-cty/README.md create mode 100644 bpf/aya-bpf-cty/build.rs create mode 100644 bpf/aya-bpf-cty/ci/install.sh create mode 100644 bpf/aya-bpf-cty/ci/script.sh create mode 100644 bpf/aya-bpf-cty/src/lib.rs create mode 100644 bpf/aya-bpf-macros/Cargo.toml create mode 100644 bpf/aya-bpf-macros/src/expand.rs create mode 100644 bpf/aya-bpf-macros/src/lib.rs create mode 100644 bpf/aya-bpf/Cargo.toml create mode 100644 bpf/aya-bpf/include/aya_bpf_bindings.h create mode 100644 bpf/aya-bpf/src/bpf/generated/bindings.rs create mode 100644 bpf/aya-bpf/src/bpf/generated/helpers.rs create mode 100644 bpf/aya-bpf/src/bpf/generated/mod.rs create mode 100644 bpf/aya-bpf/src/bpf/helpers.rs create mode 100644 bpf/aya-bpf/src/bpf/mod.rs create mode 100644 bpf/aya-bpf/src/lib.rs create mode 100644 bpf/aya-bpf/src/maps/mod.rs create mode 100644 bpf/aya-bpf/src/maps/perf_map.rs create mode 100644 bpf/aya-bpf/src/programs/mod.rs create mode 100644 bpf/aya-bpf/src/programs/probe.rs create mode 100644 xtask/Cargo.toml create mode 100644 xtask/src/codegen/aya_bpf.rs create mode 100644 xtask/src/codegen/mod.rs create mode 100644 xtask/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 68aac4b8..88752091 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,2 @@ [workspace] -members = ["aya"] +members = ["aya", "xtask"] diff --git a/bpf/Cargo.toml b/bpf/Cargo.toml new file mode 100644 index 00000000..c36e7c57 --- /dev/null +++ b/bpf/Cargo.toml @@ -0,0 +1,2 @@ +[workspace] +members = ["aya-bpf", "aya-bpf-macros"] diff --git a/bpf/aya-bpf-cty/.travis.yml b/bpf/aya-bpf-cty/.travis.yml new file mode 100644 index 00000000..3cf0a771 --- /dev/null +++ b/bpf/aya-bpf-cty/.travis.yml @@ -0,0 +1,32 @@ +language: rust + +matrix: + include: + # MSRV + - env: TARGET=x86_64-unknown-linux-gnu + rust: 1.30.0 + + - env: TARGET=x86_64-unknown-linux-gnu + rust: stable + +before_install: set -e + +install: + - sh ci/install.sh + +script: + - sh ci/script.sh + +after_script: set +e + +cache: cargo + +branches: + only: + - master + - staging + - trying + +notifications: + email: + on_success: never diff --git a/bpf/aya-bpf-cty/CHANGELOG.md b/bpf/aya-bpf-cty/CHANGELOG.md new file mode 100644 index 00000000..65a897b4 --- /dev/null +++ b/bpf/aya-bpf-cty/CHANGELOG.md @@ -0,0 +1,66 @@ +# Change Log + +All notable changes to this project will be documented in this file. +This project adheres to $[Semantic Versioning](http://semver.org/). + +## [Unreleased] + +## [v0.2.1] - 2019-11-16 + +### Added + +- Support for the `xtensa`, `riscv32` and `riscv64` architectures + +## [v0.2.0] - 2019-02-06 + +### Changed + +- [breaking-change] `cty::c_void` is now a type alias of `core::ffi::c_void`. + +## [v0.1.5] - 2017-05-29 + +### Added + +- More types like `int32_t` + +## [v0.1.4] - 2017-05-29 + +### Added + +- Support for the `msp430` architecture. + +### Fixed + +- [breaking-change] The type definitions of `c_long` and `c_ulong`. + +## [v0.1.3] - 2017-05-29 - YANKED + +### Added + +- Support for the `nvptx` and `nvptx64` architectures. + +## [v0.1.2] - 2017-05-29 - YANKED + +### Fixed + +- [breaking-change] The type definitions of `c_int` and `c_uint`. + +## [v0.1.1] - 2017-05-29 - YANKED + +### Fixed + +- [breaking-change] The type definitions of `c_long`, `c_ulong` and + `c_longlong`. + +## v0.1.0 - 2017-05-24 - YANKED + +- Initial release + +[Unreleased]: https://github.com/japaric/cty/compare/v0.2.1...HEAD +[v0.2.1]: https://github.com/japaric/cty/compare/v0.2.0...v0.2.1 +[v0.2.0]: https://github.com/japaric/cty/compare/v0.1.5...v0.2.0 +[v0.1.5]: https://github.com/japaric/cty/compare/v0.1.4...v0.1.5 +[v0.1.4]: https://github.com/japaric/cty/compare/v0.1.3...v0.1.4 +[v0.1.3]: https://github.com/japaric/cty/compare/v0.1.2...v0.1.3 +[v0.1.2]: https://github.com/japaric/cty/compare/v0.1.1...v0.1.2 +[v0.1.1]: https://github.com/japaric/cty/compare/v0.1.0...v0.1.1 diff --git a/bpf/aya-bpf-cty/Cargo.toml b/bpf/aya-bpf-cty/Cargo.toml new file mode 100644 index 00000000..7dc89eca --- /dev/null +++ b/bpf/aya-bpf-cty/Cargo.toml @@ -0,0 +1,8 @@ +[package] +authors = ["Jorge Aparicio "] +categories = ["embedded", "external-ffi-bindings" ,"no-std"] +description = "Type aliases to C types like c_int for use with bindgen" +documentation = "https://docs.rs/cty" +license = "MIT OR Apache-2.0" +name = "aya-bpf-cty" +version = "0.2.1" \ No newline at end of file diff --git a/bpf/aya-bpf-cty/LICENSE-APACHE b/bpf/aya-bpf-cty/LICENSE-APACHE new file mode 100644 index 00000000..16fe87b0 --- /dev/null +++ b/bpf/aya-bpf-cty/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/bpf/aya-bpf-cty/LICENSE-MIT b/bpf/aya-bpf-cty/LICENSE-MIT new file mode 100644 index 00000000..a128ba40 --- /dev/null +++ b/bpf/aya-bpf-cty/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2017 Jorge Aparicio + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/bpf/aya-bpf-cty/README.md b/bpf/aya-bpf-cty/README.md new file mode 100644 index 00000000..f5d09bd4 --- /dev/null +++ b/bpf/aya-bpf-cty/README.md @@ -0,0 +1,22 @@ +[![crates.io](https://img.shields.io/crates/v/cty.svg)](https://crates.io/crates/cty) +[![crates.io](https://img.shields.io/crates/d/cty.svg)](https://crates.io/crates/cty) + +# `cty` + +> Type aliases to C types like c_int for use with bindgen + +## License + +Licensed under either of + +- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/bpf/aya-bpf-cty/build.rs b/bpf/aya-bpf-cty/build.rs new file mode 100644 index 00000000..f6ed9c89 --- /dev/null +++ b/bpf/aya-bpf-cty/build.rs @@ -0,0 +1,9 @@ +use std::env; + +fn main() { + if !env::var("CARGO_CFG_BPF_TARGET_ARCH").is_ok() { + let arch = env::var("HOST").unwrap(); + let arch = arch.splitn(2, "-").next().unwrap(); + println!("cargo:rustc-cfg=bpf_target_arch=\"{}\"", arch); + } +} diff --git a/bpf/aya-bpf-cty/ci/install.sh b/bpf/aya-bpf-cty/ci/install.sh new file mode 100644 index 00000000..58ed3c9e --- /dev/null +++ b/bpf/aya-bpf-cty/ci/install.sh @@ -0,0 +1,7 @@ +set -ex + +main() { + return +} + +main diff --git a/bpf/aya-bpf-cty/ci/script.sh b/bpf/aya-bpf-cty/ci/script.sh new file mode 100644 index 00000000..46ac0c26 --- /dev/null +++ b/bpf/aya-bpf-cty/ci/script.sh @@ -0,0 +1,10 @@ +set -ex + +main() { + for target in $(rustup target list | grep linux-gnu | cut -d' ' -f1); do + rustup target add $target || continue + cargo check --target $target + done +} + +main diff --git a/bpf/aya-bpf-cty/src/lib.rs b/bpf/aya-bpf-cty/src/lib.rs new file mode 100644 index 00000000..fdb17dd1 --- /dev/null +++ b/bpf/aya-bpf-cty/src/lib.rs @@ -0,0 +1,139 @@ +//! Type aliases to C types like c_int for use with bindgen +//! +//! # MSRV +//! +//! This crate is guaranteed to compile on stable Rust 1.30.0 and up. It *might* compile with older +//! versions but that may change in any new patch release. +#![no_std] +#![allow(non_camel_case_types)] +#![deny(warnings)] + +// AD = Architecture dependent +pub use ad::*; +// OD = OS dependent +pub use od::*; +// PWD = Pointer Width Dependent +pub use pwd::*; + +#[cfg(any(target_arch = "bpfel", target_arch = "bpfeb"))] +mod ad { + pub type c_int = i32; + pub type c_uint = u32; + + #[cfg(bpf_target_arch = "aarch64")] + pub type c_char = super::c_uchar; + + #[cfg(any(bpf_target_arch = "x86", bpf_target_arch = "x86_64"))] + pub type c_char = super::c_schar; + + #[cfg(all(not(bpf_target_arch), host_arch = "aarch64"))] + pub type c_char = super::c_uchar; +} + +#[cfg(any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "asmjs", + target_arch = "wasm32", + target_arch = "wasm64", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "s390x", + target_arch = "riscv32", + target_arch = "riscv64" +))] +mod ad { + pub type c_char = ::c_uchar; + + pub type c_int = i32; + pub type c_uint = u32; +} + +#[cfg(any( + target_arch = "mips", + target_arch = "mips64", + target_arch = "sparc64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "nvptx", + target_arch = "nvptx64", + target_arch = "xtensa" +))] +mod ad { + pub type c_char = ::c_schar; + + pub type c_int = i32; + pub type c_uint = u32; +} + +#[cfg(target_arch = "msp430")] +mod ad { + pub type c_char = ::c_uchar; + + pub type c_int = i16; + pub type c_uint = u16; +} + +// NOTE c_{,u}long definitions come from libc v0.2.3 +#[cfg(not(any(windows, target_os = "redox", target_os = "solaris")))] +mod od { + #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))] + pub type c_long = i32; + #[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))] + pub type c_ulong = u32; + + #[cfg(target_pointer_width = "64")] + pub type c_long = i64; + #[cfg(target_pointer_width = "64")] + pub type c_ulong = u64; +} + +#[cfg(windows)] +mod od { + pub type c_long = i32; + pub type c_ulong = u32; +} + +#[cfg(any(target_os = "redox", target_os = "solaris"))] +mod od { + pub type c_long = i64; + pub type c_ulong = u64; +} + +#[cfg(target_pointer_width = "32")] +mod pwd {} + +#[cfg(target_pointer_width = "64")] +mod pwd {} + +pub type int8_t = i8; +pub type int16_t = i16; +pub type int32_t = i32; +pub type int64_t = i64; + +pub type uint8_t = u8; +pub type uint16_t = u16; +pub type uint32_t = u32; +pub type uint64_t = u64; + +pub type c_schar = i8; +pub type c_short = i16; +pub type c_longlong = i64; + +pub type c_uchar = u8; +pub type c_ushort = u16; +pub type c_ulonglong = u64; + +pub type c_float = f32; +pub type c_double = f64; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type c_void = core::ffi::c_void; diff --git a/bpf/aya-bpf-macros/Cargo.toml b/bpf/aya-bpf-macros/Cargo.toml new file mode 100644 index 00000000..68000809 --- /dev/null +++ b/bpf/aya-bpf-macros/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "aya-bpf-macros" +version = "0.1.0" +authors = ["Alessandro Decina "] +edition = "2018" + +[lib] +proc-macro = true + +[dependencies] +proc-macro2 = "1.0" +quote = "1.0" +syn = {version = "1.0", features = ["full"]} \ No newline at end of file diff --git a/bpf/aya-bpf-macros/src/expand.rs b/bpf/aya-bpf-macros/src/expand.rs new file mode 100644 index 00000000..8484cc61 --- /dev/null +++ b/bpf/aya-bpf-macros/src/expand.rs @@ -0,0 +1,122 @@ +use proc_macro2::TokenStream; +use quote::quote; +use syn::{ + parse::{Parse, ParseStream}, + punctuated::{Pair, Punctuated}, + token::Eq, + Error, Ident, ItemFn, ItemStatic, LitStr, Result, Token, +}; + +pub struct NameValue { + name: Ident, + _eq: Eq, + value: LitStr, +} + +pub struct Args { + args: Vec, +} + +impl Parse for Args { + fn parse(input: ParseStream) -> Result { + let args = Punctuated::::parse_terminated_with(input, |input| { + Ok(NameValue { + name: input.parse()?, + _eq: input.parse()?, + value: input.parse()?, + }) + })? + .into_pairs() + .map(|pair| match pair { + Pair::Punctuated(name_val, _) => name_val, + Pair::End(name_val) => name_val, + }) + .collect(); + + Ok(Args { args }) + } +} + +pub struct Map { + item: ItemStatic, + name: String, +} + +impl Map { + pub fn from_syn(args: Args, item: ItemStatic) -> Result { + let name = name_arg(&args)?.unwrap_or_else(|| item.ident.to_string()); + Ok(Map { item, name }) + } + + pub fn expand(&self) -> Result { + let section_name = format!("maps/{}", self.name); + let item = &self.item; + Ok(quote! { + #[no_mangle] + #[link_section = #section_name] + #item + }) + } +} + +pub struct Probe { + kind: ProbeKind, + item: ItemFn, + name: String, +} + +impl Probe { + pub fn from_syn(kind: ProbeKind, args: Args, item: ItemFn) -> Result { + let name = name_arg(&args)?.unwrap_or_else(|| item.sig.ident.to_string()); + + Ok(Probe { kind, item, name }) + } + + pub fn expand(&self) -> Result { + let section_name = format!("{}/{}", self.kind, self.name); + let fn_name = &self.item.sig.ident; + let item = &self.item; + Ok(quote! { + #[no_mangle] + #[link_section = #section_name] + fn #fn_name(ctx: *mut ::core::ffi::c_void) -> u32 { + let _ = #fn_name(::aya_bpf::programs::ProbeContext::new(ctx)); + return 0; + + #item + } + }) + } +} + +fn name_arg(args: &Args) -> Result> { + for arg in &args.args { + if arg.name == "name" { + return Ok(Some(arg.value.value())); + } else { + return Err(Error::new_spanned(&arg.name, "invalid argument")); + } + } + + Ok(None) +} + +#[derive(Debug, Copy, Clone)] +pub enum ProbeKind { + KProbe, + KRetProbe, + UProbe, + URetProbe, +} + +impl std::fmt::Display for ProbeKind { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + use ProbeKind::*; + match self { + KProbe => write!(f, "kprobe"), + KRetProbe => write!(f, "kretprobe"), + UProbe => write!(f, "uprobe"), + URetProbe => write!(f, "uretprobe"), + } + } +} diff --git a/bpf/aya-bpf-macros/src/lib.rs b/bpf/aya-bpf-macros/src/lib.rs new file mode 100644 index 00000000..9a0382d2 --- /dev/null +++ b/bpf/aya-bpf-macros/src/lib.rs @@ -0,0 +1,46 @@ +mod expand; + +use expand::{Args, Map, Probe, ProbeKind}; +use proc_macro::TokenStream; +use syn::{parse_macro_input, ItemFn, ItemStatic}; + +#[proc_macro_attribute] +pub fn map(attrs: TokenStream, item: TokenStream) -> TokenStream { + let args = parse_macro_input!(attrs as Args); + let item = parse_macro_input!(item as ItemStatic); + + Map::from_syn(args, item) + .and_then(|u| u.expand()) + .unwrap_or_else(|err| err.to_compile_error()) + .into() +} + +#[proc_macro_attribute] +pub fn kprobe(attrs: TokenStream, item: TokenStream) -> TokenStream { + probe(ProbeKind::KProbe, attrs, item) +} + +#[proc_macro_attribute] +pub fn kretprobe(attrs: TokenStream, item: TokenStream) -> TokenStream { + probe(ProbeKind::KRetProbe, attrs, item) +} + +#[proc_macro_attribute] +pub fn uprobe(attrs: TokenStream, item: TokenStream) -> TokenStream { + probe(ProbeKind::UProbe, attrs, item) +} + +#[proc_macro_attribute] +pub fn uretprobe(attrs: TokenStream, item: TokenStream) -> TokenStream { + probe(ProbeKind::URetProbe, attrs, item) +} + +fn probe(kind: ProbeKind, attrs: TokenStream, item: TokenStream) -> TokenStream { + let args = parse_macro_input!(attrs as Args); + let item = parse_macro_input!(item as ItemFn); + + Probe::from_syn(kind, args, item) + .and_then(|u| u.expand()) + .unwrap_or_else(|err| err.to_compile_error()) + .into() +} diff --git a/bpf/aya-bpf/Cargo.toml b/bpf/aya-bpf/Cargo.toml new file mode 100644 index 00000000..db055291 --- /dev/null +++ b/bpf/aya-bpf/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "aya-bpf" +version = "0.1.0" +authors = ["Alessandro Decina "] +edition = "2018" + +[dependencies] +aya-bpf-cty = { path = "../aya-bpf-cty" } +aya-bpf-macros = { path = "../aya-bpf-macros" } diff --git a/bpf/aya-bpf/include/aya_bpf_bindings.h b/bpf/aya-bpf/include/aya_bpf_bindings.h new file mode 100644 index 00000000..e815f0bc --- /dev/null +++ b/bpf/aya-bpf/include/aya_bpf_bindings.h @@ -0,0 +1,3 @@ +#include +#include +#include "bpf_helpers.h" \ No newline at end of file diff --git a/bpf/aya-bpf/src/bpf/generated/bindings.rs b/bpf/aya-bpf/src/bpf/generated/bindings.rs new file mode 100644 index 00000000..ee9f053a --- /dev/null +++ b/bpf/aya-bpf/src/bpf/generated/bindings.rs @@ -0,0 +1,932 @@ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub const BPF_LD: u32 = 0; +pub const BPF_LDX: u32 = 1; +pub const BPF_ST: u32 = 2; +pub const BPF_STX: u32 = 3; +pub const BPF_ALU: u32 = 4; +pub const BPF_JMP: u32 = 5; +pub const BPF_RET: u32 = 6; +pub const BPF_MISC: u32 = 7; +pub const BPF_W: u32 = 0; +pub const BPF_H: u32 = 8; +pub const BPF_B: u32 = 16; +pub const BPF_IMM: u32 = 0; +pub const BPF_ABS: u32 = 32; +pub const BPF_IND: u32 = 64; +pub const BPF_MEM: u32 = 96; +pub const BPF_LEN: u32 = 128; +pub const BPF_MSH: u32 = 160; +pub const BPF_ADD: u32 = 0; +pub const BPF_SUB: u32 = 16; +pub const BPF_MUL: u32 = 32; +pub const BPF_DIV: u32 = 48; +pub const BPF_OR: u32 = 64; +pub const BPF_AND: u32 = 80; +pub const BPF_LSH: u32 = 96; +pub const BPF_RSH: u32 = 112; +pub const BPF_NEG: u32 = 128; +pub const BPF_MOD: u32 = 144; +pub const BPF_XOR: u32 = 160; +pub const BPF_JA: u32 = 0; +pub const BPF_JEQ: u32 = 16; +pub const BPF_JGT: u32 = 32; +pub const BPF_JGE: u32 = 48; +pub const BPF_JSET: u32 = 64; +pub const BPF_K: u32 = 0; +pub const BPF_X: u32 = 8; +pub const BPF_MAXINSNS: u32 = 4096; +pub const BPF_JMP32: u32 = 6; +pub const BPF_ALU64: u32 = 7; +pub const BPF_DW: u32 = 24; +pub const BPF_XADD: u32 = 192; +pub const BPF_MOV: u32 = 176; +pub const BPF_ARSH: u32 = 192; +pub const BPF_END: u32 = 208; +pub const BPF_TO_LE: u32 = 0; +pub const BPF_TO_BE: u32 = 8; +pub const BPF_FROM_LE: u32 = 0; +pub const BPF_FROM_BE: u32 = 8; +pub const BPF_JNE: u32 = 80; +pub const BPF_JLT: u32 = 160; +pub const BPF_JLE: u32 = 176; +pub const BPF_JSGT: u32 = 96; +pub const BPF_JSGE: u32 = 112; +pub const BPF_JSLT: u32 = 192; +pub const BPF_JSLE: u32 = 208; +pub const BPF_CALL: u32 = 128; +pub const BPF_EXIT: u32 = 144; +pub const BPF_F_ALLOW_OVERRIDE: u32 = 1; +pub const BPF_F_ALLOW_MULTI: u32 = 2; +pub const BPF_F_REPLACE: u32 = 4; +pub const BPF_F_STRICT_ALIGNMENT: u32 = 1; +pub const BPF_F_ANY_ALIGNMENT: u32 = 2; +pub const BPF_F_TEST_RND_HI32: u32 = 4; +pub const BPF_F_TEST_STATE_FREQ: u32 = 8; +pub const BPF_PSEUDO_MAP_FD: u32 = 1; +pub const BPF_PSEUDO_MAP_VALUE: u32 = 2; +pub const BPF_PSEUDO_CALL: u32 = 1; +pub const BPF_F_QUERY_EFFECTIVE: u32 = 1; +pub const BPF_BUILD_ID_SIZE: u32 = 20; +pub const BPF_OBJ_NAME_LEN: u32 = 16; +pub const BPF_TAG_SIZE: u32 = 8; +pub type __u8 = ::aya_bpf_cty::c_uchar; +pub type __u16 = ::aya_bpf_cty::c_ushort; +pub type __s32 = ::aya_bpf_cty::c_int; +pub type __u32 = ::aya_bpf_cty::c_uint; +pub type __s64 = ::aya_bpf_cty::c_longlong; +pub type __u64 = ::aya_bpf_cty::c_ulonglong; +pub type __be16 = __u16; +pub type __be32 = __u32; +pub type __wsum = __u32; +pub const BPF_REG_0: ::aya_bpf_cty::c_uint = 0; +pub const BPF_REG_1: ::aya_bpf_cty::c_uint = 1; +pub const BPF_REG_2: ::aya_bpf_cty::c_uint = 2; +pub const BPF_REG_3: ::aya_bpf_cty::c_uint = 3; +pub const BPF_REG_4: ::aya_bpf_cty::c_uint = 4; +pub const BPF_REG_5: ::aya_bpf_cty::c_uint = 5; +pub const BPF_REG_6: ::aya_bpf_cty::c_uint = 6; +pub const BPF_REG_7: ::aya_bpf_cty::c_uint = 7; +pub const BPF_REG_8: ::aya_bpf_cty::c_uint = 8; +pub const BPF_REG_9: ::aya_bpf_cty::c_uint = 9; +pub const BPF_REG_10: ::aya_bpf_cty::c_uint = 10; +pub const __MAX_BPF_REG: ::aya_bpf_cty::c_uint = 11; +pub type _bindgen_ty_1 = ::aya_bpf_cty::c_uint; +pub const BPF_MAP_TYPE_UNSPEC: bpf_map_type = 0; +pub const BPF_MAP_TYPE_HASH: bpf_map_type = 1; +pub const BPF_MAP_TYPE_ARRAY: bpf_map_type = 2; +pub const BPF_MAP_TYPE_PROG_ARRAY: bpf_map_type = 3; +pub const BPF_MAP_TYPE_PERF_EVENT_ARRAY: bpf_map_type = 4; +pub const BPF_MAP_TYPE_PERCPU_HASH: bpf_map_type = 5; +pub const BPF_MAP_TYPE_PERCPU_ARRAY: bpf_map_type = 6; +pub const BPF_MAP_TYPE_STACK_TRACE: bpf_map_type = 7; +pub const BPF_MAP_TYPE_CGROUP_ARRAY: bpf_map_type = 8; +pub const BPF_MAP_TYPE_LRU_HASH: bpf_map_type = 9; +pub const BPF_MAP_TYPE_LRU_PERCPU_HASH: bpf_map_type = 10; +pub const BPF_MAP_TYPE_LPM_TRIE: bpf_map_type = 11; +pub const BPF_MAP_TYPE_ARRAY_OF_MAPS: bpf_map_type = 12; +pub const BPF_MAP_TYPE_HASH_OF_MAPS: bpf_map_type = 13; +pub const BPF_MAP_TYPE_DEVMAP: bpf_map_type = 14; +pub const BPF_MAP_TYPE_SOCKMAP: bpf_map_type = 15; +pub const BPF_MAP_TYPE_CPUMAP: bpf_map_type = 16; +pub const BPF_MAP_TYPE_XSKMAP: bpf_map_type = 17; +pub const BPF_MAP_TYPE_SOCKHASH: bpf_map_type = 18; +pub const BPF_MAP_TYPE_CGROUP_STORAGE: bpf_map_type = 19; +pub const BPF_MAP_TYPE_REUSEPORT_SOCKARRAY: bpf_map_type = 20; +pub const BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE: bpf_map_type = 21; +pub const BPF_MAP_TYPE_QUEUE: bpf_map_type = 22; +pub const BPF_MAP_TYPE_STACK: bpf_map_type = 23; +pub const BPF_MAP_TYPE_SK_STORAGE: bpf_map_type = 24; +pub const BPF_MAP_TYPE_DEVMAP_HASH: bpf_map_type = 25; +pub const BPF_MAP_TYPE_STRUCT_OPS: bpf_map_type = 26; +pub const BPF_MAP_TYPE_RINGBUF: bpf_map_type = 27; +pub type bpf_map_type = ::aya_bpf_cty::c_uint; +pub const BPF_ANY: ::aya_bpf_cty::c_uint = 0; +pub const BPF_NOEXIST: ::aya_bpf_cty::c_uint = 1; +pub const BPF_EXIST: ::aya_bpf_cty::c_uint = 2; +pub const BPF_F_LOCK: ::aya_bpf_cty::c_uint = 4; +pub type _bindgen_ty_2 = ::aya_bpf_cty::c_uint; +pub const BPF_F_NO_PREALLOC: ::aya_bpf_cty::c_uint = 1; +pub const BPF_F_NO_COMMON_LRU: ::aya_bpf_cty::c_uint = 2; +pub const BPF_F_NUMA_NODE: ::aya_bpf_cty::c_uint = 4; +pub const BPF_F_RDONLY: ::aya_bpf_cty::c_uint = 8; +pub const BPF_F_WRONLY: ::aya_bpf_cty::c_uint = 16; +pub const BPF_F_STACK_BUILD_ID: ::aya_bpf_cty::c_uint = 32; +pub const BPF_F_ZERO_SEED: ::aya_bpf_cty::c_uint = 64; +pub const BPF_F_RDONLY_PROG: ::aya_bpf_cty::c_uint = 128; +pub const BPF_F_WRONLY_PROG: ::aya_bpf_cty::c_uint = 256; +pub const BPF_F_CLONE: ::aya_bpf_cty::c_uint = 512; +pub const BPF_F_MMAPABLE: ::aya_bpf_cty::c_uint = 1024; +pub type _bindgen_ty_3 = ::aya_bpf_cty::c_uint; +pub const BPF_F_RECOMPUTE_CSUM: ::aya_bpf_cty::c_uint = 1; +pub const BPF_F_INVALIDATE_HASH: ::aya_bpf_cty::c_uint = 2; +pub type _bindgen_ty_4 = ::aya_bpf_cty::c_uint; +pub const BPF_F_HDR_FIELD_MASK: ::aya_bpf_cty::c_uint = 15; +pub type _bindgen_ty_5 = ::aya_bpf_cty::c_uint; +pub const BPF_F_PSEUDO_HDR: ::aya_bpf_cty::c_uint = 16; +pub const BPF_F_MARK_MANGLED_0: ::aya_bpf_cty::c_uint = 32; +pub const BPF_F_MARK_ENFORCE: ::aya_bpf_cty::c_uint = 64; +pub type _bindgen_ty_6 = ::aya_bpf_cty::c_uint; +pub const BPF_F_INGRESS: ::aya_bpf_cty::c_uint = 1; +pub type _bindgen_ty_7 = ::aya_bpf_cty::c_uint; +pub const BPF_F_TUNINFO_IPV6: ::aya_bpf_cty::c_uint = 1; +pub type _bindgen_ty_8 = ::aya_bpf_cty::c_uint; +pub const BPF_F_SKIP_FIELD_MASK: ::aya_bpf_cty::c_uint = 255; +pub const BPF_F_USER_STACK: ::aya_bpf_cty::c_uint = 256; +pub const BPF_F_FAST_STACK_CMP: ::aya_bpf_cty::c_uint = 512; +pub const BPF_F_REUSE_STACKID: ::aya_bpf_cty::c_uint = 1024; +pub const BPF_F_USER_BUILD_ID: ::aya_bpf_cty::c_uint = 2048; +pub type _bindgen_ty_9 = ::aya_bpf_cty::c_uint; +pub const BPF_F_ZERO_CSUM_TX: ::aya_bpf_cty::c_uint = 2; +pub const BPF_F_DONT_FRAGMENT: ::aya_bpf_cty::c_uint = 4; +pub const BPF_F_SEQ_NUMBER: ::aya_bpf_cty::c_uint = 8; +pub type _bindgen_ty_10 = ::aya_bpf_cty::c_uint; +pub const BPF_F_INDEX_MASK: ::aya_bpf_cty::c_ulong = 4294967295; +pub const BPF_F_CURRENT_CPU: ::aya_bpf_cty::c_ulong = 4294967295; +pub const BPF_F_CTXLEN_MASK: ::aya_bpf_cty::c_ulong = 4503595332403200; +pub type _bindgen_ty_11 = ::aya_bpf_cty::c_ulong; +pub const BPF_F_CURRENT_NETNS: ::aya_bpf_cty::c_int = -1; +pub type _bindgen_ty_12 = ::aya_bpf_cty::c_int; +pub const BPF_CSUM_LEVEL_QUERY: ::aya_bpf_cty::c_uint = 0; +pub const BPF_CSUM_LEVEL_INC: ::aya_bpf_cty::c_uint = 1; +pub const BPF_CSUM_LEVEL_DEC: ::aya_bpf_cty::c_uint = 2; +pub const BPF_CSUM_LEVEL_RESET: ::aya_bpf_cty::c_uint = 3; +pub type _bindgen_ty_13 = ::aya_bpf_cty::c_uint; +pub const BPF_F_ADJ_ROOM_FIXED_GSO: ::aya_bpf_cty::c_uint = 1; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV4: ::aya_bpf_cty::c_uint = 2; +pub const BPF_F_ADJ_ROOM_ENCAP_L3_IPV6: ::aya_bpf_cty::c_uint = 4; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_GRE: ::aya_bpf_cty::c_uint = 8; +pub const BPF_F_ADJ_ROOM_ENCAP_L4_UDP: ::aya_bpf_cty::c_uint = 16; +pub const BPF_F_ADJ_ROOM_NO_CSUM_RESET: ::aya_bpf_cty::c_uint = 32; +pub type _bindgen_ty_14 = ::aya_bpf_cty::c_uint; +pub const BPF_ADJ_ROOM_ENCAP_L2_MASK: ::aya_bpf_cty::c_uint = 255; +pub const BPF_ADJ_ROOM_ENCAP_L2_SHIFT: ::aya_bpf_cty::c_uint = 56; +pub type _bindgen_ty_15 = ::aya_bpf_cty::c_uint; +pub const BPF_F_SYSCTL_BASE_NAME: ::aya_bpf_cty::c_uint = 1; +pub type _bindgen_ty_16 = ::aya_bpf_cty::c_uint; +pub const BPF_SK_STORAGE_GET_F_CREATE: ::aya_bpf_cty::c_uint = 1; +pub type _bindgen_ty_17 = ::aya_bpf_cty::c_uint; +pub const BPF_F_GET_BRANCH_RECORDS_SIZE: ::aya_bpf_cty::c_uint = 1; +pub type _bindgen_ty_18 = ::aya_bpf_cty::c_uint; +pub const BPF_RB_NO_WAKEUP: ::aya_bpf_cty::c_uint = 1; +pub const BPF_RB_FORCE_WAKEUP: ::aya_bpf_cty::c_uint = 2; +pub type _bindgen_ty_19 = ::aya_bpf_cty::c_uint; +pub const BPF_RB_AVAIL_DATA: ::aya_bpf_cty::c_uint = 0; +pub const BPF_RB_RING_SIZE: ::aya_bpf_cty::c_uint = 1; +pub const BPF_RB_CONS_POS: ::aya_bpf_cty::c_uint = 2; +pub const BPF_RB_PROD_POS: ::aya_bpf_cty::c_uint = 3; +pub type _bindgen_ty_20 = ::aya_bpf_cty::c_uint; +pub const BPF_RINGBUF_BUSY_BIT: ::aya_bpf_cty::c_uint = 2147483648; +pub const BPF_RINGBUF_DISCARD_BIT: ::aya_bpf_cty::c_uint = 1073741824; +pub const BPF_RINGBUF_HDR_SZ: ::aya_bpf_cty::c_uint = 8; +pub type _bindgen_ty_21 = ::aya_bpf_cty::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __sk_buff { + pub len: __u32, + pub pkt_type: __u32, + pub mark: __u32, + pub queue_mapping: __u32, + pub protocol: __u32, + pub vlan_present: __u32, + pub vlan_tci: __u32, + pub vlan_proto: __u32, + pub priority: __u32, + pub ingress_ifindex: __u32, + pub ifindex: __u32, + pub tc_index: __u32, + pub cb: [__u32; 5usize], + pub hash: __u32, + pub tc_classid: __u32, + pub data: __u32, + pub data_end: __u32, + pub napi_id: __u32, + pub family: __u32, + pub remote_ip4: __u32, + pub local_ip4: __u32, + pub remote_ip6: [__u32; 4usize], + pub local_ip6: [__u32; 4usize], + pub remote_port: __u32, + pub local_port: __u32, + pub data_meta: __u32, + pub __bindgen_anon_1: __sk_buff__bindgen_ty_1, + pub tstamp: __u64, + pub wire_len: __u32, + pub gso_segs: __u32, + pub __bindgen_anon_2: __sk_buff__bindgen_ty_2, + pub gso_size: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union __sk_buff__bindgen_ty_1 { + pub flow_keys: *mut bpf_flow_keys, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl __sk_buff__bindgen_ty_1 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union __sk_buff__bindgen_ty_2 { + pub sk: *mut bpf_sock, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl __sk_buff__bindgen_ty_2 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_tunnel_key { + pub tunnel_id: __u32, + pub __bindgen_anon_1: bpf_tunnel_key__bindgen_ty_1, + pub tunnel_tos: __u8, + pub tunnel_ttl: __u8, + pub tunnel_ext: __u16, + pub tunnel_label: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_tunnel_key__bindgen_ty_1 { + pub remote_ipv4: __u32, + pub remote_ipv6: [__u32; 4usize], + _bindgen_union_align: [u32; 4usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_xfrm_state { + pub reqid: __u32, + pub spi: __u32, + pub family: __u16, + pub ext: __u16, + pub __bindgen_anon_1: bpf_xfrm_state__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_xfrm_state__bindgen_ty_1 { + pub remote_ipv4: __u32, + pub remote_ipv6: [__u32; 4usize], + _bindgen_union_align: [u32; 4usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_sock { + pub bound_dev_if: __u32, + pub family: __u32, + pub type_: __u32, + pub protocol: __u32, + pub mark: __u32, + pub priority: __u32, + pub src_ip4: __u32, + pub src_ip6: [__u32; 4usize], + pub src_port: __u32, + pub dst_port: __u32, + pub dst_ip4: __u32, + pub dst_ip6: [__u32; 4usize], + pub state: __u32, + pub rx_queue_mapping: __s32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_tcp_sock { + pub snd_cwnd: __u32, + pub srtt_us: __u32, + pub rtt_min: __u32, + pub snd_ssthresh: __u32, + pub rcv_nxt: __u32, + pub snd_nxt: __u32, + pub snd_una: __u32, + pub mss_cache: __u32, + pub ecn_flags: __u32, + pub rate_delivered: __u32, + pub rate_interval_us: __u32, + pub packets_out: __u32, + pub retrans_out: __u32, + pub total_retrans: __u32, + pub segs_in: __u32, + pub data_segs_in: __u32, + pub segs_out: __u32, + pub data_segs_out: __u32, + pub lost_out: __u32, + pub sacked_out: __u32, + pub bytes_received: __u64, + pub bytes_acked: __u64, + pub dsack_dups: __u32, + pub delivered: __u32, + pub delivered_ce: __u32, + pub icsk_retransmits: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_sock_tuple { + pub __bindgen_anon_1: bpf_sock_tuple__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_sock_tuple__bindgen_ty_1 { + pub ipv4: bpf_sock_tuple__bindgen_ty_1__bindgen_ty_1, + pub ipv6: bpf_sock_tuple__bindgen_ty_1__bindgen_ty_2, + _bindgen_union_align: [u32; 9usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_sock_tuple__bindgen_ty_1__bindgen_ty_1 { + pub saddr: __be32, + pub daddr: __be32, + pub sport: __be16, + pub dport: __be16, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_sock_tuple__bindgen_ty_1__bindgen_ty_2 { + pub saddr: [__be32; 4usize], + pub daddr: [__be32; 4usize], + pub sport: __be16, + pub dport: __be16, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct xdp_md { + pub data: __u32, + pub data_end: __u32, + pub data_meta: __u32, + pub ingress_ifindex: __u32, + pub rx_queue_index: __u32, + pub egress_ifindex: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sk_msg_md { + pub __bindgen_anon_1: sk_msg_md__bindgen_ty_1, + pub __bindgen_anon_2: sk_msg_md__bindgen_ty_2, + pub family: __u32, + pub remote_ip4: __u32, + pub local_ip4: __u32, + pub remote_ip6: [__u32; 4usize], + pub local_ip6: [__u32; 4usize], + pub remote_port: __u32, + pub local_port: __u32, + pub size: __u32, + pub __bindgen_anon_3: sk_msg_md__bindgen_ty_3, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sk_msg_md__bindgen_ty_1 { + pub data: *mut ::aya_bpf_cty::c_void, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl sk_msg_md__bindgen_ty_1 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sk_msg_md__bindgen_ty_2 { + pub data_end: *mut ::aya_bpf_cty::c_void, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl sk_msg_md__bindgen_ty_2 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sk_msg_md__bindgen_ty_3 { + pub sk: *mut bpf_sock, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl sk_msg_md__bindgen_ty_3 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct sk_reuseport_md { + pub __bindgen_anon_1: sk_reuseport_md__bindgen_ty_1, + pub __bindgen_anon_2: sk_reuseport_md__bindgen_ty_2, + pub len: __u32, + pub eth_protocol: __u32, + pub ip_protocol: __u32, + pub bind_inany: __u32, + pub hash: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sk_reuseport_md__bindgen_ty_1 { + pub data: *mut ::aya_bpf_cty::c_void, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl sk_reuseport_md__bindgen_ty_1 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union sk_reuseport_md__bindgen_ty_2 { + pub data_end: *mut ::aya_bpf_cty::c_void, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl sk_reuseport_md__bindgen_ty_2 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_map_info { + pub type_: __u32, + pub id: __u32, + pub key_size: __u32, + pub value_size: __u32, + pub max_entries: __u32, + pub map_flags: __u32, + pub name: [::aya_bpf_cty::c_char; 16usize], + pub ifindex: __u32, + pub btf_vmlinux_value_type_id: __u32, + pub netns_dev: __u64, + pub netns_ino: __u64, + pub btf_id: __u32, + pub btf_key_type_id: __u32, + pub btf_value_type_id: __u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_sock_addr { + pub user_family: __u32, + pub user_ip4: __u32, + pub user_ip6: [__u32; 4usize], + pub user_port: __u32, + pub family: __u32, + pub type_: __u32, + pub protocol: __u32, + pub msg_src_ip4: __u32, + pub msg_src_ip6: [__u32; 4usize], + pub __bindgen_anon_1: bpf_sock_addr__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_sock_addr__bindgen_ty_1 { + pub sk: *mut bpf_sock, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl bpf_sock_addr__bindgen_ty_1 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_sock_ops { + pub op: __u32, + pub __bindgen_anon_1: bpf_sock_ops__bindgen_ty_1, + pub family: __u32, + pub remote_ip4: __u32, + pub local_ip4: __u32, + pub remote_ip6: [__u32; 4usize], + pub local_ip6: [__u32; 4usize], + pub remote_port: __u32, + pub local_port: __u32, + pub is_fullsock: __u32, + pub snd_cwnd: __u32, + pub srtt_us: __u32, + pub bpf_sock_ops_cb_flags: __u32, + pub state: __u32, + pub rtt_min: __u32, + pub snd_ssthresh: __u32, + pub rcv_nxt: __u32, + pub snd_nxt: __u32, + pub snd_una: __u32, + pub mss_cache: __u32, + pub ecn_flags: __u32, + pub rate_delivered: __u32, + pub rate_interval_us: __u32, + pub packets_out: __u32, + pub retrans_out: __u32, + pub total_retrans: __u32, + pub segs_in: __u32, + pub data_segs_in: __u32, + pub segs_out: __u32, + pub data_segs_out: __u32, + pub lost_out: __u32, + pub sacked_out: __u32, + pub sk_txhash: __u32, + pub bytes_received: __u64, + pub bytes_acked: __u64, + pub __bindgen_anon_2: bpf_sock_ops__bindgen_ty_2, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_sock_ops__bindgen_ty_1 { + pub args: [__u32; 4usize], + pub reply: __u32, + pub replylong: [__u32; 4usize], + _bindgen_union_align: [u32; 4usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_sock_ops__bindgen_ty_2 { + pub sk: *mut bpf_sock, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, + _bindgen_union_align: u64, +} +impl bpf_sock_ops__bindgen_ty_2 { + #[inline] + pub fn new_bitfield_1() -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit + } +} +pub const BPF_SOCK_OPS_RTO_CB_FLAG: ::aya_bpf_cty::c_uint = 1; +pub const BPF_SOCK_OPS_RETRANS_CB_FLAG: ::aya_bpf_cty::c_uint = 2; +pub const BPF_SOCK_OPS_STATE_CB_FLAG: ::aya_bpf_cty::c_uint = 4; +pub const BPF_SOCK_OPS_RTT_CB_FLAG: ::aya_bpf_cty::c_uint = 8; +pub const BPF_SOCK_OPS_ALL_CB_FLAGS: ::aya_bpf_cty::c_uint = 15; +pub type _bindgen_ty_22 = ::aya_bpf_cty::c_uint; +pub const BPF_SOCK_OPS_VOID: ::aya_bpf_cty::c_uint = 0; +pub const BPF_SOCK_OPS_TIMEOUT_INIT: ::aya_bpf_cty::c_uint = 1; +pub const BPF_SOCK_OPS_RWND_INIT: ::aya_bpf_cty::c_uint = 2; +pub const BPF_SOCK_OPS_TCP_CONNECT_CB: ::aya_bpf_cty::c_uint = 3; +pub const BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB: ::aya_bpf_cty::c_uint = 4; +pub const BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB: ::aya_bpf_cty::c_uint = 5; +pub const BPF_SOCK_OPS_NEEDS_ECN: ::aya_bpf_cty::c_uint = 6; +pub const BPF_SOCK_OPS_BASE_RTT: ::aya_bpf_cty::c_uint = 7; +pub const BPF_SOCK_OPS_RTO_CB: ::aya_bpf_cty::c_uint = 8; +pub const BPF_SOCK_OPS_RETRANS_CB: ::aya_bpf_cty::c_uint = 9; +pub const BPF_SOCK_OPS_STATE_CB: ::aya_bpf_cty::c_uint = 10; +pub const BPF_SOCK_OPS_TCP_LISTEN_CB: ::aya_bpf_cty::c_uint = 11; +pub const BPF_SOCK_OPS_RTT_CB: ::aya_bpf_cty::c_uint = 12; +pub type _bindgen_ty_23 = ::aya_bpf_cty::c_uint; +pub const BPF_TCP_ESTABLISHED: ::aya_bpf_cty::c_uint = 1; +pub const BPF_TCP_SYN_SENT: ::aya_bpf_cty::c_uint = 2; +pub const BPF_TCP_SYN_RECV: ::aya_bpf_cty::c_uint = 3; +pub const BPF_TCP_FIN_WAIT1: ::aya_bpf_cty::c_uint = 4; +pub const BPF_TCP_FIN_WAIT2: ::aya_bpf_cty::c_uint = 5; +pub const BPF_TCP_TIME_WAIT: ::aya_bpf_cty::c_uint = 6; +pub const BPF_TCP_CLOSE: ::aya_bpf_cty::c_uint = 7; +pub const BPF_TCP_CLOSE_WAIT: ::aya_bpf_cty::c_uint = 8; +pub const BPF_TCP_LAST_ACK: ::aya_bpf_cty::c_uint = 9; +pub const BPF_TCP_LISTEN: ::aya_bpf_cty::c_uint = 10; +pub const BPF_TCP_CLOSING: ::aya_bpf_cty::c_uint = 11; +pub const BPF_TCP_NEW_SYN_RECV: ::aya_bpf_cty::c_uint = 12; +pub const BPF_TCP_MAX_STATES: ::aya_bpf_cty::c_uint = 13; +pub type _bindgen_ty_24 = ::aya_bpf_cty::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_value { + pub counter: __u64, + pub enabled: __u64, + pub running: __u64, +} +pub const BPF_DEVCG_ACC_MKNOD: ::aya_bpf_cty::c_uint = 1; +pub const BPF_DEVCG_ACC_READ: ::aya_bpf_cty::c_uint = 2; +pub const BPF_DEVCG_ACC_WRITE: ::aya_bpf_cty::c_uint = 4; +pub type _bindgen_ty_26 = ::aya_bpf_cty::c_uint; +pub const BPF_DEVCG_DEV_BLOCK: ::aya_bpf_cty::c_uint = 1; +pub const BPF_DEVCG_DEV_CHAR: ::aya_bpf_cty::c_uint = 2; +pub type _bindgen_ty_27 = ::aya_bpf_cty::c_uint; +pub const BPF_FIB_LOOKUP_DIRECT: ::aya_bpf_cty::c_uint = 1; +pub const BPF_FIB_LOOKUP_OUTPUT: ::aya_bpf_cty::c_uint = 2; +pub type _bindgen_ty_28 = ::aya_bpf_cty::c_uint; +pub const BPF_FIB_LKUP_RET_SUCCESS: ::aya_bpf_cty::c_uint = 0; +pub const BPF_FIB_LKUP_RET_BLACKHOLE: ::aya_bpf_cty::c_uint = 1; +pub const BPF_FIB_LKUP_RET_UNREACHABLE: ::aya_bpf_cty::c_uint = 2; +pub const BPF_FIB_LKUP_RET_PROHIBIT: ::aya_bpf_cty::c_uint = 3; +pub const BPF_FIB_LKUP_RET_NOT_FWDED: ::aya_bpf_cty::c_uint = 4; +pub const BPF_FIB_LKUP_RET_FWD_DISABLED: ::aya_bpf_cty::c_uint = 5; +pub const BPF_FIB_LKUP_RET_UNSUPP_LWT: ::aya_bpf_cty::c_uint = 6; +pub const BPF_FIB_LKUP_RET_NO_NEIGH: ::aya_bpf_cty::c_uint = 7; +pub const BPF_FIB_LKUP_RET_FRAG_NEEDED: ::aya_bpf_cty::c_uint = 8; +pub type _bindgen_ty_29 = ::aya_bpf_cty::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_fib_lookup { + pub family: __u8, + pub l4_protocol: __u8, + pub sport: __be16, + pub dport: __be16, + pub tot_len: __u16, + pub ifindex: __u32, + pub __bindgen_anon_1: bpf_fib_lookup__bindgen_ty_1, + pub __bindgen_anon_2: bpf_fib_lookup__bindgen_ty_2, + pub __bindgen_anon_3: bpf_fib_lookup__bindgen_ty_3, + pub h_vlan_proto: __be16, + pub h_vlan_TCI: __be16, + pub smac: [__u8; 6usize], + pub dmac: [__u8; 6usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_fib_lookup__bindgen_ty_1 { + pub tos: __u8, + pub flowinfo: __be32, + pub rt_metric: __u32, + _bindgen_union_align: u32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_fib_lookup__bindgen_ty_2 { + pub ipv4_src: __be32, + pub ipv6_src: [__u32; 4usize], + _bindgen_union_align: [u32; 4usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_fib_lookup__bindgen_ty_3 { + pub ipv4_dst: __be32, + pub ipv6_dst: [__u32; 4usize], + _bindgen_union_align: [u32; 4usize], +} +pub const BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG: ::aya_bpf_cty::c_uint = 1; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL: ::aya_bpf_cty::c_uint = 2; +pub const BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP: ::aya_bpf_cty::c_uint = 4; +pub type _bindgen_ty_30 = ::aya_bpf_cty::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct bpf_flow_keys { + pub nhoff: __u16, + pub thoff: __u16, + pub addr_proto: __u16, + pub is_frag: __u8, + pub is_first_frag: __u8, + pub is_encap: __u8, + pub ip_proto: __u8, + pub n_proto: __be16, + pub sport: __be16, + pub dport: __be16, + pub __bindgen_anon_1: bpf_flow_keys__bindgen_ty_1, + pub flags: __u32, + pub flow_label: __be32, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union bpf_flow_keys__bindgen_ty_1 { + pub __bindgen_anon_1: bpf_flow_keys__bindgen_ty_1__bindgen_ty_1, + pub __bindgen_anon_2: bpf_flow_keys__bindgen_ty_1__bindgen_ty_2, + _bindgen_union_align: [u32; 8usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_flow_keys__bindgen_ty_1__bindgen_ty_1 { + pub ipv4_src: __be32, + pub ipv4_dst: __be32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_flow_keys__bindgen_ty_1__bindgen_ty_2 { + pub ipv6_src: [__u32; 4usize], + pub ipv6_dst: [__u32; 4usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_spin_lock { + pub val: __u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_sysctl { + pub write: __u32, + pub file_pos: __u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_pidns_info { + pub pid: __u32, + pub tgid: __u32, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_perf_event_data { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_redir_neigh { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct linux_binprm { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct pt_regs { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sockaddr { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tcphdr { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct seq_file { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tcp6_sock { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tcp_sock { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tcp_timewait_sock { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tcp_request_sock { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct udp6_sock { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct task_struct { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct path { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct btf_ptr { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct inode { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct socket { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct file { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct bpf_map_def { + pub type_: ::aya_bpf_cty::c_uint, + pub key_size: ::aya_bpf_cty::c_uint, + pub value_size: ::aya_bpf_cty::c_uint, + pub max_entries: ::aya_bpf_cty::c_uint, + pub map_flags: ::aya_bpf_cty::c_uint, +} diff --git a/bpf/aya-bpf/src/bpf/generated/helpers.rs b/bpf/aya-bpf/src/bpf/generated/helpers.rs new file mode 100644 index 00000000..b189f877 --- /dev/null +++ b/bpf/aya-bpf/src/bpf/generated/helpers.rs @@ -0,0 +1,1826 @@ +use crate::bpf::generated::bindings::*; +#[inline(always)] +pub unsafe extern "C" fn bpf_map_lookup_elem( + map: *mut ::aya_bpf_cty::c_void, + key: *const ::aya_bpf_cty::c_void, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + key: *const ::aya_bpf_cty::c_void, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(1usize); + f(map, key) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_map_update_elem( + map: *mut ::aya_bpf_cty::c_void, + key: *const ::aya_bpf_cty::c_void, + value: *const ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + key: *const ::aya_bpf_cty::c_void, + value: *const ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(2usize); + f(map, key, value, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_map_delete_elem( + map: *mut ::aya_bpf_cty::c_void, + key: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + key: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(3usize); + f(map, key) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_probe_read( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(4usize); + f(dst, size, unsafe_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ktime_get_ns() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(5usize); + f() +} /* # [inline (always)] pub unsafe extern "C" fn bpf_trace_printk (fmt : * const :: aya_bpf_cty :: c_char , fmt_size : __u32 , ...) -> :: aya_bpf_cty :: c_long{ let f : unsafe extern "C" fn (fmt : * const :: aya_bpf_cty :: c_char , fmt_size : __u32 , ...) -> :: aya_bpf_cty :: c_long = :: core :: mem :: transmute (6usize) ; f (fmt , fmt_size) } */ +#[inline(always)] +pub unsafe extern "C" fn bpf_get_prandom_u32() -> __u32 { + let f: unsafe extern "C" fn() -> __u32 = ::core::mem::transmute(7usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_smp_processor_id() -> __u32 { + let f: unsafe extern "C" fn() -> __u32 = ::core::mem::transmute(8usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_store_bytes( + skb: *mut __sk_buff, + offset: __u32, + from: *const ::aya_bpf_cty::c_void, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + offset: __u32, + from: *const ::aya_bpf_cty::c_void, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(9usize); + f(skb, offset, from, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_l3_csum_replace( + skb: *mut __sk_buff, + offset: __u32, + from: __u64, + to: __u64, + size: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + offset: __u32, + from: __u64, + to: __u64, + size: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(10usize); + f(skb, offset, from, to, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_l4_csum_replace( + skb: *mut __sk_buff, + offset: __u32, + from: __u64, + to: __u64, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + offset: __u32, + from: __u64, + to: __u64, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(11usize); + f(skb, offset, from, to, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_tail_call( + ctx: *mut ::aya_bpf_cty::c_void, + prog_array_map: *mut ::aya_bpf_cty::c_void, + index: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + prog_array_map: *mut ::aya_bpf_cty::c_void, + index: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(12usize); + f(ctx, prog_array_map, index) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_clone_redirect( + skb: *mut __sk_buff, + ifindex: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + ifindex: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(13usize); + f(skb, ifindex, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_current_pid_tgid() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(14usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_current_uid_gid() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(15usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_current_comm( + buf: *mut ::aya_bpf_cty::c_void, + size_of_buf: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + buf: *mut ::aya_bpf_cty::c_void, + size_of_buf: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(16usize); + f(buf, size_of_buf) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_cgroup_classid(skb: *mut __sk_buff) -> __u32 { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> __u32 = ::core::mem::transmute(17usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_vlan_push( + skb: *mut __sk_buff, + vlan_proto: __be16, + vlan_tci: __u16, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + vlan_proto: __be16, + vlan_tci: __u16, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(18usize); + f(skb, vlan_proto, vlan_tci) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_vlan_pop(skb: *mut __sk_buff) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(19usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_get_tunnel_key( + skb: *mut __sk_buff, + key: *mut bpf_tunnel_key, + size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + key: *mut bpf_tunnel_key, + size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(20usize); + f(skb, key, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_set_tunnel_key( + skb: *mut __sk_buff, + key: *mut bpf_tunnel_key, + size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + key: *mut bpf_tunnel_key, + size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(21usize); + f(skb, key, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_perf_event_read( + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> __u64 { + let f: unsafe extern "C" fn(map: *mut ::aya_bpf_cty::c_void, flags: __u64) -> __u64 = + ::core::mem::transmute(22usize); + f(map, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_redirect(ifindex: __u32, flags: __u64) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(ifindex: __u32, flags: __u64) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(23usize); + f(ifindex, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_route_realm(skb: *mut __sk_buff) -> __u32 { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> __u32 = ::core::mem::transmute(24usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_perf_event_output( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(25usize); + f(ctx, map, flags, data, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_load_bytes( + skb: *const ::aya_bpf_cty::c_void, + offset: __u32, + to: *mut ::aya_bpf_cty::c_void, + len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *const ::aya_bpf_cty::c_void, + offset: __u32, + to: *mut ::aya_bpf_cty::c_void, + len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(26usize); + f(skb, offset, to, len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_stackid( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(27usize); + f(ctx, map, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_csum_diff( + from: *mut __be32, + from_size: __u32, + to: *mut __be32, + to_size: __u32, + seed: __wsum, +) -> __s64 { + let f: unsafe extern "C" fn( + from: *mut __be32, + from_size: __u32, + to: *mut __be32, + to_size: __u32, + seed: __wsum, + ) -> __s64 = ::core::mem::transmute(28usize); + f(from, from_size, to, to_size, seed) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_get_tunnel_opt( + skb: *mut __sk_buff, + opt: *mut ::aya_bpf_cty::c_void, + size: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + opt: *mut ::aya_bpf_cty::c_void, + size: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(29usize); + f(skb, opt, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_set_tunnel_opt( + skb: *mut __sk_buff, + opt: *mut ::aya_bpf_cty::c_void, + size: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + opt: *mut ::aya_bpf_cty::c_void, + size: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(30usize); + f(skb, opt, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_change_proto( + skb: *mut __sk_buff, + proto: __be16, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + proto: __be16, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(31usize); + f(skb, proto, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_change_type( + skb: *mut __sk_buff, + type_: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(skb: *mut __sk_buff, type_: __u32) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(32usize); + f(skb, type_) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_under_cgroup( + skb: *mut __sk_buff, + map: *mut ::aya_bpf_cty::c_void, + index: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + map: *mut ::aya_bpf_cty::c_void, + index: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(33usize); + f(skb, map, index) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_hash_recalc(skb: *mut __sk_buff) -> __u32 { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> __u32 = ::core::mem::transmute(34usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_current_task() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(35usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_probe_write_user( + dst: *mut ::aya_bpf_cty::c_void, + src: *const ::aya_bpf_cty::c_void, + len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + src: *const ::aya_bpf_cty::c_void, + len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(36usize); + f(dst, src, len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_current_task_under_cgroup( + map: *mut ::aya_bpf_cty::c_void, + index: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + index: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(37usize); + f(map, index) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_change_tail( + skb: *mut __sk_buff, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(38usize); + f(skb, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_pull_data( + skb: *mut __sk_buff, + len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(skb: *mut __sk_buff, len: __u32) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(39usize); + f(skb, len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_csum_update(skb: *mut __sk_buff, csum: __wsum) -> __s64 { + let f: unsafe extern "C" fn(skb: *mut __sk_buff, csum: __wsum) -> __s64 = + ::core::mem::transmute(40usize); + f(skb, csum) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_set_hash_invalid(skb: *mut __sk_buff) { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) = ::core::mem::transmute(41usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_numa_node_id() -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn() -> ::aya_bpf_cty::c_long = ::core::mem::transmute(42usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_change_head( + skb: *mut __sk_buff, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(43usize); + f(skb, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_xdp_adjust_head( + xdp_md: *mut xdp_md, + delta: ::aya_bpf_cty::c_int, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + xdp_md: *mut xdp_md, + delta: ::aya_bpf_cty::c_int, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(44usize); + f(xdp_md, delta) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_probe_read_str( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(45usize); + f(dst, size, unsafe_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_socket_cookie(ctx: *mut ::aya_bpf_cty::c_void) -> __u64 { + let f: unsafe extern "C" fn(ctx: *mut ::aya_bpf_cty::c_void) -> __u64 = + ::core::mem::transmute(46usize); + f(ctx) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_socket_uid(skb: *mut __sk_buff) -> __u32 { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> __u32 = ::core::mem::transmute(47usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_set_hash(skb: *mut __sk_buff, hash: __u32) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(skb: *mut __sk_buff, hash: __u32) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(48usize); + f(skb, hash) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_setsockopt( + bpf_socket: *mut ::aya_bpf_cty::c_void, + level: ::aya_bpf_cty::c_int, + optname: ::aya_bpf_cty::c_int, + optval: *mut ::aya_bpf_cty::c_void, + optlen: ::aya_bpf_cty::c_int, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + bpf_socket: *mut ::aya_bpf_cty::c_void, + level: ::aya_bpf_cty::c_int, + optname: ::aya_bpf_cty::c_int, + optval: *mut ::aya_bpf_cty::c_void, + optlen: ::aya_bpf_cty::c_int, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(49usize); + f(bpf_socket, level, optname, optval, optlen) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_adjust_room( + skb: *mut __sk_buff, + len_diff: __s32, + mode: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + len_diff: __s32, + mode: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(50usize); + f(skb, len_diff, mode, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_redirect_map( + map: *mut ::aya_bpf_cty::c_void, + key: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + key: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(51usize); + f(map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_redirect_map( + skb: *mut __sk_buff, + map: *mut ::aya_bpf_cty::c_void, + key: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + map: *mut ::aya_bpf_cty::c_void, + key: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(52usize); + f(skb, map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sock_map_update( + skops: *mut bpf_sock_ops, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skops: *mut bpf_sock_ops, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(53usize); + f(skops, map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_xdp_adjust_meta( + xdp_md: *mut xdp_md, + delta: ::aya_bpf_cty::c_int, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + xdp_md: *mut xdp_md, + delta: ::aya_bpf_cty::c_int, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(54usize); + f(xdp_md, delta) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_perf_event_read_value( + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + buf: *mut bpf_perf_event_value, + buf_size: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + buf: *mut bpf_perf_event_value, + buf_size: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(55usize); + f(map, flags, buf, buf_size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_perf_prog_read_value( + ctx: *mut bpf_perf_event_data, + buf: *mut bpf_perf_event_value, + buf_size: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut bpf_perf_event_data, + buf: *mut bpf_perf_event_value, + buf_size: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(56usize); + f(ctx, buf, buf_size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_getsockopt( + bpf_socket: *mut ::aya_bpf_cty::c_void, + level: ::aya_bpf_cty::c_int, + optname: ::aya_bpf_cty::c_int, + optval: *mut ::aya_bpf_cty::c_void, + optlen: ::aya_bpf_cty::c_int, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + bpf_socket: *mut ::aya_bpf_cty::c_void, + level: ::aya_bpf_cty::c_int, + optname: ::aya_bpf_cty::c_int, + optval: *mut ::aya_bpf_cty::c_void, + optlen: ::aya_bpf_cty::c_int, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(57usize); + f(bpf_socket, level, optname, optval, optlen) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_override_return( + regs: *mut pt_regs, + rc: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(regs: *mut pt_regs, rc: __u64) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(58usize); + f(regs, rc) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sock_ops_cb_flags_set( + bpf_sock: *mut bpf_sock_ops, + argval: ::aya_bpf_cty::c_int, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + bpf_sock: *mut bpf_sock_ops, + argval: ::aya_bpf_cty::c_int, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(59usize); + f(bpf_sock, argval) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_msg_redirect_map( + msg: *mut sk_msg_md, + map: *mut ::aya_bpf_cty::c_void, + key: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + msg: *mut sk_msg_md, + map: *mut ::aya_bpf_cty::c_void, + key: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(60usize); + f(msg, map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_msg_apply_bytes( + msg: *mut sk_msg_md, + bytes: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(msg: *mut sk_msg_md, bytes: __u32) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(61usize); + f(msg, bytes) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_msg_cork_bytes( + msg: *mut sk_msg_md, + bytes: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(msg: *mut sk_msg_md, bytes: __u32) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(62usize); + f(msg, bytes) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_msg_pull_data( + msg: *mut sk_msg_md, + start: __u32, + end: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + msg: *mut sk_msg_md, + start: __u32, + end: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(63usize); + f(msg, start, end, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_bind( + ctx: *mut bpf_sock_addr, + addr: *mut sockaddr, + addr_len: ::aya_bpf_cty::c_int, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut bpf_sock_addr, + addr: *mut sockaddr, + addr_len: ::aya_bpf_cty::c_int, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(64usize); + f(ctx, addr, addr_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_xdp_adjust_tail( + xdp_md: *mut xdp_md, + delta: ::aya_bpf_cty::c_int, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + xdp_md: *mut xdp_md, + delta: ::aya_bpf_cty::c_int, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(65usize); + f(xdp_md, delta) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_get_xfrm_state( + skb: *mut __sk_buff, + index: __u32, + xfrm_state: *mut bpf_xfrm_state, + size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + index: __u32, + xfrm_state: *mut bpf_xfrm_state, + size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(66usize); + f(skb, index, xfrm_state, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_stack( + ctx: *mut ::aya_bpf_cty::c_void, + buf: *mut ::aya_bpf_cty::c_void, + size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + buf: *mut ::aya_bpf_cty::c_void, + size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(67usize); + f(ctx, buf, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_load_bytes_relative( + skb: *const ::aya_bpf_cty::c_void, + offset: __u32, + to: *mut ::aya_bpf_cty::c_void, + len: __u32, + start_header: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *const ::aya_bpf_cty::c_void, + offset: __u32, + to: *mut ::aya_bpf_cty::c_void, + len: __u32, + start_header: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(68usize); + f(skb, offset, to, len, start_header) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_fib_lookup( + ctx: *mut ::aya_bpf_cty::c_void, + params: *mut bpf_fib_lookup, + plen: ::aya_bpf_cty::c_int, + flags: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + params: *mut bpf_fib_lookup, + plen: ::aya_bpf_cty::c_int, + flags: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(69usize); + f(ctx, params, plen, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sock_hash_update( + skops: *mut bpf_sock_ops, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skops: *mut bpf_sock_ops, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(70usize); + f(skops, map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_msg_redirect_hash( + msg: *mut sk_msg_md, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + msg: *mut sk_msg_md, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(71usize); + f(msg, map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_redirect_hash( + skb: *mut __sk_buff, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(72usize); + f(skb, map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_lwt_push_encap( + skb: *mut __sk_buff, + type_: __u32, + hdr: *mut ::aya_bpf_cty::c_void, + len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + type_: __u32, + hdr: *mut ::aya_bpf_cty::c_void, + len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(73usize); + f(skb, type_, hdr, len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_lwt_seg6_store_bytes( + skb: *mut __sk_buff, + offset: __u32, + from: *const ::aya_bpf_cty::c_void, + len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + offset: __u32, + from: *const ::aya_bpf_cty::c_void, + len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(74usize); + f(skb, offset, from, len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_lwt_seg6_adjust_srh( + skb: *mut __sk_buff, + offset: __u32, + delta: __s32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + offset: __u32, + delta: __s32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(75usize); + f(skb, offset, delta) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_lwt_seg6_action( + skb: *mut __sk_buff, + action: __u32, + param: *mut ::aya_bpf_cty::c_void, + param_len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + action: __u32, + param: *mut ::aya_bpf_cty::c_void, + param_len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(76usize); + f(skb, action, param, param_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_rc_repeat(ctx: *mut ::aya_bpf_cty::c_void) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(ctx: *mut ::aya_bpf_cty::c_void) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(77usize); + f(ctx) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_rc_keydown( + ctx: *mut ::aya_bpf_cty::c_void, + protocol: __u32, + scancode: __u64, + toggle: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + protocol: __u32, + scancode: __u64, + toggle: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(78usize); + f(ctx, protocol, scancode, toggle) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_cgroup_id(skb: *mut __sk_buff) -> __u64 { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> __u64 = ::core::mem::transmute(79usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_current_cgroup_id() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(80usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_local_storage( + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(81usize); + f(map, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_select_reuseport( + reuse: *mut sk_reuseport_md, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + reuse: *mut sk_reuseport_md, + map: *mut ::aya_bpf_cty::c_void, + key: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(82usize); + f(reuse, map, key, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_ancestor_cgroup_id( + skb: *mut __sk_buff, + ancestor_level: ::aya_bpf_cty::c_int, +) -> __u64 { + let f: unsafe extern "C" fn( + skb: *mut __sk_buff, + ancestor_level: ::aya_bpf_cty::c_int, + ) -> __u64 = ::core::mem::transmute(83usize); + f(skb, ancestor_level) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_lookup_tcp( + ctx: *mut ::aya_bpf_cty::c_void, + tuple: *mut bpf_sock_tuple, + tuple_size: __u32, + netns: __u64, + flags: __u64, +) -> *mut bpf_sock { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + tuple: *mut bpf_sock_tuple, + tuple_size: __u32, + netns: __u64, + flags: __u64, + ) -> *mut bpf_sock = ::core::mem::transmute(84usize); + f(ctx, tuple, tuple_size, netns, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_lookup_udp( + ctx: *mut ::aya_bpf_cty::c_void, + tuple: *mut bpf_sock_tuple, + tuple_size: __u32, + netns: __u64, + flags: __u64, +) -> *mut bpf_sock { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + tuple: *mut bpf_sock_tuple, + tuple_size: __u32, + netns: __u64, + flags: __u64, + ) -> *mut bpf_sock = ::core::mem::transmute(85usize); + f(ctx, tuple, tuple_size, netns, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_release(sock: *mut ::aya_bpf_cty::c_void) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(sock: *mut ::aya_bpf_cty::c_void) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(86usize); + f(sock) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_map_push_elem( + map: *mut ::aya_bpf_cty::c_void, + value: *const ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + value: *const ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(87usize); + f(map, value, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_map_pop_elem( + map: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(88usize); + f(map, value) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_map_peek_elem( + map: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(89usize); + f(map, value) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_msg_push_data( + msg: *mut sk_msg_md, + start: __u32, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + msg: *mut sk_msg_md, + start: __u32, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(90usize); + f(msg, start, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_msg_pop_data( + msg: *mut sk_msg_md, + start: __u32, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + msg: *mut sk_msg_md, + start: __u32, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(91usize); + f(msg, start, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_rc_pointer_rel( + ctx: *mut ::aya_bpf_cty::c_void, + rel_x: __s32, + rel_y: __s32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + rel_x: __s32, + rel_y: __s32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(92usize); + f(ctx, rel_x, rel_y) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_spin_lock(lock: *mut bpf_spin_lock) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(lock: *mut bpf_spin_lock) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(93usize); + f(lock) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_spin_unlock(lock: *mut bpf_spin_lock) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(lock: *mut bpf_spin_lock) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(94usize); + f(lock) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_fullsock(sk: *mut bpf_sock) -> *mut bpf_sock { + let f: unsafe extern "C" fn(sk: *mut bpf_sock) -> *mut bpf_sock = + ::core::mem::transmute(95usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_tcp_sock(sk: *mut bpf_sock) -> *mut bpf_tcp_sock { + let f: unsafe extern "C" fn(sk: *mut bpf_sock) -> *mut bpf_tcp_sock = + ::core::mem::transmute(96usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_ecn_set_ce(skb: *mut __sk_buff) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(97usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_listener_sock(sk: *mut bpf_sock) -> *mut bpf_sock { + let f: unsafe extern "C" fn(sk: *mut bpf_sock) -> *mut bpf_sock = + ::core::mem::transmute(98usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skc_lookup_tcp( + ctx: *mut ::aya_bpf_cty::c_void, + tuple: *mut bpf_sock_tuple, + tuple_size: __u32, + netns: __u64, + flags: __u64, +) -> *mut bpf_sock { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + tuple: *mut bpf_sock_tuple, + tuple_size: __u32, + netns: __u64, + flags: __u64, + ) -> *mut bpf_sock = ::core::mem::transmute(99usize); + f(ctx, tuple, tuple_size, netns, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_tcp_check_syncookie( + sk: *mut ::aya_bpf_cty::c_void, + iph: *mut ::aya_bpf_cty::c_void, + iph_len: __u32, + th: *mut tcphdr, + th_len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + sk: *mut ::aya_bpf_cty::c_void, + iph: *mut ::aya_bpf_cty::c_void, + iph_len: __u32, + th: *mut tcphdr, + th_len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(100usize); + f(sk, iph, iph_len, th, th_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sysctl_get_name( + ctx: *mut bpf_sysctl, + buf: *mut ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut bpf_sysctl, + buf: *mut ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(101usize); + f(ctx, buf, buf_len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sysctl_get_current_value( + ctx: *mut bpf_sysctl, + buf: *mut ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut bpf_sysctl, + buf: *mut ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(102usize); + f(ctx, buf, buf_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sysctl_get_new_value( + ctx: *mut bpf_sysctl, + buf: *mut ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut bpf_sysctl, + buf: *mut ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(103usize); + f(ctx, buf, buf_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sysctl_set_new_value( + ctx: *mut bpf_sysctl, + buf: *const ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut bpf_sysctl, + buf: *const ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(104usize); + f(ctx, buf, buf_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_strtol( + buf: *const ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + flags: __u64, + res: *mut ::aya_bpf_cty::c_long, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + buf: *const ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + flags: __u64, + res: *mut ::aya_bpf_cty::c_long, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(105usize); + f(buf, buf_len, flags, res) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_strtoul( + buf: *const ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + flags: __u64, + res: *mut ::aya_bpf_cty::c_ulong, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + buf: *const ::aya_bpf_cty::c_char, + buf_len: ::aya_bpf_cty::c_ulong, + flags: __u64, + res: *mut ::aya_bpf_cty::c_ulong, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(106usize); + f(buf, buf_len, flags, res) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_storage_get( + map: *mut ::aya_bpf_cty::c_void, + sk: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + sk: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(107usize); + f(map, sk, value, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_storage_delete( + map: *mut ::aya_bpf_cty::c_void, + sk: *mut ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + sk: *mut ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(108usize); + f(map, sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_send_signal(sig: __u32) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(sig: __u32) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(109usize); + f(sig) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_tcp_gen_syncookie( + sk: *mut ::aya_bpf_cty::c_void, + iph: *mut ::aya_bpf_cty::c_void, + iph_len: __u32, + th: *mut tcphdr, + th_len: __u32, +) -> __s64 { + let f: unsafe extern "C" fn( + sk: *mut ::aya_bpf_cty::c_void, + iph: *mut ::aya_bpf_cty::c_void, + iph_len: __u32, + th: *mut tcphdr, + th_len: __u32, + ) -> __s64 = ::core::mem::transmute(110usize); + f(sk, iph, iph_len, th, th_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_output( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(111usize); + f(ctx, map, flags, data, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_probe_read_user( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(112usize); + f(dst, size, unsafe_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_probe_read_kernel( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(113usize); + f(dst, size, unsafe_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_probe_read_user_str( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(114usize); + f(dst, size, unsafe_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_probe_read_kernel_str( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + unsafe_ptr: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(115usize); + f(dst, size, unsafe_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_tcp_send_ack( + tp: *mut ::aya_bpf_cty::c_void, + rcv_nxt: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + tp: *mut ::aya_bpf_cty::c_void, + rcv_nxt: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(116usize); + f(tp, rcv_nxt) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_send_signal_thread(sig: __u32) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(sig: __u32) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(117usize); + f(sig) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_jiffies64() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(118usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_read_branch_records( + ctx: *mut bpf_perf_event_data, + buf: *mut ::aya_bpf_cty::c_void, + size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut bpf_perf_event_data, + buf: *mut ::aya_bpf_cty::c_void, + size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(119usize); + f(ctx, buf, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_ns_current_pid_tgid( + dev: __u64, + ino: __u64, + nsdata: *mut bpf_pidns_info, + size: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dev: __u64, + ino: __u64, + nsdata: *mut bpf_pidns_info, + size: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(120usize); + f(dev, ino, nsdata, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_xdp_output( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + map: *mut ::aya_bpf_cty::c_void, + flags: __u64, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(121usize); + f(ctx, map, flags, data, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_netns_cookie(ctx: *mut ::aya_bpf_cty::c_void) -> __u64 { + let f: unsafe extern "C" fn(ctx: *mut ::aya_bpf_cty::c_void) -> __u64 = + ::core::mem::transmute(122usize); + f(ctx) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_current_ancestor_cgroup_id( + ancestor_level: ::aya_bpf_cty::c_int, +) -> __u64 { + let f: unsafe extern "C" fn(ancestor_level: ::aya_bpf_cty::c_int) -> __u64 = + ::core::mem::transmute(123usize); + f(ancestor_level) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_assign( + ctx: *mut ::aya_bpf_cty::c_void, + sk: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ctx: *mut ::aya_bpf_cty::c_void, + sk: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(124usize); + f(ctx, sk, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ktime_get_boot_ns() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(125usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_seq_printf( + m: *mut seq_file, + fmt: *const ::aya_bpf_cty::c_char, + fmt_size: __u32, + data: *const ::aya_bpf_cty::c_void, + data_len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + m: *mut seq_file, + fmt: *const ::aya_bpf_cty::c_char, + fmt_size: __u32, + data: *const ::aya_bpf_cty::c_void, + data_len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(126usize); + f(m, fmt, fmt_size, data, data_len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_seq_write( + m: *mut seq_file, + data: *const ::aya_bpf_cty::c_void, + len: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + m: *mut seq_file, + data: *const ::aya_bpf_cty::c_void, + len: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(127usize); + f(m, data, len) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_cgroup_id(sk: *mut ::aya_bpf_cty::c_void) -> __u64 { + let f: unsafe extern "C" fn(sk: *mut ::aya_bpf_cty::c_void) -> __u64 = + ::core::mem::transmute(128usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sk_ancestor_cgroup_id( + sk: *mut ::aya_bpf_cty::c_void, + ancestor_level: ::aya_bpf_cty::c_int, +) -> __u64 { + let f: unsafe extern "C" fn( + sk: *mut ::aya_bpf_cty::c_void, + ancestor_level: ::aya_bpf_cty::c_int, + ) -> __u64 = ::core::mem::transmute(129usize); + f(sk, ancestor_level) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ringbuf_output( + ringbuf: *mut ::aya_bpf_cty::c_void, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ringbuf: *mut ::aya_bpf_cty::c_void, + data: *mut ::aya_bpf_cty::c_void, + size: __u64, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(130usize); + f(ringbuf, data, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ringbuf_reserve( + ringbuf: *mut ::aya_bpf_cty::c_void, + size: __u64, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + ringbuf: *mut ::aya_bpf_cty::c_void, + size: __u64, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(131usize); + f(ringbuf, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ringbuf_submit(data: *mut ::aya_bpf_cty::c_void, flags: __u64) { + let f: unsafe extern "C" fn(data: *mut ::aya_bpf_cty::c_void, flags: __u64) = + ::core::mem::transmute(132usize); + f(data, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ringbuf_discard(data: *mut ::aya_bpf_cty::c_void, flags: __u64) { + let f: unsafe extern "C" fn(data: *mut ::aya_bpf_cty::c_void, flags: __u64) = + ::core::mem::transmute(133usize); + f(data, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ringbuf_query( + ringbuf: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> __u64 { + let f: unsafe extern "C" fn(ringbuf: *mut ::aya_bpf_cty::c_void, flags: __u64) -> __u64 = + ::core::mem::transmute(134usize); + f(ringbuf, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_csum_level( + skb: *mut __sk_buff, + level: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(skb: *mut __sk_buff, level: __u64) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(135usize); + f(skb, level) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skc_to_tcp6_sock(sk: *mut ::aya_bpf_cty::c_void) -> *mut tcp6_sock { + let f: unsafe extern "C" fn(sk: *mut ::aya_bpf_cty::c_void) -> *mut tcp6_sock = + ::core::mem::transmute(136usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skc_to_tcp_sock(sk: *mut ::aya_bpf_cty::c_void) -> *mut tcp_sock { + let f: unsafe extern "C" fn(sk: *mut ::aya_bpf_cty::c_void) -> *mut tcp_sock = + ::core::mem::transmute(137usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skc_to_tcp_timewait_sock( + sk: *mut ::aya_bpf_cty::c_void, +) -> *mut tcp_timewait_sock { + let f: unsafe extern "C" fn(sk: *mut ::aya_bpf_cty::c_void) -> *mut tcp_timewait_sock = + ::core::mem::transmute(138usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skc_to_tcp_request_sock( + sk: *mut ::aya_bpf_cty::c_void, +) -> *mut tcp_request_sock { + let f: unsafe extern "C" fn(sk: *mut ::aya_bpf_cty::c_void) -> *mut tcp_request_sock = + ::core::mem::transmute(139usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skc_to_udp6_sock(sk: *mut ::aya_bpf_cty::c_void) -> *mut udp6_sock { + let f: unsafe extern "C" fn(sk: *mut ::aya_bpf_cty::c_void) -> *mut udp6_sock = + ::core::mem::transmute(140usize); + f(sk) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_task_stack( + task: *mut task_struct, + buf: *mut ::aya_bpf_cty::c_void, + size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + task: *mut task_struct, + buf: *mut ::aya_bpf_cty::c_void, + size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(141usize); + f(task, buf, size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_load_hdr_opt( + skops: *mut bpf_sock_ops, + searchby_res: *mut ::aya_bpf_cty::c_void, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skops: *mut bpf_sock_ops, + searchby_res: *mut ::aya_bpf_cty::c_void, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(142usize); + f(skops, searchby_res, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_store_hdr_opt( + skops: *mut bpf_sock_ops, + from: *const ::aya_bpf_cty::c_void, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skops: *mut bpf_sock_ops, + from: *const ::aya_bpf_cty::c_void, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(143usize); + f(skops, from, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_reserve_hdr_opt( + skops: *mut bpf_sock_ops, + len: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + skops: *mut bpf_sock_ops, + len: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(144usize); + f(skops, len, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_inode_storage_get( + map: *mut ::aya_bpf_cty::c_void, + inode: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + inode: *mut ::aya_bpf_cty::c_void, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(145usize); + f(map, inode, value, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_inode_storage_delete( + map: *mut ::aya_bpf_cty::c_void, + inode: *mut ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_int { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + inode: *mut ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_int = ::core::mem::transmute(146usize); + f(map, inode) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_d_path( + path: *mut path, + buf: *mut ::aya_bpf_cty::c_char, + sz: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + path: *mut path, + buf: *mut ::aya_bpf_cty::c_char, + sz: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(147usize); + f(path, buf, sz) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_copy_from_user( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + user_ptr: *const ::aya_bpf_cty::c_void, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + user_ptr: *const ::aya_bpf_cty::c_void, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(148usize); + f(dst, size, user_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_snprintf_btf( + str_: *mut ::aya_bpf_cty::c_char, + str_size: __u32, + ptr: *mut btf_ptr, + btf_ptr_size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + str_: *mut ::aya_bpf_cty::c_char, + str_size: __u32, + ptr: *mut btf_ptr, + btf_ptr_size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(149usize); + f(str_, str_size, ptr, btf_ptr_size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_seq_printf_btf( + m: *mut seq_file, + ptr: *mut btf_ptr, + ptr_size: __u32, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + m: *mut seq_file, + ptr: *mut btf_ptr, + ptr_size: __u32, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(150usize); + f(m, ptr, ptr_size, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_skb_cgroup_classid(skb: *mut __sk_buff) -> __u64 { + let f: unsafe extern "C" fn(skb: *mut __sk_buff) -> __u64 = ::core::mem::transmute(151usize); + f(skb) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_redirect_neigh( + ifindex: __u32, + params: *mut bpf_redir_neigh, + plen: ::aya_bpf_cty::c_int, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + ifindex: __u32, + params: *mut bpf_redir_neigh, + plen: ::aya_bpf_cty::c_int, + flags: __u64, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(152usize); + f(ifindex, params, plen, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_per_cpu_ptr( + percpu_ptr: *const ::aya_bpf_cty::c_void, + cpu: __u32, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + percpu_ptr: *const ::aya_bpf_cty::c_void, + cpu: __u32, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(153usize); + f(percpu_ptr, cpu) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_this_cpu_ptr( + percpu_ptr: *const ::aya_bpf_cty::c_void, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + percpu_ptr: *const ::aya_bpf_cty::c_void, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(154usize); + f(percpu_ptr) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_redirect_peer(ifindex: __u32, flags: __u64) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(ifindex: __u32, flags: __u64) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(155usize); + f(ifindex, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_task_storage_get( + map: *mut ::aya_bpf_cty::c_void, + task: *mut task_struct, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, +) -> *mut ::aya_bpf_cty::c_void { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + task: *mut task_struct, + value: *mut ::aya_bpf_cty::c_void, + flags: __u64, + ) -> *mut ::aya_bpf_cty::c_void = ::core::mem::transmute(156usize); + f(map, task, value, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_task_storage_delete( + map: *mut ::aya_bpf_cty::c_void, + task: *mut task_struct, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + map: *mut ::aya_bpf_cty::c_void, + task: *mut task_struct, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(157usize); + f(map, task) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_get_current_task_btf() -> *mut task_struct { + let f: unsafe extern "C" fn() -> *mut task_struct = ::core::mem::transmute(158usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_bprm_opts_set( + bprm: *mut linux_binprm, + flags: __u64, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn(bprm: *mut linux_binprm, flags: __u64) -> ::aya_bpf_cty::c_long = + ::core::mem::transmute(159usize); + f(bprm, flags) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ktime_get_coarse_ns() -> __u64 { + let f: unsafe extern "C" fn() -> __u64 = ::core::mem::transmute(160usize); + f() +} +#[inline(always)] +pub unsafe extern "C" fn bpf_ima_inode_hash( + inode: *mut inode, + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, +) -> ::aya_bpf_cty::c_long { + let f: unsafe extern "C" fn( + inode: *mut inode, + dst: *mut ::aya_bpf_cty::c_void, + size: __u32, + ) -> ::aya_bpf_cty::c_long = ::core::mem::transmute(161usize); + f(inode, dst, size) +} +#[inline(always)] +pub unsafe extern "C" fn bpf_sock_from_file(file: *mut file) -> *mut socket { + let f: unsafe extern "C" fn(file: *mut file) -> *mut socket = ::core::mem::transmute(162usize); + f(file) +} diff --git a/bpf/aya-bpf/src/bpf/generated/mod.rs b/bpf/aya-bpf/src/bpf/generated/mod.rs new file mode 100644 index 00000000..9b4baebc --- /dev/null +++ b/bpf/aya-bpf/src/bpf/generated/mod.rs @@ -0,0 +1,4 @@ +#![allow(dead_code, non_camel_case_types, non_snake_case)] + +pub(crate) mod bindings; +pub(crate) mod helpers; diff --git a/bpf/aya-bpf/src/bpf/helpers.rs b/bpf/aya-bpf/src/bpf/helpers.rs new file mode 100644 index 00000000..215c54af --- /dev/null +++ b/bpf/aya-bpf/src/bpf/helpers.rs @@ -0,0 +1,37 @@ +use core::mem::{self, MaybeUninit}; + +use crate::{ + bpf::generated::helpers as gen, + cty::{c_char, c_long, c_void}, +}; +pub use gen::*; + +#[inline] +pub unsafe fn bpf_probe_read(src: *const T) -> Result { + let mut v: MaybeUninit = MaybeUninit::uninit(); + let ret = gen::bpf_probe_read( + v.as_mut_ptr() as *mut c_void, + mem::size_of::() as u32, + src as *const c_void, + ); + if ret < 0 { + return Err(ret); + } + + Ok(v.assume_init()) +} + +#[inline] +pub fn bpf_get_current_comm() -> Result<[c_char; 16], ()> { + let mut comm: [c_char; 16usize] = [0; 16]; + if unsafe { gen::bpf_get_current_comm(&mut comm as *mut _ as *mut c_void, 16u32) } == 0 { + Ok(comm) + } else { + Err(()) + } +} + +#[inline] +pub fn bpf_get_current_pid_tgid() -> u64 { + unsafe { gen::bpf_get_current_pid_tgid() } +} diff --git a/bpf/aya-bpf/src/bpf/mod.rs b/bpf/aya-bpf/src/bpf/mod.rs new file mode 100644 index 00000000..5d5b140f --- /dev/null +++ b/bpf/aya-bpf/src/bpf/mod.rs @@ -0,0 +1,4 @@ +mod generated; + +pub mod helpers; +pub use generated::bindings::*; diff --git a/bpf/aya-bpf/src/lib.rs b/bpf/aya-bpf/src/lib.rs new file mode 100644 index 00000000..5ce68421 --- /dev/null +++ b/bpf/aya-bpf/src/lib.rs @@ -0,0 +1,34 @@ +#![no_std] + +pub mod bpf; +pub mod maps; +pub mod programs; + +pub use aya_bpf_cty as cty; + +use bpf::helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid}; +use core::ffi::c_void; +use cty::c_char; + +pub use aya_bpf_macros as macros; + +pub const TASK_COMM_LEN: usize = 16; + +pub trait BpfContext { + fn as_ptr(&self) -> *mut c_void; + + #[inline] + fn command(&self) -> Result<[c_char; TASK_COMM_LEN], ()> { + bpf_get_current_comm() + } + + #[inline] + fn pid(&self) -> u32 { + bpf_get_current_pid_tgid() as u32 + } + + #[inline] + fn tgid(&self) -> u32 { + (bpf_get_current_pid_tgid() >> 32) as u32 + } +} diff --git a/bpf/aya-bpf/src/maps/mod.rs b/bpf/aya-bpf/src/maps/mod.rs new file mode 100644 index 00000000..6f4476fd --- /dev/null +++ b/bpf/aya-bpf/src/maps/mod.rs @@ -0,0 +1,3 @@ +pub mod perf_map; + +pub use perf_map::PerfMap; diff --git a/bpf/aya-bpf/src/maps/perf_map.rs b/bpf/aya-bpf/src/maps/perf_map.rs new file mode 100644 index 00000000..ef17cd6c --- /dev/null +++ b/bpf/aya-bpf/src/maps/perf_map.rs @@ -0,0 +1,58 @@ +use core::{marker::PhantomData, mem}; + +use crate::{ + bpf::{ + bpf_map_def, helpers::bpf_perf_event_output, BPF_F_CURRENT_CPU, + BPF_MAP_TYPE_PERF_EVENT_ARRAY, + }, + BpfContext, +}; + +#[repr(transparent)] +pub struct PerfMap { + def: bpf_map_def, + _t: PhantomData, +} + +impl PerfMap { + pub const fn new(flags: u32) -> PerfMap { + PerfMap::with_max_entries(0, flags) + } + + pub const fn with_max_entries(max_entries: u32, flags: u32) -> PerfMap { + PerfMap { + def: bpf_map_def { + type_: BPF_MAP_TYPE_PERF_EVENT_ARRAY, + key_size: mem::size_of::() as u32, + value_size: mem::size_of::() as u32, + max_entries, + map_flags: flags, + }, + _t: PhantomData, + } + } + + pub fn output(&mut self, ctx: &C, data: &T) { + self.output_at_index(ctx, None, data, 0) + } + + pub fn output_at_index( + &mut self, + ctx: &C, + index: Option, + data: &T, + flags: u32, + ) { + let index = index.map(|i| (i as u64) << 32).unwrap_or(BPF_F_CURRENT_CPU); + let flags = index | flags as u64; + unsafe { + bpf_perf_event_output( + ctx.as_ptr(), + &mut self.def as *mut _ as *mut _, + flags, + data as *const _ as *mut _, + mem::size_of::() as u64, + ); + } + } +} diff --git a/bpf/aya-bpf/src/programs/mod.rs b/bpf/aya-bpf/src/programs/mod.rs new file mode 100644 index 00000000..16678065 --- /dev/null +++ b/bpf/aya-bpf/src/programs/mod.rs @@ -0,0 +1,3 @@ +pub mod probe; + +pub use probe::ProbeContext; diff --git a/bpf/aya-bpf/src/programs/probe.rs b/bpf/aya-bpf/src/programs/probe.rs new file mode 100644 index 00000000..8f9e45cd --- /dev/null +++ b/bpf/aya-bpf/src/programs/probe.rs @@ -0,0 +1,21 @@ +use core::ffi::c_void; + +use crate::{bpf::pt_regs, BpfContext}; + +pub struct ProbeContext { + regs: *mut pt_regs, +} + +impl ProbeContext { + pub fn new(ctx: *mut c_void) -> ProbeContext { + ProbeContext { + regs: ctx as *mut pt_regs, + } + } +} + +impl BpfContext for ProbeContext { + fn as_ptr(&self) -> *mut c_void { + self.regs as *mut c_void + } +} diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml new file mode 100644 index 00000000..a6937ea8 --- /dev/null +++ b/xtask/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "xtask" +version = "0.1.0" +authors = ["Alessandro Decina "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +structopt = {version = "0.3", default-features = false } +anyhow = "1" +syn = {version = "1", features = ["visit-mut"] } +quote = "1" +proc-macro2 = "1" \ No newline at end of file diff --git a/xtask/src/codegen/aya_bpf.rs b/xtask/src/codegen/aya_bpf.rs new file mode 100644 index 00000000..b7c5d3d9 --- /dev/null +++ b/xtask/src/codegen/aya_bpf.rs @@ -0,0 +1,140 @@ +use std::{fs::File, io::Write, path::PathBuf, process::Command}; + +use anyhow::anyhow; +use proc_macro2::TokenStream; +use quote::{quote, ToTokens}; +use structopt::StructOpt; +use syn::{ + self, parse_str, + punctuated::Punctuated, + token::Comma, + visit_mut::{self, VisitMut}, + AngleBracketedGenericArguments, ForeignItemStatic, GenericArgument, Ident, Item, + PathArguments::AngleBracketed, + Type, +}; + +#[derive(StructOpt)] +pub struct CodegenOptions { + #[structopt(long)] + libbpf_dir: PathBuf, +} + +pub fn codegen(opts: CodegenOptions) -> Result<(), anyhow::Error> { + let dir = PathBuf::from("bpf/aya-bpf"); + let generated = dir.join("src/bpf/generated"); + + let types: Vec<&str> = vec!["bpf_map_.*"]; + let vars = vec!["BPF_.*", "bpf_.*"]; + let mut cmd = Command::new("bindgen"); + cmd.arg("--no-layout-tests") + .arg("--use-core") + .arg("--ctypes-prefix") + .arg("::aya_bpf_cty") + .arg("--default-enum-style") + .arg("consts") + .arg("--no-prepend-enum-name") + .arg(&*dir.join("include/aya_bpf_bindings.h").to_string_lossy()); + + for x in types { + cmd.arg("--whitelist-type").arg(x); + } + + for x in vars { + cmd.arg("--whitelist-var").arg(x); + } + + cmd.arg("--"); + cmd.arg("-I").arg(opts.libbpf_dir.join("src")); + + let output = cmd.output()?; + let bindings = std::str::from_utf8(&output.stdout)?; + + if !output.status.success() { + eprintln!("{}", std::str::from_utf8(&output.stderr)?); + return Err(anyhow!("bindgen failed: {}", output.status)); + } + + // delete the helpers, then rewrite them in helpers.rs + let mut tree = parse_str::(bindings).unwrap(); + let mut tx = RewriteBpfHelpers { + helpers: Vec::new(), + }; + tx.visit_file_mut(&mut tree); + + let filename = generated.join("bindings.rs"); + { + let mut file = File::create(&filename)?; + write!(file, "{}", tree.to_token_stream())?; + } + Command::new("rustfmt").arg(filename).status()?; + + let filename = generated.join("helpers.rs"); + { + let mut file = File::create(&filename)?; + write!(file, "use crate::bpf::generated::bindings::*;")?; + for helper in &tx.helpers { + file.write(helper.as_bytes())?; + } + } + Command::new("rustfmt").arg(filename).status()?; + + Ok(()) +} + +struct RewriteBpfHelpers { + helpers: Vec, +} + +impl VisitMut for RewriteBpfHelpers { + fn visit_item_mut(&mut self, item: &mut Item) { + visit_mut::visit_item_mut(self, item); + if let Item::ForeignMod(_) = item { + *item = Item::Verbatim(TokenStream::new()) + } + } + fn visit_foreign_item_static_mut(&mut self, static_item: &mut ForeignItemStatic) { + if let Type::Path(path) = &*static_item.ty { + let ident = &static_item.ident; + let ident_str = ident.to_string(); + let last = path.path.segments.last().unwrap(); + let ty_ident = last.ident.to_string(); + if ident_str.starts_with("bpf_") && ty_ident == "Option" { + let fn_ty = match &last.arguments { + AngleBracketed(AngleBracketedGenericArguments { args, .. }) => { + args.first().unwrap() + } + _ => panic!(), + }; + let mut ty_s = quote! { + #[inline(always)] + pub #fn_ty + } + .to_string(); + ty_s = ty_s.replace("fn (", &format!("fn {} (", ident_str)); + let call_idx = self.helpers.len() + 1; + let args: Punctuated = match fn_ty { + GenericArgument::Type(Type::BareFn(f)) => f + .inputs + .iter() + .map(|arg| arg.name.clone().unwrap().0) + .collect(), + _ => unreachable!(), + }; + let body = quote! { + { + let f: #fn_ty = ::core::mem::transmute(#call_idx); + f(#args) + } + } + .to_string(); + ty_s.push_str(&body); + let mut helper = ty_s; + if helper.contains("printk") { + helper = format!("/* {} */", helper); + } + self.helpers.push(helper); + } + } + } +} diff --git a/xtask/src/codegen/mod.rs b/xtask/src/codegen/mod.rs new file mode 100644 index 00000000..925f8b2e --- /dev/null +++ b/xtask/src/codegen/mod.rs @@ -0,0 +1,22 @@ +mod aya_bpf; + +use structopt::StructOpt; + +#[derive(StructOpt)] +pub struct Options { + #[structopt(subcommand)] + command: Command, +} + +#[derive(StructOpt)] +enum Command { + #[structopt(name = "aya-bpf")] + AyaBpf(aya_bpf::CodegenOptions), +} + +pub fn codegen(opts: Options) -> Result<(), anyhow::Error> { + use Command::*; + match opts.command { + AyaBpf(opts) => aya_bpf::codegen(opts), + } +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs new file mode 100644 index 00000000..14a923a5 --- /dev/null +++ b/xtask/src/main.rs @@ -0,0 +1,29 @@ +mod codegen; + +use std::process::exit; + +use structopt::StructOpt; +#[derive(StructOpt)] +pub struct Options { + #[structopt(subcommand)] + command: Command, +} + +#[derive(StructOpt)] +enum Command { + Codegen(codegen::Options), +} + +fn main() { + let opts = Options::from_args(); + + use Command::*; + let ret = match opts.command { + Codegen(opts) => codegen::codegen(opts), + }; + + if let Err(e) = ret { + eprintln!("{:#}", e); + exit(1); + } +}