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

Tracelog lib does not implement correct keyword switching. #62

Open
gtrevi opened this issue Jun 6, 2024 · 0 comments
Open

Tracelog lib does not implement correct keyword switching. #62

gtrevi opened this issue Jun 6, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request triaged The issue is triaged by the maintainers.
Milestone

Comments

@gtrevi
Copy link
Contributor

gtrevi commented Jun 6, 2024

Apparently, in libs\ebpf_ext\ebpf_ext_tracelog.c no #define EBPF_EXT_****_KEYWORD_SWITCH(...) uses the keyword for the switch parameter, but no caller of those macros passes it.
Like done in the ebpf-for-windows repo, explicitly specifying the keyword parameter would make understanding the flow easier.

For example:

#define EBPF_EXT_LOG_MESSAGE_STRING_KEYWORD_SWITCH(trace_level, message, string_value)       \
    switch (keyword) {                                                                       \
    CASE_BASE:                                                                               \
        _EBPF_EXT_LOG_MESSAGE_STRING(trace_level, KEYWORD_BASE, message, string_value);      \
        break;                                                                               \
    CASE_BIND:                                                                               \
        _EBPF_EXT_LOG_MESSAGE_STRING(trace_level, KEYWORD_BIND, message, string_value);      \
        break;                                                                               \
    CASE_EXT:                                                                                \
        _EBPF_EXT_LOG_MESSAGE_STRING(trace_level, KEYWORD_EXT, message, string_value);       \
        break;                                                                               \
    CASE_SOCK_ADDR:                                                                          \
        _EBPF_EXT_LOG_MESSAGE_STRING(trace_level, KEYWORD_SOCK_ADDR, message, string_value); \
        break;                                                                               \
    CASE_SOCK_OPS:                                                                           \
        _EBPF_EXT_LOG_MESSAGE_STRING(trace_level, KEYWORD_SOCK_OPS, message, string_value);  \
        break;                                                                               \
    CASE_XDP:                                                                                \
        _EBPF_EXT_LOG_MESSAGE_STRING(trace_level, KEYWORD_XDP, message, string_value);       \
        break;                                                                               \
    default:                                                                                 \
        ebpf_assert(!"Invalid keyword");                                                     \
        break;                                                                               \
    }
__declspec(noinline) void ebpf_ext_log_message_string(
    ebpf_ext_tracelog_level_t trace_level,
    ebpf_ext_tracelog_keyword_t keyword,
    _In_z_ const char* message,
    _In_z_ const char* string_value)
{
    switch (trace_level) {
    CASE_LOG_ALWAYS:
        EBPF_EXT_LOG_MESSAGE_STRING_KEYWORD_SWITCH(LEVEL_LOG_ALWAYS, message, string_value);
        break;
    ...
}
@gtrevi gtrevi added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Jun 6, 2024
@Alan-Jowett Alan-Jowett added the triaged The issue is triaged by the maintainers. label Sep 16, 2024
@Alan-Jowett Alan-Jowett added this to the 2410 milestone Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged The issue is triaged by the maintainers.
Projects
None yet
Development

No branches or pull requests

3 participants