Conversation
I don't think this is always true. I think they can be other integer types too. I think that's why the definition of But given your debug output:
I agree the user would configure the type as |
There was a problem hiding this comment.
Enums are uint32. Currently, because of the way integer are handled on
BPF, we need to add an extra dereferencing in the resolve algo to have
it working properly.
That's the most common case, but it's not universal as Andy pointed out.
sudo bpftool btf dump file /sys/kernel/btf/vmlinux | grep 'ENUM ' | grep -v 'size=4'
[1148] ENUM 'rw_hint' encoding=UNSIGNED size=1 vlen=6
[2359] ENUM 'blk_integrity_checksum' encoding=UNSIGNED size=1 vlen=4
[4871] ENUM '_cache_table_type' encoding=UNSIGNED size=1 vlen=4
[4872] ENUM '_tlb_table_type' encoding=UNSIGNED size=1 vlen=15
[23364] ENUM 'scsi_cmnd_submitter' encoding=UNSIGNED size=1 vlen=3
[115702] ENUM 'hub_led_mode' encoding=UNSIGNED size=1 vlen=8
Shouldn't we check the enum size and act appropriately?
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for your clarifications. I think it's better this way indeed. Changes includes :
|
kkourt
left a comment
There was a problem hiding this comment.
LGTM, but can you please rephrase the first commit message that still mentions:
Enums are uint32.
Enums are integers. Currently, because of the way integer are handled on BPF side, we need to add an extra dereferencing in the resolve algo to have it working properly. ``` sudo bpftool btf dump file /sys/kernel/btf/vmlinux | grep 'ENUM ' [1148] ENUM 'rw_hint' encoding=UNSIGNED size=1 vlen=6 ``` Or with custom uprobe we can have something like ``` [11] ENUM 'test_enum' encoding=UNSIGNED size=4 vlen=3 ``` Signed-off-by: Tristan d'Audibert <tdaudibe@isovalent.com>
Enum can have different size. To prevent from user misconfiguration, we calculate the correct type for the enum and return the appropriate one. Like this, if the user set the `type` with something wrong (e.g. `file`) it will be replaced by this new value silently. ```yaml type: file resolve: my_enum type: uint32 resolve: my_enum ``` Example enum format displayed with `bpftool`. ``` [11] ENUM 'test_enum' encoding=UNSIGNED size=4 vlen=3 [1148] ENUM 'rw_hint' encoding=UNSIGNED size=1 vlen=6 ``` Signed-off-by: Tristan d'Audibert <tdaudibe@isovalent.com>
Signed-off-by: Tristan d'Audibert <tdaudibe@isovalent.com>
e1aa561 to
f0314f7
Compare
|
Sorry, it should be better now. Thanks |
Fixes #4799
Description
Enums are uint32. Currently, because of the way integer are handled on BPF, we need to add an extra dereferencing in the resolve algo to have it working properly. For this reason I did not add tests as this little hack won't be necessary after a fix will be done.