-
Notifications
You must be signed in to change notification settings - Fork 270
[doc] Custom maps proposal #4882
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?
[doc] Custom maps proposal #4882
Conversation
…saxena-anurag/ebpf-for-windows-1 into user/anusa/custom_maps_proposal
docs/ExtensibleMaps.md
Outdated
| This document contains proposal for adding support for extensible / custom maps. Custom maps are map types that are | ||
| program type specific, and are implemented / coordinated by the extensions. | ||
|
|
||
| Extensible / custom maps are program type specific map types that can be implemented / coordinated by eBPF extensions |
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.
| Extensible / custom maps are program type specific map types that can be implemented / coordinated by eBPF extensions | |
| Custom maps are program type specific map types that can be implemented / coordinated by eBPF extensions |
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.
Updated all instances to use "custom maps"
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.
You missed one: the filename is still ExtensibleMaps.md. Please rename to CustomMaps.md for consistency.
docs/ExtensibleMaps.md
Outdated
| ```c | ||
| typedef struct _ebpf_map_provider_dispatch_table { | ||
| ebpf_extension_header_t header; | ||
| ebpf_map_create_notify_t create_map_notify; |
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.
Consider renaming to process_map_operation instead of operation_map_notify.
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.
Updated
docs/ExtensibleMaps.md
Outdated
| ↓ | ||
| ebpfcore checks if map_type >= 4096 | ||
| ↓ | ||
| ebpfcore creates extensible map with NMR client |
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.
editorial - rewrite to eBPF registers new map client for the map instance.
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.
Updated
docs/ExtensibleMaps.md
Outdated
| This document contains proposal for adding support for extensible / custom maps. Custom maps are map types that are | ||
| program type specific, and are implemented / coordinated by the extensions. | ||
|
|
||
| Extensible / custom maps are program type specific map types that can be implemented / coordinated by eBPF extensions |
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.
You missed one: the filename is still ExtensibleMaps.md. Please rename to CustomMaps.md for consistency.
docs/ExtensibleMaps.md
Outdated
| Global maps will use IDs from 1 to 4095. Extensible maps will use IDs 4096 onwards. | ||
|
|
||
| - **Global Maps (1-4095)**: Reserved for core eBPF runtime map types (hash, array, etc.) | ||
| - **Extensible Maps (4096+)**: Available for extension-implemented custom map types |
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.
Once custom map types are registered, why have separate ranges in the first place?
| Note: Extensions **should** register the map types for the custom maps by creating a pull request to eBPF-for-Windows | ||
| repository and updating `ebpf_map_type_t` enum in ebpf_structs.h. This helps in any map type collision with another | ||
| extension. |
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.
| Note: Extensions **should** register the map types for the custom maps by creating a pull request to eBPF-for-Windows | |
| repository and updating `ebpf_map_type_t` enum in ebpf_structs.h. This helps in any map type collision with another | |
| extension. | |
| Note: Extensions **must** register the map types for the custom maps by creating a pull request to eBPF-for-Windows | |
| repository and updating `ebpf_map_type_t` enum in ebpf_structs.h. This avoids any map type collision with another | |
| extension or eBPF core. |
(Requiring a PR also prevents extensions from colliding with core eBPF runtime map types.)
|
|
||
| **Dynamic Provider Discovery**: Uses NMR's built-in discovery mechanism | ||
| - No central registry required - providers are discovered on-demand during map creation | ||
| - When a map is created with a custom type (>= 4096), eBPF core: |
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.
| - When a map is created with a custom type (>= 4096), eBPF core: | |
| - When a custom map is created, eBPF core: |
| ↓ | ||
| ebpfapi validates parameters | ||
| ↓ | ||
| ebpfcore checks if map_type >= 4096 |
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.
I think this line should be deleted since I'm not convinced it has any significant value.
I'm not opposed to it if you can articulate some value it provides though, but currently this document doesn't.
|
|
||
| ### User-mode APIs | ||
| All existing libbpf APIs work unchanged with custom maps | ||
| - `bpf_create_map()` / `bpf_map_create()` - Creates custom maps when type >= 4096 |
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.
| - `bpf_create_map()` / `bpf_map_create()` - Creates custom maps when type >= 4096 | |
| - `bpf_create_map()` / `bpf_map_create()` - Creates custom maps when type is a custom map type |
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 proposes a design for implementing custom maps in eBPF-for-Windows, enabling extensions to register and manage their own map types (e.g., BPF_MAP_TYPE_XSKMAP) through a new NMR provider interface while leveraging the core runtime's existing map implementations.
Key changes:
- Introduces a new NMR provider interface for custom maps with provider registration data and dispatch tables
- Partitions the map type ID space: IDs 1-4095 for core maps, 4096+ for custom maps
- Documents the map creation flow, lifecycle management, and how existing APIs remain unchanged
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ## Map Lifecycle | ||
| **Provider Binding**: eBPF core maintains map lifecycle and coordinates with extensions for map creation, deletion, | ||
| and othr map operations. |
Copilot
AI
Jan 7, 2026
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.
Corrected spelling of 'othr' to 'other'.
| ### User-mode APIs | ||
| All existing libbpf APIs work unchanged with custom maps | ||
| - `bpf_create_map()` / `bpf_map_create()` - Creates custom maps when type >= 4096 | ||
| - Map operations - Operations are routed to custom maps, whicn in turn invokes provider callbacks. |
Copilot
AI
Jan 7, 2026
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.
Corrected spelling of 'whicn' to 'which'.
| - Map operations - Operations are routed to custom maps, whicn in turn invokes provider callbacks. | |
| - Map operations - Operations are routed to custom maps, which in turn invokes provider callbacks. |
| ## NMR Interface for Extensions | ||
| To implement custom maps, a new NMR interface will be added and extensions will register as map info providers using | ||
| NMR, similar to existing program and hook providers. An extension implementing more than one custom maps needs to | ||
| register as a map provider once for each map type it supports. |
Copilot
AI
Jan 7, 2026
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.
The statement about registering 'once for each map type' conflicts with the structure definition at line 35 which shows 'uint32_t custom_map_type; // Single map type per provider.' Consider clarifying whether this means one registration per map type (requiring multiple registrations for extensions supporting multiple map types) or one registration total per extension.
| following scenarios: | ||
| 1. **Map Creation** -- eBPF runtime will invoke `process_map_create` to validate the key and value sizes, and optionally | ||
| get actual value size. | ||
| 2. **Map Deletion** -- eBPF runtime will invoke process_map_delete to notify the extension that the map is being deleted. |
Copilot
AI
Jan 7, 2026
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.
Inconsistent naming: the dispatch table field is named 'process_map_delete' (line 46) but this sentence refers to it as 'process_map_delete'. However, reviewing the dispatch table structure shows the field is 'process_map_delete_t' as a type, not the function name. Consider using consistent terminology, such as 'the process_map_delete callback' to match the field name in the dispatch table.
| 2. **Map Deletion** -- eBPF runtime will invoke process_map_delete to notify the extension that the map is being deleted. | |
| 2. **Map Deletion** -- eBPF runtime will invoke the `process_map_delete` callback to notify the extension that the map is being deleted. |
Description
This PR adds proposal for implementing custom maps (#4375).
Testing
NA
Documentation
This PR adds doc.
Installation
No