Set custom LibXDP/LibBPF logging.
This commit is contained in:
@@ -36,14 +36,44 @@ int FindMapFd(struct xdp_program *prog, const char *map_name)
|
||||
return fd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom print function for LibBPF that doesn't print anything (silent mode).
|
||||
*
|
||||
* @param level The current LibBPF log level.
|
||||
* @param format The message format.
|
||||
* @param args Format arguments for the message.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static int silent_libbpf_log(enum libbpf_print_level level, const char *format, va_list args)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets custom LibBPF log mode.
|
||||
*
|
||||
* @param silent If 1, disables LibBPF logging entirely.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void SetLibBPFLogMode(int silent)
|
||||
{
|
||||
if (silent)
|
||||
{
|
||||
libbpf_set_print(silent_libbpf_log);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a BPF object file.
|
||||
*
|
||||
* @param file_name The path to the BPF object file.
|
||||
* @param strict Whether to enable strict mode.
|
||||
*
|
||||
* @return XDP program structure (pointer) or NULL.
|
||||
*/
|
||||
struct xdp_program *LoadBpfObj(const char *file_name)
|
||||
struct xdp_program *LoadBpfObj(const char *file_name, int strict)
|
||||
{
|
||||
struct xdp_program *prog = xdp_program__open_file(file_name, "xdp_prog", NULL);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define XDP_OBJ_PATH "/etc/xdpfw/xdp_prog.o"
|
||||
|
||||
int FindMapFd(struct xdp_program *prog, const char *map_name);
|
||||
struct xdp_program *LoadBpfObj(const char *file_name);
|
||||
void SetLibBPFLogMode(int silent);
|
||||
struct xdp_program *LoadBpfObj(const char *file_name, int strict);
|
||||
int AttachXdp(struct xdp_program *prog, char** mode, int ifidx, u8 detach, cmdline_t *cmd);
|
||||
void UpdateFilters(int filters_map, config__t *cfg);
|
||||
Reference in New Issue
Block a user