Comments (6)
Might be nice if we can set this via ubpf_create
, since not every VM in the same process may have the same purpose (and thus might have varying needs for available helpers).
from ubpf.
I was leaning towards a callout. Something like:
int ubpf_set_helper_resolver(struct ubpf_vm *vm, void* resolver_context, uintptr_t (*resolver_function)(void* context, uint32_t helper_id));
The consumer of this library can then control the resolution of helper_id -> address of helper function.
from ubpf.
Isn't that just a more complicated form of ubpf_register
:
Line 85 in c7c019c
from ubpf.
Fair enough. We would then need some form of sparse storage for the helper-id -> address mapping. The issue is that we might need to store:
For an EBPF_PROGRAM_TYPE_XDP
--- Global ---
0x0001->bpf_map_lookup_elem
0x0002->bpf_map_update_elem
0x0003->bpf_map_delete_elem
--- Program specific ---
0x1001->bpf_xdp_redirect
0x1002->bpf_xdp_encap
0x1003->bpf_xdp_decap
0x1004->bpf_xdp_transpose
Or for EBPF_PROGRAM_TYPE_BIND
--- Global ---
0x0001->bpf_map_lookup_elem
0x0002->bpf_map_update_elem
0x0003->bpf_map_delete_elem
--- Program specific ---
0x1001->bpf_bind_redirect
Note: These are currently made up examples (we haven't added anything like this yet).
The current storage assumes helper_id is the position in the array, which won't work well with disjointed helper-id space.
We can either have the complexity of storing the mapping in ubpf or in the caller. In my case the caller needs to store it anyway, so duplicating it in ubpf doesn't make sense for my scenario, but if you think it is something that would be more generally usable, I am happy to add it.
from ubpf.
I think I'm in favor of having an optional callback to do this mapping at runtime/JIT time. I still think ubpf_create
should accept an argument to allow specifying the initial size of ext_funcs
, too.
from ubpf.
Doing this at JIT time is redundant. We can perform the translation on the byte code prior to JIT / interpret and update the eBPF byte code.
So, the only limitation then is if there are > 64 unique helper functions being called by the eBPF program, which seems unlikely.
from ubpf.
Related Issues (20)
- Segmentation fault caused by call instruction HOT 3
- uBPF should match GCC's assembly format
- uBPF assembler should support labels
- EBPF_OP_LSH_IMM and EBPF_OP_LSH_REG incorrectly are non-conformant
- Code analysis errors
- Code coverage check incorrectly shows as failed
- Running the tests failed HOT 2
- Handle calls to bpf local calls in aarch64 HOT 2
- Handle ELF relocations for local BPF function calls
- Out of bounds memory load, store - PREVAIL assumes context is non-null but uBPF sets context to null
- ubpf_set_unwind_function_index is broken
- x64 JIT fails when running on Windows
- ubpf_exec uses 1112 bytes of stack space - Consider moving some data to heap.
- Intermittent failure in macos coverage builds
- Code analysis failure: C6011: Dereferencing NULL pointer 'vm->int_funcs'.
- ubpf_exec stack size mitigation leaks memory HOT 1
- I think DIV_BY_ZERO can be removed as it's dead.
- Retpoline code fails on Windows HOT 1
- Windows CI/CD doesn't check exit code
- Support kprobe and uprobe? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ubpf.