microsoft / microsoft/ebpf-for-windows

Optional interface argument for xdp programs seems required when adding XDP program via netsh

Open
#4,581 0 comments 0 reactions 1 assignee Claimed by @shankarseal View on GitHub
bug P2 triaged
Dominant language
C
Stars
3.6k
Forks
311
Avg merge
6d 10h
Merged PRs (30d)
21

Description

While trying to follow the guidance in the "netsh ebpf add program" help text, my experience around the optional "interface" argument does not align with what the help text describes. I could only get the program to load by specifying a specific interface. I'm not sure if the help text is wrong or if there is a product bug.

In my case I was loading a native program.

```
C:\Users\Administrator>netsh ebpf add program /?

Usage: add program [filename=]
[[type=]]
[[pinpath=]]
[[interface=]]
[[pinned=]none|first|all]
[[execution=]jit|interpret]
[[compartment=]

Parameters:

Tag Value
filename - Filename or path to ELF file containing the
program.
type - A string used as if it were a section name, to
determine the program type and expected attach
type.
pinpath - Optionally the name to pin the program to.
interface - Optionally the friendly name or index of a
network interface to which an XDP program should be attached.
If the interface is not specified (or index is set to 0),
the XDP program is attached to all network interfaces.
The command fails if this parameter is specified for program types
other than XDP.
compartment - Optionally the ID of a network compartment to which a program
should be attached. The command fails if this parameter is
specified for program types other than CGROUP_SOCK_ADDR.
pinned - One of the following values:
none: Load all programs without pinning any.
first: Pin the first program in the file.
all: Pin all programs in the file.
execution - One of the following values:
jit: Convert the program to machine code.
interpret: Run the program as byte code.

Remarks: Loads programs from a file and pins them if requested.

C:\Users\Administrator>netsh ebpf add program filename=test_xdp.sys type=xdp
error 23: could not attach program

C:\Users\Administrator>netsh ebpf add program filename=test_xdp.sys type=xdp interface=0
Interface parameter is invalid.

C:\Users\Administrator>netsh ebpf add program filename=test_xdp.sys type=xdp interface=5
Loaded with ID 70

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.