microsoft / microsoft/ebpf-for-windows
'netsh ebpf unpin program...' invocation does not match invocation help text, prints confusing error message.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 311
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 21
Description
### Describe the bug
Using `netsh ebpf unpin program ` to unpin a pinned ebpf program by specifying the id alone (and not specifying the optional pinned path argument) causes the command to fail with a confusing error message.
_(The details are provided in the repro steps.)_
### OS information
_No response_
### Steps taken to reproduce bug
1. Copy the `sample_ebpf_ext.sys` (sample ebpf extension) and `test_sample_ebpf.sys` (sample ebpf program) binaries to the ebpf-for-windows install directory on the test device/VM
2. `cd` to the ebpf install directory, install the sample ebpf extension and start it:
```
sc create SampleEbpfExt binPath= .\sample_ebpf_ext.sys type= kernel
sc start SampleEbpfExt
```
3. Next, add and pin the sample ebpf program:
`netsh ebpf add program .\test_sample_ebpf.sys pinpath= \ebpf\sample\ebpf_sample`
4. Verify that the program is added and pinned at the expected path:
```
PS > netsh ebpf show pins
ID Type Path
======= ======= ==============
3 Program \ebpf\sample\ebpf_sample
```
4. invoke `netsh ebpf unpin program` to view the expected usage syntax:
```
PS > netsh ebpf unpin program
One or more essential parameters were not entered.
Verify the required parameters, and reenter them.
The syntax supplied for this command is not valid. Check help for the correct syntax.
Usage: unpin program [path]
```
5. Notice that the 'Usage' line above indicates the 'path' argument to be optional.
6. Invoke the command providing only the pinned program id and omitting the pin path and notice the command failure with the unrelated error message:
```
PS > netsh ebpf unpin program 3
The media is write protected.
```
7. Invoke the command again along with the program's pinned path argument and verify that the program was unpinned correctly:
```
PS > netsh ebpf unpin program 3 \ebpf\sample\ebpf_sample
PS > netsh ebpf show pins
ID Type Path
======= ======= ==============
```
### Expected behavior
1. The `netsh ebpf unpin program 3` should successfully unpin the program based on the program id alone, without having to specify the optional 'pinned path' argument as well.
2. The parameter validation code path for `netsh ebpf...` should be reviewed to ensure that parameter validation error messages are specific to the issue at hand.
### Actual outcome
The `netsh ebpf unpin program 3` command fails with a confusing and unrelated error message.
### Additional details
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.