Skip to content
New issue

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

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

Already on GitHub? # to your account

Silence missing BPF program error #1393

Merged
merged 1 commit into from
Feb 27, 2024
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 userspace/libpman/src/maps.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static int add_bpf_program_to_tail_table(int tail_table_fd, const char* bpf_prog
if(!bpf_prog)
{
snprintf(error_message, MAX_ERROR_MESSAGE_LEN, "unable to find BPF program '%s'", bpf_prog_name);
pman_print_error((const char*)error_message);
pman_print_msg(FALCOSECURITY_LOG_SEV_DEBUG, (const char*)error_message);

/*
* It's not a hard failure, as programs could be excluded from the
Expand Down
13 changes: 9 additions & 4 deletions userspace/libpman/src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.

struct internal_state g_state = {};

static void log_error(const char* fmt, ...)
static void log_msg(enum falcosecurity_log_severity level, const char* fmt, ...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to use the level inside this function, atm it's not used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/me facepalming

Sure, give me a moment.

{
va_list args;
va_start(args, fmt);
Expand All @@ -34,7 +34,7 @@ static void log_error(const char* fmt, ...)
{
char buf[MAX_ERROR_MESSAGE_LEN];
vsnprintf(buf, sizeof(buf), fmt, args);
g_state.log_fn("libpman", buf, FALCOSECURITY_LOG_SEV_ERROR);
g_state.log_fn("libpman", buf, level);
}
else
{
Expand All @@ -47,6 +47,11 @@ static void log_error(const char* fmt, ...)
}

void pman_print_error(const char* error_message)
{
pman_print_msg(FALCOSECURITY_LOG_SEV_ERROR, error_message);
}

void pman_print_msg(enum falcosecurity_log_severity level, const char* error_message)
{
if(!error_message)
{
Expand All @@ -63,10 +68,10 @@ void pman_print_error(const char* error_message)
* for this error code.
*/
const char* err_str = (errno == ESRCH) ? "Object not found" : strerror(errno);
log_error("%s (errno: %d | message: %s)", error_message, errno, err_str);
log_msg(level, "%s (errno: %d | message: %s)", error_message, errno, err_str);
}
else
{
log_error("%s", error_message);
log_msg(level, "%s", error_message);
}
}
1 change: 1 addition & 0 deletions userspace/libpman/src/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ struct internal_state
extern struct internal_state g_state;

extern void pman_print_error(const char* error_message);
extern void pman_print_msg(enum falcosecurity_log_severity level, const char* error_message);
Loading