Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/book/programs/probes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ For this demo program, we are going to rely on aya-log to print IP addresses fro
- We call `bpf_probe_read_kernel` helper to copy the `struct sock_common __sk_common` portion of the socket structure. (For uprobe programs, we would need to call `bpf_probe_read_user` instead.)
- We match the `skc_family` field, and for `AF_INET` (IPv4) and `AF_INET6` (IPv6) values, extract and print the src and destination addresses using aya-log `info!` macro.

Before we write eBPF code in Rust, we need to generate the BTF bindings for Rust:

```rust linenums="1" title="kprobetcp/xtask/src/codegen.rs"
--8<-- "examples/kprobetcp/xtask/src/codegen.rs"
```

Generate the code by:
```console
$ cargo xtask codegen
```

Here's how the eBPF code looks like:

```rust linenums="1" title="kprobetcp-ebpf/src/main.rs"
Expand Down
187 changes: 184 additions & 3 deletions examples/kprobetcp/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading