-
Notifications
You must be signed in to change notification settings - Fork 229
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
Don't abort program if next_key is NULL in ebpf_map_get_next_key() #3900
base: main
Are you sure you want to change the base?
Conversation
70b4642
to
1bfaab6
Compare
Fix libbpf_test failed test case. |
tests/unit/libbpf_test.cpp
Outdated
@@ -1005,6 +1005,11 @@ TEST_CASE("libbpf map", "[libbpf]") | |||
REQUIRE(result < 0); | |||
REQUIRE(errno == EINVAL); | |||
|
|||
// next_key is NULL. | |||
result = bpf_map_get_next_key(map_fd, NULL, &value); |
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.
question: the second argument to bpf_map_get_next_key()
is previous_key
, which is being passed as NULL here, whereas the comment says next_key
is NULL. The above code change is also for handling next_key
being NULL. Is this expected?
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.
Thanks, good catch!
On Linux it is valid to pass NULL as next_key for queue type maps, since that map type doesn't really have a key. Return EINVAL instead of aborting the process via an assert.
1bfaab6
to
ecf7ea9
Compare
On Linux it is valid to pass NULL as next_key for queue type maps, since that map type doesn't really have a key. Return EINVAL instead of aborting the process via an assert.