Skip to content

Commit

Permalink
fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
shankarseal committed Dec 11, 2023
1 parent cafe75c commit 8746a0b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/ebpf_program_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <guiddef.h>
#if !defined(NO_CRT) && !defined(_NO_CRT_STDIO_INLINE)
#include <stdbool.h>
#include <stdint.h>
#else
typedef unsigned char uint8_t;
Expand Down
2 changes: 1 addition & 1 deletion libs/execution_context/ebpf_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ _IRQL_requires_max_(PASSIVE_LEVEL) static ebpf_result_t _ebpf_program_compute_pr
}

if (helper_function_prototype->reallocate_packet) {
result = EBPF_CRYPTOGRAPHIC_HASH_APPEND_VALUE(cryptographic_hash, "reallocate_packet");
result = EBPF_CRYPTOGRAPHIC_HASH_APPEND_STR(cryptographic_hash, "reallocate_packet");
if (result != EBPF_SUCCESS) {
goto Exit;
}
Expand Down
6 changes: 3 additions & 3 deletions netebpfext/net_ebpf_ext_program_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
#include "ebpf_program_types.h"
#include "ebpf_shared_framework.h"

#define TRUE 1

#define XDP_EXT_HELPER_FUNCTION_START EBPF_MAX_GENERAL_HELPER_FUNCTION

#define HELPER_FUNCTION_REALLOCATE_PACKET 1

// XDP_TEST helper function prototype descriptors.
static const ebpf_helper_function_prototype_t _xdp_test_ebpf_extension_helper_function_prototype[] = {
{XDP_EXT_HELPER_FUNCTION_START + 1,
"bpf_xdp_adjust_head",
EBPF_RETURN_TYPE_INTEGER,
{EBPF_ARGUMENT_TYPE_PTR_TO_CTX, EBPF_ARGUMENT_TYPE_ANYTHING},
TRUE}};
HELPER_FUNCTION_REALLOCATE_PACKET}};

// XDP_TEST program information.
static const ebpf_context_descriptor_t _ebpf_xdp_test_context_descriptor = {
Expand Down
23 changes: 23 additions & 0 deletions tests/end_to_end/netsh_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,29 @@ TEST_CASE("show verification droppacket_unsafe.o", "[netsh][verification]")
"\n");
}

TEST_CASE("show verification xdp_adjust_head_unsafe.o", "[netsh][verification]")
{
_test_helper_netsh test_helper;
test_helper.initialize();

int result;
std::string output =
_run_netsh_command(handle_ebpf_show_verification, L"xdp_adjust_head_unsafe.o", L"xdp", nullptr, &result);
REQUIRE(result == ERROR_SUPPRESS_OUTPUT);
output = strip_paths(output);
REQUIRE(
output == "Verification failed\n"
"\n"
"Verification report:\n"
"\n"
"; ./tests/sample/unsafe/xdp_adjust_head_unsafe.c:38\n"
"; ethernet_header->Type = 0x0800;\n"
"16: Upper bound must be at most packet_size (valid_access(r1.offset+26, width=2) for write)\n"
"\n"
"1 errors\n"
"\n");
}

TEST_CASE("show verification printk_unsafe.o", "[netsh][verification]")
{
_test_helper_netsh test_helper;
Expand Down
2 changes: 1 addition & 1 deletion tests/sample/unsafe/xdp_adjust_head_unsafe.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "net/ip.h"
#include "net/udp.h"

SEC("xdp/xdp_adjust_head_unsafe")
SEC("xdp")
int
xdp_adjust_head_unsafe(xdp_md_t* ctx)
{
Expand Down

0 comments on commit 8746a0b

Please sign in to comment.