Skip to content

Conversation

@saxena-anurag
Copy link
Contributor

@saxena-anurag saxena-anurag commented Dec 12, 2025

Description

This PR adds proposal for implementing custom maps (#4375).

Testing

NA

Documentation

This PR adds doc.

Installation

No

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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"

Copy link
Collaborator

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.

```c
typedef struct _ebpf_map_provider_dispatch_table {
ebpf_extension_header_t header;
ebpf_map_create_notify_t create_map_notify;
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

ebpfcore checks if map_type >= 4096
ebpfcore creates extensible map with NMR client
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

mtfriesen
mtfriesen previously approved these changes Dec 12, 2025
@saxena-anurag saxena-anurag changed the title custom maps proposal [doc] Custom maps proposal Dec 12, 2025
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
Copy link
Collaborator

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.

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
Copy link
Collaborator

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?

Comment on lines +85 to +87
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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

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 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.
Copy link

Copilot AI Jan 7, 2026

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'.

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

Copilot AI Jan 7, 2026

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'.

Suggested change
- 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.

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

Copilot AI Jan 7, 2026

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.

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

Copilot AI Jan 7, 2026

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.

Suggested change
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.

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.

4 participants