Skip to content
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

Add error case for creating unspecified map type. #974

Merged

Conversation

tommyp1ckles
Copy link
Contributor

@tommyp1ckles tommyp1ckles commented Mar 10, 2023

When creating a new map, if the the map type is unspecified (i.e. BPF_MAP_TYPE_UNSPEC) then the call to create the map will fail with EINVAL and the following Go error is returned due to the btf file descriptor being zerod out:

...: map create: ... (without BTF k/v)

Instead, upon failure to create me, this will now check if the map type was set to unspecified and return a relevant error.

map_test.go Outdated Show resolved Hide resolved
map.go Outdated Show resolved Hide resolved
@tommyp1ckles tommyp1ckles force-pushed the pr/tp/improve-unspec-bpf-map-create-error branch 2 times, most recently from 1e918a8 to 9e0f062 Compare March 15, 2023 04:12
When creating a new map, if the the map type is unspecified (i.e. BPF_MAP_TYPE_UNSPEC)
then the call to create the map will fail with EINVAL and the following Go error is returned
due to the btf file descriptor being zerod out:

...: map create: ... (without BTF k/v)

Instead, this will now immediately check if a map is unspecified and return an approriate error.

Signed-off-by: Tom Hadlaw <tom.hadlaw@isovalent.com>
@tommyp1ckles tommyp1ckles force-pushed the pr/tp/improve-unspec-bpf-map-create-error branch from 9e0f062 to 63ab8f8 Compare March 15, 2023 04:12
@tommyp1ckles tommyp1ckles requested review from lmb and ti-mo and removed request for lmb and ti-mo March 15, 2023 04:13
@ti-mo ti-mo merged commit 0c8773e into cilium:master Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants