Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change trace in ebpf_pinning_table_find #2954

Merged
merged 9 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/execution_context/ebpf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ ebpf_core_get_pinned_object(_In_ const cxplat_utf8_string_t* path, _Out_ ebpf_ha

Done:
shpalani marked this conversation as resolved.
Show resolved Hide resolved
EBPF_OBJECT_RELEASE_REFERENCE((ebpf_core_object_t*)object);
EBPF_RETURN_RESULT(retval);
shpalani marked this conversation as resolved.
Show resolved Hide resolved
EBPF_RETURN_FUNCTION_RESULT(retval);
}

static ebpf_result_t
Expand Down
3 changes: 2 additions & 1 deletion libs/execution_context/ebpf_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ _ebpf_native_validate_map(_In_ const ebpf_native_map_t* map, ebpf_handle_t origi
static ebpf_result_t
_ebpf_native_reuse_map(_Inout_ ebpf_native_map_t* map)
{
EBPF_LOG_ENTRY();
ebpf_result_t result = EBPF_SUCCESS;
ebpf_handle_t handle = ebpf_handle_invalid;
// Check if a map is already present with this pin path.
Expand Down Expand Up @@ -853,7 +854,7 @@ _ebpf_native_reuse_map(_Inout_ ebpf_native_map_t* map)
if (result != EBPF_SUCCESS) {
ebpf_assert_success(ebpf_handle_close(handle));
}
return result;
EBPF_RETURN_RESULT(result);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libs/runtime/ebpf_pinning_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ ebpf_pinning_table_find(

ebpf_lock_unlock(&pinning_table->lock, state);

EBPF_RETURN_RESULT(return_value);
EBPF_RETURN_FUNCTION_RESULT(return_value);
}

_Must_inspect_result_ ebpf_result_t
Expand Down
19 changes: 19 additions & 0 deletions libs/shared/ebpf_tracelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ extern "C"
TraceLoggingLong(result, "Error")); \
}

#define EBPF_LOG_FUNCTION_RESULT(result) \
if (TraceLoggingProviderEnabled( \
ebpf_tracelog_provider, EBPF_TRACELOG_LEVEL_VERBOSE, EBPF_TRACELOG_KEYWORD_BASE)) { \
TraceLoggingWrite( \
ebpf_tracelog_provider, \
EBPF_TRACELOG_EVENT_GENERIC_MESSAGE, \
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE), \
TraceLoggingKeyword(EBPF_TRACELOG_KEYWORD_BASE), \
TraceLoggingString(__FUNCTION__ " returned result", "Message"), \
TraceLoggingLong(result, "Result")); \
}

#define EBPF_LOG_ENTRY() \
if (TraceLoggingProviderEnabled( \
ebpf_tracelog_provider, EBPF_TRACELOG_LEVEL_VERBOSE, EBPF_TRACELOG_KEYWORD_FUNCTION_ENTRY_EXIT)) { \
Expand Down Expand Up @@ -210,6 +222,13 @@ extern "C"
return local_fd; \
} while (false);

#define EBPF_RETURN_FUNCTION_RESULT(result) \
ebpf_result_t local_result = (result); \
do { \
EBPF_LOG_FUNCTION_RESULT(local_result); \
return local_result; \
} while (false);

void
ebpf_log_ntstatus_api_failure(ebpf_tracelog_keyword_t keyword, _In_z_ const char* api_name, NTSTATUS status);
#define EBPF_LOG_NTSTATUS_API_FAILURE(keyword, api, status) \
Expand Down
Loading