Commit Graph

1338 Commits (00d265c51b69e672457502593fbc63d0ac953e27)
 

Author SHA1 Message Date
Dave Tucker 5cfecbdd8e
Merge pull request #232 from dave-tucker/fix_docs
ci: lint: aya: Skip doctests with miri
3 years ago
Dave Tucker 3d820ee473 ci: lint: aya: Skip doctests with miri
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 5421b71b5b
Merge pull request #230 from dave-tucker/fix_docs
ci: Fix aya-bpf workflow
3 years ago
Dave Tucker 1f047f0dbe ci: Fix aya-bpf workflow
This was testing the aya crate with the nightly toolchain which wasn't
what was intented

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
dependabot[bot] ab7eed2759
build(deps): update parking_lot requirement from 0.11.1 to 0.12.0
Updates the requirements on [parking_lot](https://github.com/Amanieu/parking_lot) to permit the latest version.
- [Release notes](https://github.com/Amanieu/parking_lot/releases)
- [Changelog](https://github.com/Amanieu/parking_lot/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Amanieu/parking_lot/compare/0.11.1...0.12.0)

---
updated-dependencies:
- dependency-name: parking_lot
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Alessandro Decina 2a18239346
Merge pull request #161 from nimrodshn/add_lpm_trie
Add support for BPF_MAP_TYPE_LPM_TRIE
3 years ago
Nimrod Shneor c6e66d8080 Fix #128: Add support for BPF_MAP_TYPE_LPM_TRIE map 3 years ago
Alessandro Decina 17a3959e87
Merge pull request #183 from dave-tucker/fix-image-build
ci: Fix image build workflow
3 years ago
Dave Tucker d55a47fb3d ci: Fix image build workflow
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 9f711e44fe
Merge pull request #182 from dave-tucker/moar-tests
Regression Test Framework Improvements
3 years ago
Dave Tucker ce93774e0a ci: try running regression tests in a container
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 61c3675b92 test: Add a check for minimum kernel version
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 4bad464c92 test: Add smoke test for BPF_PROG_TYPE_EXT
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 657fb44525 test: Add compile_c_ebpf to library
This allows for C code to be compiled and used in tests!
It does require libbpf on the host machine though...

Also moved removal of the `user` and `ebpf` dirs created by rust-script
into `lib.sh` and parameterized bits of the XDP smoke test for ease of
copying

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina f41db116ac
Merge pull request #160 from dave-tucker/test-images
test: Add regression tests
3 years ago
Dave Tucker 74ae8ce271 test: Add regression tests
This uses a mix of rust-script, bash, qemu and a test runner called RTF
to add a regression test suite... and wires it into GitHub Actions

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 6316748ec1
Merge pull request #179 from dave-tucker/btf_datasec_name
btf: Replace / in DATASEC before load to kernel
3 years ago
Alessandro Decina b2182c6c4e
Merge pull request #177 from alessandrod/ptr-relocs
relocate .text references
3 years ago
Alessandro Decina f169a3fc6b aya: fix func_info/line_info offsets
Given the new start instruction offset, rebase func_infos and
line_infos.
3 years ago
Alessandro Decina 8202105b7d aya: relocate .text references
Handle relocations against .text symbols in all instructions not just
calls. Makes it so that let x = &some_function triggers linking of
some_function in the current program and handles the resulting
relocation accordingly.

Among other things, enables the use of bpf_for_each_map_elem.
3 years ago
Dave Tucker 825bb3ad20 btf: Replace / in DATASEC before load to kernel
This replaces the / character with a . which is allowed in the kernel
names. Not allowing a forward slash is perhaps a kernel bug, but lets
fix it up here as it's commonly used for Aya

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 1904aeaef9
Merge pull request #175 from dave-tucker/merge_fixup_sanitize
aya: Merge Fixup and Sanitzation to single step
3 years ago
Dave Tucker 99fa85eab8 btf: fix match arms
Don't match on kind and use if let...
Match on the BtfType

Fixes: #178

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 326825aab0 tests: add a test for each BTF fix
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 4efc2061a8 btf: fix borrow check errors 3 years ago
Dave Tucker a1b46ece05 aya: Merge Fixup and Sanitzation to single step
Aya will now perform sanitzation and fixups in a single phase, requiring
only one pass over the BTF. This modifies the parsed BTF in place.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 06f8938808
Merge pull request #164 from dave-tucker/btf_verifier
aya: Fix BTF verifier output
3 years ago
Dave Tucker 5d8b279265 aya: Fix BTF verifier output
Currently errors can occur if the verifier output is > buffer as we get
ENOMEM. We should only provide a log_buf if initial load failed, then
retry up to 10 times to get full verifier output.

To DRY this logic it has been moved to a function so its shared with
program loading

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>

one verifier loop to rule them all

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker d9496df3a7
Merge pull request #173 from alessandrod/func-proto-fixup
Add fixup for FuncProto
3 years ago
Dave Tucker f70ab2caa7
Merge pull request #174 from alessandrod/func-global-fix
btf: fix sanitization if BTF_FUNC_GLOBAL is not supported
3 years ago
Alessandro Decina 7ad0524283 btf: fix sanitization if BTF_FUNC_GLOBAL is not supported
The lower 16 bits were not actually being cleared.
3 years ago
Alessandro Decina 9ba2e147a1 btf: fixup func protos
If an argument has a type, it must also have a name, see btf_func_check
in the kernel.

Given:

SEC("lsm/syslog")
int BPF_PROG(syslog_audit, int type, int ret_prev)
{
        return 0;
}

Fixes:

error: BTF error: the BPF_BTF_LOAD syscall failed. Verifier output: magic: 0xeb9f
version: 1
flags: 0x0
hdr_len: 24
type_off: 0
type_len: 76
str_off: 76
str_len: 128
btf_total_size: 228
[1] FUNC_PROTO (anon) return=2 args=(3 (anon))
[2] INT int size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
[3] PTR (anon) type_id=4
[4] INT long long unsigned int size=8 bits_offset=0 nr_bits=64 encoding=(none)
[5] FUNC syslog_audit type_id=1
[5] FUNC syslog_audit type_id=1 Invalid arg#1
: Invalid argument (os error 22)
3 years ago
Alessandro Decina 89b5dd32ed btf: run fixup in place 3 years ago
Alessandro Decina b45a160bb0
Merge pull request #168 from dave-tucker/decl_tag
btf: Add support for BTF_TYPE_KIND_{TAG,DECL_TAG}
3 years ago
Alessandro Decina b93188fefe
Merge pull request #172 from dave-tucker/name_trunc
aya: Fix name truncation
3 years ago
Dave Tucker 8f9a32ff10 aya: Fix name truncation
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina dccdc45ccd
Merge pull request #171 from dave-tucker/nametoolong
aya: Truncate long program names
3 years ago
Dave Tucker 437432cdd6 aya: Truncate long program names
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 5d9ff70498 btf: Add support for BTF_TYPE_KIND_{TAG,DECL_TAG}
Adds support for two new BTF kinds including feature probes and BTF
sanitization

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 1492d85a7b
Merge pull request #169 from dave-tucker/fix_array_relo
aya: Fix BTF type resolution for Arrays and Ints
3 years ago
Alessandro Decina 6a91fdf5a7
Merge pull request #157 from dave-tucker/doc-aya
aya: document the public api
3 years ago
Dave Tucker 686ce45f93 aya: Fix BTF type resolution for Arrays and Ints
The union of `size` and `type` is unused in BTF_KIND_ARRAY.
Type information of elements is in the btf_array struct that follows in
the type_ field while the index type is in the index_type field.

For BTF_KIND_INT, only the offset should be compared and size and
signedness should be ignored.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 01187735f0
Merge pull request #167 from aya-rs/codegen
Update libbpf to be89b28f96be426e30a2b0c5312d13b30ee518c7
3 years ago
dave-tucker 324c679a41 Update libbpf to be89b28f96be426e30a2b0c5312d13b30ee518c7 3 years ago
Alessandro Decina 4e9bc32a3d aya: maps: rename from_pinned() to open_pinned() 3 years ago
Alessandro Decina 9b1ab96ad5
Merge pull request #166 from dave-tucker/decl_tag
codegen: add btf_decl_tag
3 years ago
Dave Tucker 19af687480 codegen: add btf_decl_tag
This is required to add support for BTF_KIND_DECL_TAG

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina f12054a00d
Merge pull request #165 from dave-tucker/prog_pinned
aya: Retrieve program from pinned path
3 years ago
Dave Tucker abc8d27440 aya: Retrieve program from pinned path
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 353b5f9cb1
Merge pull request #163 from aya-rs/codegen
Update libbpf to 22411acc4b2c846868fd570b2d9f3b016d2af2cb
3 years ago