Skip to content

Add bpf_redirect_map for AF_XDP sockets#1008

Draft
mtfriesen wants to merge 8 commits into
mainfrom
mtfriesen/ebpf_xsk_map
Draft

Add bpf_redirect_map for AF_XDP sockets#1008
mtfriesen wants to merge 8 commits into
mainfrom
mtfriesen/ebpf_xsk_map

Conversation

@mtfriesen

@mtfriesen mtfriesen commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Description

Describe the purpose of and changes within this Pull Request.

WIP

Resolves #941.

Testing

Do any existing tests cover this change? Are new tests needed?

CI, automated functional and spin tests added.

Documentation

Is there any documentation impact for this change?

Yes, docs added, and also deprecation notices are added for the built-in program API, now that the feature gap is effectively closed.

Installation

Is there any installer impact for this change?

N/A.

Comment thread docs/usage.md
Starting with XDP version 1.1, experimental eBPF support can be enabled by appending an `ADDLOCAL=xdp_ebpf` parameter to the `msiexec.exe` install commands.
> **Note:** The built-in rules-based program API (`XDP_RULE` / `XDP_MATCH_TYPE`
> / `XdpCreateProgram`) is deprecated and planned for removal. All users should
> migrate to eBPF programs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: should XDP add support for multi-attach as this is being deprecated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is multi-attach when the program gets loaded once and continuously applies to all interfaces?

Right now, XDP doesn't support that in any program mode - it would be a separate feature request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no it means a user can attach multiple different XDP programs to the same interface. Agree that that is outside the scope of this PR and is a separate feature request, but should we file an issue to track that work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, please do.

Comment thread src/xdp/ebpfstore.h
{
.header = EBPF_HELPER_FUNCTION_PROTOTYPE_HEADER,
.helper_id = BPF_FUNC_redirect_map,
.name = "bpf_redirect_map",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

since this helper function is also applicable for TC, should we add this in ebpfcore? ebpf supports implementing a "virtual" helper function in ebpfcore that can then be overridden by the extension. that way, multiple program info providers can have their own implementations of the same helper functions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that would be perfect. Does eBPF-for-Windows support that today? Does a virtual function like that require coordination between extensions, or since TC and XDP programs are different types, they each define their own bpf_redirect_map with no overlap?

Or would this be something like a bpf_redirect_map virtual function gets implemented by eBPF core, and then it calls into a map-specific type helper?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes this is currently supported in ebpf-for-windows. There will be no implementation in ebpfcore, and each extension will need to provide their own implementation. If a program type does not support this helper, and a BPF program of that type uses this helper, load of that program will fail.

See microsoft/ebpf-for-windows#3464 where bpf_get_socket_cookie() was added in the same way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, that makes sense. I'll create a similar virtual function and hopefully catch the eBPF 1.2 release.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Add AF_XDP bpf_redirect_map support

2 participants