From 2d5d3175b5085106d67938b112e3f788399d7b01 Mon Sep 17 00:00:00 2001 From: Michael Friesen <3517159+mtfriesen@users.noreply.github.com> Date: Fri, 17 Feb 2023 13:59:13 -0500 Subject: [PATCH] XDP: complete TX clones upon injection failure (#2013) * complete TX clones upon inject failure * satisfy static analyzer * fix dispatch input parameter, and ignore output --------- Co-authored-by: Alan Jowett Co-authored-by: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com> --- netebpfext/net_ebpf_ext_xdp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/netebpfext/net_ebpf_ext_xdp.c b/netebpfext/net_ebpf_ext_xdp.c index cfe8a1a51..e2f4ee7ea 100644 --- a/netebpfext/net_ebpf_ext_xdp.c +++ b/netebpfext/net_ebpf_ext_xdp.c @@ -512,14 +512,17 @@ Exit: } static void -_net_ebpf_ext_l2_inject_send_complete(_In_ const void* context, _Inout_ NET_BUFFER_LIST* nbl, BOOLEAN dispatch_level) +_net_ebpf_ext_l2_inject_send_complete( + _In_opt_ const void* context, _Inout_ NET_BUFFER_LIST* nbl, BOOLEAN dispatch_level) { + UNREFERENCED_PARAMETER(dispatch_level); + if ((BOOLEAN)(uintptr_t)context == FALSE) // Free clone allocated using _net_ebpf_ext_allocate_cloned_nbl. _net_ebpf_ext_free_nbl(nbl, TRUE); else // Free clone allocated using FwpsAllocateCloneNetBufferList. - FwpsFreeCloneNetBufferList(nbl, dispatch_level); + FwpsFreeCloneNetBufferList(nbl, 0); } static void @@ -561,6 +564,8 @@ _net_ebpf_ext_handle_xdp_tx( if (status != STATUS_SUCCESS) { NET_EBPF_EXT_LOG_NTSTATUS_API_FAILURE(NET_EBPF_EXT_TRACELOG_KEYWORD_XDP, "FwpsInjectMacSendAsync", status); + _net_ebpf_ext_l2_inject_send_complete( + (void*)(uintptr_t)cloned_packet, nbl, KeGetCurrentIrql() == DISPATCH_LEVEL); goto Exit; }