Skip to content

fix: do not shift in map_by_fd #344

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/src/bpf_map/userspace/map_in_maps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{
auto key_val = array_map_impl::elem_lookup(key);
int map_id = *(int *)key_val;
return (void *)((u_int64_t)map_id << 32);
return (void *)((u_int64_t)map_id);

Check warning on line 29 in runtime/src/bpf_map/userspace/map_in_maps.hpp

View check run for this annotation

Codecov / codecov/patch

runtime/src/bpf_map/userspace/map_in_maps.hpp#L29

Added line #L29 was not covered by tests
}
};

Expand Down
4 changes: 2 additions & 2 deletions runtime/src/bpftime_shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,13 +573,13 @@
return INVALID_MAP_PTR;
}
// Use a convenient way to represent a pointer
return ((uint64_t)fd << 32) | 0xffffffff;
return fd;

Check warning on line 576 in runtime/src/bpftime_shm.cpp

View check run for this annotation

Codecov / codecov/patch

runtime/src/bpftime_shm.cpp#L576

Added line #L576 was not covered by tests
}

extern "C" uint64_t map_val(uint64_t map_ptr)
{
SPDLOG_DEBUG("Call map_val with map_ptr={:x}", map_ptr);
int fd = (int)(map_ptr >> 32);
int fd = (int)map_ptr;

Check warning on line 582 in runtime/src/bpftime_shm.cpp

View check run for this annotation

Codecov / codecov/patch

runtime/src/bpftime_shm.cpp#L582

Added line #L582 was not covered by tests
if (!shm_holder.global_shared_memory.get_manager() ||
!shm_holder.global_shared_memory.is_map_fd(fd)) {
SPDLOG_ERROR("Expected fd {} to be a map fd (map_val call)",
Expand Down
Loading