Add support to ctx in runProgram.
Programs of type raw_tp need the input to be passed in the ctx instead of the data. Test: with ag/33648187 Change-Id: I79ac0126d91c9eafd847a0c8709a47a0113a9430
This commit is contained in:
parent
a3b8091626
commit
69a9bbcee0
1 changed files with 14 additions and 9 deletions
|
|
@ -235,15 +235,20 @@ inline int detachSingleProgram(bpf_attach_type type, const borrowed_fd& prog_fd,
|
|||
}
|
||||
|
||||
// Available in 4.12 and later kernels.
|
||||
inline int runProgram(const borrowed_fd& prog_fd, const void* data,
|
||||
const uint32_t data_size) {
|
||||
return bpf(BPF_PROG_RUN, {
|
||||
.test = {
|
||||
.prog_fd = static_cast<__u32>(prog_fd.get()),
|
||||
.data_size_in = data_size,
|
||||
.data_in = ptr_to_u64(data),
|
||||
},
|
||||
});
|
||||
inline int runProgram(const borrowed_fd &prog_fd, const void *data,
|
||||
const uint32_t data_size, const void *ctx = nullptr,
|
||||
const uint32_t ctx_size = 0) {
|
||||
return bpf(BPF_PROG_RUN,
|
||||
{
|
||||
.test =
|
||||
{
|
||||
.prog_fd = static_cast<__u32>(prog_fd.get()),
|
||||
.data_size_in = data_size,
|
||||
.data_in = ptr_to_u64(data),
|
||||
.ctx_size_in = ctx_size,
|
||||
.ctx_in = ptr_to_u64(ctx),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// BPF_OBJ_GET_INFO_BY_FD requires 4.14+ kernel
|
||||
|
|
|
|||
Loading…
Reference in a new issue