-
Notifications
You must be signed in to change notification settings - Fork 212
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
bpf2c should not allow static initialization for BPF_MAP_TYPE_HASH_OF_MAPS map value, except for key_size is integer #2882
Comments
From code analysis, BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_HASH_OF_MAPS provide general-purpose support for map in map storage.
|
Trace |
Reading this note from https://docs.kernel.org/bpf/map_of_maps.html If the key and value (fd of the inner map) are integers, then static initialization should be allowed. I think. that is the reason, the maps provided in the description worked and were loaded. |
Updating the title based on what Linux does. It appears as if libbpf on Linux supports statically initializing hash of maps, but only if the key size == sizeof(int) and then assigning offset as the key. |
Describe the bug
The request is to bpf2c should flag error that it cannot statically initialize the value for Hash-of-Maps.
Only BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_PROG_ARRAY type maps can be statically initialized as they have an implicit key value.
BPF_MAP_TYPE_HASH_OF_MAPS style maps have no implicit key value and can't be statically initialized.
Incorrect Map with static initialization:
Trace:
[39]1624.193C::2023-09-21 15:06:26.974 [EbpfForWindowsProvider]_ebpf_native_set_initial_map_values
[39]1624.193C::2023-09-21 15:06:26.974 [EbpfForWindowsProvider]_ebpf_native_set_initial_map_values returned error,6
[39]1624.193C::2023-09-21 15:06:26.974 [EbpfForWindowsProvider]ebpf_native_load_programs: set initial map values failed,{eb7ad2f3-6a4b-465b-8fb7-93ad58c5c456}
Reference: #2854
OS information
Windows 10 and above
Steps taken to reproduce bug
Use the above map.
Expected behavior
bpf2c should flag the error that BPF_MAP_TYPE_HASH_OF_MAPS cannot be statically initialized.
Actual outcome
Trace:
[39]1624.193C::2023-09-21 15:06:26.974 [EbpfForWindowsProvider]_ebpf_native_set_initial_map_values
[39]1624.193C::2023-09-21 15:06:26.974 [EbpfForWindowsProvider]_ebpf_native_set_initial_map_values returned error,6
[39]1624.193C::2023-09-21 15:06:26.974 [EbpfForWindowsProvider]ebpf_native_load_programs: set initial map values failed,{eb7ad2f3-6a4b-465b-8fb7-93ad58c5c456}
Additional details
The text was updated successfully, but these errors were encountered: