Skip to content

Conversation

@nigriMSFT
Copy link
Contributor

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

Copy link
Collaborator

@dthaler dthaler left a 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.

@Alan-Jowett Alan-Jowett requested a review from Copilot August 26, 2025 19:13
Copy link
Contributor

Copilot AI left a 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;
Copy link

Copilot AI Aug 26, 2025

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.

Suggested change
object_type = EBPF_OBJECT_UNKNOWN;
// object_type = EBPF_OBJECT_UNKNOWN; // Unnecessary, removed.

Copilot uses AI. Check for mistakes.
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());
Copy link

Copilot AI Aug 26, 2025

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.

Suggested change
printf("%7u Map %s\n", info.id, path.c_str());
printf("%7u %-7s %s\n", info.id, "Map", path.c_str());

Copilot uses AI. Check for mistakes.
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.

netsh ebpf show pins does not show map pins

3 participants