-
Notifications
You must be signed in to change notification settings - Fork 268
ebpfnetsh: print map pins #4583
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
base: main
Are you sure you want to change the base?
Conversation
dthaler
left a comment
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.
Looks good but I agree with the TODO in the PR description that a test case should be added in this PR, so holding off on approving.
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.
Pull Request Overview
This PR adds support for displaying pinned eBPF maps in the netsh command output. Previously, only pinned eBPF programs were shown, making troubleshooting map pinning issues difficult.
- Separates program and map pin paths into distinct collections during enumeration
- Adds a new loop to display pinned maps with their IDs and paths
- Changes the initial object type from EBPF_OBJECT_PROGRAM to EBPF_OBJECT_UNKNOWN for proper enumeration
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // Ignore. | ||
| break; | ||
| } | ||
| object_type = EBPF_OBJECT_UNKNOWN; |
Copilot
AI
Aug 26, 2025
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.
Setting object_type to EBPF_OBJECT_UNKNOWN after each iteration appears unnecessary. The ebpf_get_next_pinned_object_path function should set the object_type as an output parameter for each call.
| object_type = EBPF_OBJECT_UNKNOWN; | |
| // object_type = EBPF_OBJECT_UNKNOWN; // Unnecessary, removed. |
| struct bpf_map_info info = {}; | ||
| uint32_t info_size = (uint32_t)sizeof(info); | ||
| if (bpf_obj_get_info_by_fd(map_fd, &info, &info_size) == 0) { | ||
| printf("%7u Map %s\n", info.id, path.c_str()); |
Copilot
AI
Aug 26, 2025
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.
[nitpick] The output format string uses different spacing/alignment compared to the program output format. Consider using consistent formatting between program and map entries for better readability.
| printf("%7u Map %s\n", info.id, path.c_str()); | |
| printf("%7u %-7s %s\n", info.id, "Map", path.c_str()); |
Description
While troubleshooting some ebpf map pinning related code, I was confused why there were no map pins according to netsh.
Fixes #4582
Testing
TODO: A test case in netsh_test seems appropriate
Documentation
N/A
Installation
N/A