From bed474a4d128b24e9058245706ffdc18bb94eb8f Mon Sep 17 00:00:00 2001 From: Anurag Saxena <43585259+saxena-anurag@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:57:06 -0700 Subject: [PATCH] Add context_header support (#607) * upgrade to 0.18, add context_header support * fix bad typecast --- src/xdp/program.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xdp/program.c b/src/xdp/program.c index 8c395388..167cc20d 100644 --- a/src/xdp/program.c +++ b/src/xdp/program.c @@ -18,6 +18,7 @@ typedef struct _EBPF_PROG_TEST_RUN_CONTEXT { } EBPF_PROG_TEST_RUN_CONTEXT; typedef struct _EBPF_XDP_MD { + EBPF_CONTEXT_HEADER; xdp_md_t Base; EBPF_PROG_TEST_RUN_CONTEXT* ProgTestRunContext; } EBPF_XDP_MD; @@ -120,7 +121,7 @@ XdpCreateContext( XdpMd->Base.ingress_ifindex = xdp_context->ingress_ifindex; } - *Context = XdpMd; + *Context = &XdpMd->Base; XdpMd = NULL; EbpfResult = EBPF_SUCCESS; @@ -154,7 +155,7 @@ XdpDeleteContext( goto Exit; } - XdpMd = (EBPF_XDP_MD*)Context; + XdpMd = CONTAINING_RECORD(Context, EBPF_XDP_MD, Base); // Copy the packet data to the output buffer. if (DataOut != NULL && DataSizeOut != NULL && XdpMd->Base.data != NULL) { @@ -653,6 +654,7 @@ static const ebpf_program_data_t EbpfXdpProgramData = { .context_create = XdpCreateContext, .context_destroy = XdpDeleteContext, .required_irql = DISPATCH_LEVEL, + .capabilities = {.supports_context_header = TRUE}, }; static const NPI_MODULEID EbpfXdpProgramInfoProviderModuleId = {