-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat: concrete type arguments #4353
base: main
Are you sure you want to change the base?
Conversation
|
||
switch argType { | ||
case u8T: | ||
case trace.U8_T: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about reducing the size of readArgFromBuff()
by replacing the switch/if branches with an already initialized array containing pointer functions for each type (ebpfMsgDecoder.Decode*
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically the planned next step. I plan to move the decoding mapping to a hash map similar to the processor and derive functions. In this way we, and plugin authors, can easily introduce new decoding strategies.
A useful example already exists in the code: we have two different submission formats for string arrays. Therefore we have a single "presentation type" with two "decoding strategies".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geyslan I've opted not to make this step in this PR but rather in a followup so that we merge smaller chunks at a time as this is a large scale change.
15f5ce3
to
d48f44c
Compare
74d839d
to
9df64bd
Compare
9df64bd
to
03e90d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what we are trying to achieve in this PR
// If the size is greater than 255, assign 0 (making it evident) and handle it as a special case. | ||
static u8 type_size_table[ARG_TYPE_MAX_ARRAY + 1] = { | ||
static u32 type_size_table[ARG_TYPE_MAX_ARRAY + 1] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to change to u32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leaving at u8 introduced BTF errors. Moving to u32 moved the error to the verifier which I could eventually sort out. In addition I believe @geyslan suggested a move to u32 for some reason which I can't recall...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I implemented such an array, I was lucky enough to pass through the verifier with flying colours. But when you changed its elements, the verifer surely started complaining about misaligned accesses or even reverted to its familiar state of "not knowing how to count". Changing the size of the array elements to the word size would be a fix, as you did.
pkg/ebpf/c/common/buffer.h
Outdated
return 1; | ||
} | ||
// Read into buffer after the argument index | ||
if (bpf_probe_read_kernel(&(buf->args[buffer_index_offset]), size, ptr) < 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you know that we are reading from a kernel pointer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used only in syscall argument extraction which I think is copied from the bpf context first. Anyway we can't be certain and there would be no harm done moving back to the generic probe_read.
eventDerivations derive.Table | ||
eventsSorter *sorting.EventsChronologicalSorter | ||
eventsPool *sync.Pool | ||
eventArgumentTypes map[events.ID][]trace.DecodeAs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguments/Parameters should be replaced by data fields, which is the terminology used by the new event structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming to eventDataDecodeTypes
is ok for you?
The PR has two goals:
Currently only the first goal is achieved. |
03e90d1
to
f56e9bc
Compare
1. Reduce the type variance via hardcoding possible types 2. Move argument types to the types package 3. Make corresponding changes in eBPF code
Move some functions around, rename and improve documentation.
f56e9bc
to
8fc7341
Compare
1. Explain what the PR does
"Replace me with
make check-pr
output"2. Explain how to test it
3. Other comments