Skip to content

Commit

Permalink
Change trace in ebpf_pinning_table_find (#2954)
Browse files Browse the repository at this point in the history
* Initial commit

* Re-added EBPF_RETURN_RESULT

* Added EBPF_LOG_EXIT

* Addressed review comments

* Add a new EBPF_RETURN_FUNCTION_RESULT
  • Loading branch information
shpalani committed Nov 15, 2023
1 parent ac50847 commit 43972ae
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
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:
EBPF_OBJECT_RELEASE_REFERENCE((ebpf_core_object_t*)object);
EBPF_RETURN_RESULT(retval);
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

0 comments on commit 43972ae

Please sign in to comment.