microsoft / ebpf-for-windows

eBPF implementation that runs on top of Windows
MIT License
2.87k stars 224 forks source link

Retry failed FwpmTransactionBegin #3659

Closed dv-msft closed 1 month ago

dv-msft commented 3 months ago

Description

WFP allows only 1 active transaction at a time per WFP session. This leads to errors in multi-threaded scenarios where threads simultaneously try to load and attach ebpf program types supported by the NetEbpfExt extension. In certain timing sensitive instances, such multi-threaded scenarios cause NetEbpfExt to attempt to create a new WFP transaction while a previous transaction is still in progress.

This PR adds time-bounded retry logic to the call to FwpmTransactionBegin call to allow for an already-in-progress transaction (if any) to complete.

Testing

Fix verified locally (100% repro) as well as multiple, back-to-back CI/CD runs on private self-hosted runner.

Do any existing tests cover this change? Are new tests needed? Issue uncovered by existing tests. No new tests needed.

Documentation

No Documentation changes needed.

Installation

Is there any installer impact for this change? No Installer impact.

Fixes #3602 #3607

dv-msft commented 3 months ago

Instead of retry logic, a different session must be used for a given program attach operation.

Did not work. Will discuss offline.

saxena-anurag commented 3 months ago

Will this issue be amplified when we support multiple programs to be attached to the same hook (issue #2626)?

Alan-Jowett commented 2 months ago

Waiting on Shankar's comments to be addressed. Will review after that.

shankarseal commented 1 month ago

This is being abandoned as this not the right fix.