Commit Graph

902 Commits (27f22f205d7f04e69372eda370bb7b436cb87445)
 

Author SHA1 Message Date
Dan Everton fc0861105a
fix: make maps compatible with kernel <= 4.14
In kernel 4.15 and additional parameter was added to allow maps to have
names but using this breaks on older kernels.

This change makes it so the name is only added on kernels 4.15 and
newer.
3 years ago
Alessandro Decina 182182d840 (cargo-release) version 0.10.6 3 years ago
Alessandro Decina 170e98e71e bpf: fix doc tests 3 years ago
Alessandro Decina 31f96450d4 bpf: add bpf_probe_read_buf, bpf_probe_read_user_buf and bpf_probe_read_kernel_buf 3 years ago
Alessandro Decina f1fe817022
Merge pull request #106 from dave-tucker/skbcontext
bpf: Rename SkSkbContext to SkBuffContext
3 years ago
Dave Tucker 8a6fe4a640 bpf: Rename SkSkbContext to SkBuffContext
This is necessary since the context is used in many other program types
and not just in SK_SKB programs.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 685b68359e
Merge pull request #105 from dave-tucker/socket_filter
bpf: Add macro for socket_filter programs
3 years ago
Dave Tucker a4bb29a3cc bpf: Add macro for socket_filter programs
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 5ea450f0ec
Merge pull request #102 from dave-tucker/skskb
bpf: Add macros for sk_skb programs
3 years ago
Alessandro Decina 0b3e398f11
Merge pull request #103 from dave-tucker/redirect_sk
bpf: Implement redirect for skbs on sockmap/sockhash
3 years ago
Alessandro Decina daf8630133
Merge pull request #104 from dave-tucker/fix_skskb_load
obj: fix name parsing for sk_skb sections
3 years ago
Dave Tucker 352e54b724 obj: fix name parsing for sk_skb sections
This commit fixes name parsing of sk_skb sections such that both named
and unnamed variants will work correctly.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 2a8ba55b7e bpf: Implement redirect for skbs on sockmap/sockhash
This implements redirect_skb and renames redirect to redirect_msg

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 0c7e9b94ea bpf: Add macros for sk_skb programs
This commit adds the stream_parser and stream_verdict macros for use in
bpf programs

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 2206fb6456
Merge pull request #83 from willfindlay/arguments
aya-bpf: introduce argument coercion
3 years ago
William Findlay 89dee1a114
aya-bpf: implement argument coercion for pt_regs and BTF programs
Implements argument and return value coercion helpers for:
    - LSM programs
    - BTF tracepoints
    - [ku]{ret}probes

Signed-off-by: William Findlay <william@williamfindlay.com>
3 years ago
William Findlay 972e5e636a
aya-bpf-macros: fix tests
Doctests were failing due to a dependency on the aya-bpf crate.
3 years ago
Alessandro Decina f632f81db1
Merge pull request #98 from aya-rs/codegen
Update libbpf to 16dfb4ffe4aed03fafc00e0557b1ce1310a09731
3 years ago
alessandrod 4a7f47d93a Update libbpf to 16dfb4ffe4aed03fafc00e0557b1ce1310a09731 3 years ago
Alessandro Decina d341b58293 xtask: codegen: generate bindings for user_pt_regs
user_pt_regs is used in aarch64 instead of pt_regs
3 years ago
Alessandro Decina ab0d08910d ci: gen: fix workflow 3 years ago
Alessandro Decina 8f20ead0c1
Merge pull request #96 from alessandrod/cross
Fix bindings for archs other than x86
3 years ago
Alessandro Decina f372a4cd5f ci: gen: install cross headers 3 years ago
Alessandro Decina eb654d1e3e xtask: codegen: fix bindings for archs other than x86 3 years ago
Alessandro Decina 3d72414fde
Merge pull request #86 from willfindlay/bpf_probe_read_str
aya-bpf/helpers: add documentation and implement more bpf_probe_read_* wrappers
3 years ago
William Findlay 4a02d0038f
aya-bpf/helpers: add documentation and implement all bpf_probe_read_* wrappers
This patch adds some documentation to aya-bpf/helpers and adds documentation
for the module itself and for all of the wrappers currently defined in the module.

It also implements the rest of the bpf_probe_read_* wrappers that were missing from this
file. In the future, it probably also makes sense to add some bpf_probe_read_* wrappers
that can read directly into a map pointer, avoiding the BPF stack altogether. I'm going to
call this out of scope for this PR, but plan to submit a subsequent one that addresses
this use case.

Signed-off-by: William Findlay <william@williamfindlay.com>
3 years ago
Alessandro Decina 3eb0fe3257
Merge pull request #92 from willfindlay/expose_bindings
aya-bpf/helpers: expose raw bindings through helpers::gen
3 years ago
Alessandro Decina 563d4ba1c3
Merge pull request #94 from tklauser/netlink-ext-ack-libc
aya: netlink: use NETLINK_EXT_ACK from libc crate
3 years ago
Tobias Klauser 2136f05461 aya: netlink: use NETLINK_EXT_ACK from libc crate
NETLINK_EXT_ACK is available since libc crate version 0.2.105, see
https://github.com/rust-lang/libc/releases/tag/0.2.105
3 years ago
William Findlay b30fd424ef
aya-bpf/helpers: expose raw bindings through helpers::gen
Until we add another set of bpf_probe_read_* wrappers for reading into a map pointer,
users need access to the underlying bpf_probe_read helper, which is clobbered by this
module. This patch enables direct access to the underlying helpers::gen module to support
such use cases.

In my view, it would also probably make sense to just not export helpers::gen::* and force
the user to opt into helpers::gen, but this can be decided on later.

Signed-off-by: William Findlay <william@williamfindlay.com>
3 years ago
Alessandro Decina dd7e1de348
Merge pull request #90 from willfindlay/fix-bss
aya/obj: fix incorrect section size for .bss
3 years ago
William Findlay 1e6b1afbe4
aya/obj: fix incorrect section size for .bss 3 years ago
Alessandro Decina 3a8e4fe9b9
Merge pull request #89 from willfindlay/errors
aya/maps: improve map errors to be more descriptive
3 years ago
William Findlay 27d803b634
aya/maps: improve map errors to be more descriptive 3 years ago
Alessandro Decina 17b730c717
Merge pull request #85 from willfindlay/tp_btf
aya/aya-bpf: implement btf tracepoint programs
3 years ago
William Findlay 6b6d4af932
aya/programs/lsm: pass Btf by reference instead of loading new Btf in Lsm::load 3 years ago
William Findlay 6539cbb555
aya/aya-bpf: implement btf tracepoint programs 3 years ago
Alessandro Decina c4b6970774
Merge pull request #80 from willfindlay/fix-rust-analyzer
meta: ignore .vscode/ except .vscode/settings.json
3 years ago
Alessandro Decina 140005d9e3
Merge pull request #68 from vadorovsky/lsm
Add support for raw tracepoint and LSM programs
3 years ago
William Findlay 169478c863 Add support for raw tracepoint and LSM programs
This change adds support for the following program types:

* raw tracepoint
* LSM

Supporting LSM programs involved a necessity of supporting more
load_attrs for the BPF_PROG_LOAD operation, concretely:

* expected_attach_type - for LSM programs, it has always to be set to
  BPF_LSM_MAC
* attach_btf_obj_fd - it's often used to reference the file descriptor of
  program's BTF info, altough in case of LSM programs, it only has to
  contain the value 0, which means the vmlinux object file (usually
  /sys/kernel/btf/vmlinux)
* attach_btf_id - ID of the BTF object, which in case of LSM programs is
  the ID of the function (the LSM hook)

The example of LSM program using that functionality can be found here:

https://github.com/vadorovsky/aya-example-lsm

Fixes: #9
Signed-off-by: William Findlay <william@williamfindlay.com>
Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
3 years ago
Alessandro Decina 89d72e2e26
Merge pull request #81 from willfindlay/awesome-aya
readme: add a link to awesome aya
3 years ago
William Findlay 396e15d756
readme: add a link to awesome aya 3 years ago
William Findlay ac47f7ee73
meta: ignore .vscode/ except .vscode/settings.json 3 years ago
Alessandro Decina 9dc555ae17
Merge pull request #79 from willfindlay/fix-rust-analyzer
meta: fix rust-analyzer support for aya-bpf
3 years ago
William Findlay e115b72245
meta: fix rust-analyzer support for aya-bpf
Ironically, we have the same issue here as in https://github.com/aya-rs/aya-template/pull/13/.
This patch fixes this by explicitly defining the project layout for both vscode and neovim.
3 years ago
Alessandro Decina 56fd09c443
Merge pull request #78 from willfindlay/main
aya: fix include_bytes_aligned! macro to work in some corner cases
3 years ago
William Findlay 99f6f9e14d
aya: fix include_bytes_aligned! macro to work in some corner cases
I found a corner case in my own development workflow that caused the existing macro to not
work properly. The following changes appear to fix things. Ideally, we could add some test
cases to CI to prevent regressions.  This would require creating a dedicated directory to
hold test cases so that we can "include" them at compile time.
3 years ago
Alessandro Decina a94774755f
Merge pull request #76 from willfindlay/load_include_bytes
aya: introduce include_bytes_aligned!() macro
3 years ago
William Findlay 4df4e9c14e
aya: introduce include_bytes_aligned!() macro
This is a helper macro that can be used to include bytes at compile-time that can then be
used in Bpf::load(). Unlike std's include_bytes!(), this macro also ensures that the
resulting byte array is correctly aligned so that it can be parsed as an ELF binary.

Signed-off-by: William Findlay <william@williamfindlay.com>
3 years ago
Alessandro Decina 75acbe1455 xtask: fix clippy warning 3 years ago