Make sure XDP program has attached at least once.
This commit is contained in:
@@ -187,6 +187,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
int if_idx[MAX_INTERFACES] = {0};
|
int if_idx[MAX_INTERFACES] = {0};
|
||||||
|
int attach_success = 0;
|
||||||
|
|
||||||
// Attach XDP program to interface(s).
|
// Attach XDP program to interface(s).
|
||||||
for (int i = 0; i < cfg.interfaces_cnt; i++)
|
for (int i = 0; i < cfg.interfaces_cnt; i++)
|
||||||
@@ -228,6 +229,18 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
log_msg(&cfg, 1, 0, "Attached XDP program to interface '%s' using mode '%s'...", interface, mode_used);
|
log_msg(&cfg, 1, 0, "Attached XDP program to interface '%s' using mode '%s'...", interface, mode_used);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!attach_success)
|
||||||
|
{
|
||||||
|
attach_success = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!attach_success)
|
||||||
|
{
|
||||||
|
log_msg(&cfg, 0, 1, "[ERROR] Failed to attach XDP program to any configured interfaces.");
|
||||||
|
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_msg(&cfg, 2, 0, "Retrieving BPF map FDs...");
|
log_msg(&cfg, 2, 0, "Retrieving BPF map FDs...");
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static void log_msgRaw(int req_lvl, int cur_lvl, int error, const char* log_path, const char* msg, va_list args)
|
static void log_msg_raw(int req_lvl, int cur_lvl, int error, const char* log_path, const char* msg, va_list args)
|
||||||
{
|
{
|
||||||
if (cur_lvl < req_lvl)
|
if (cur_lvl < req_lvl)
|
||||||
{
|
{
|
||||||
@@ -86,7 +86,7 @@ static void log_msgRaw(int req_lvl, int cur_lvl, int error, const char* log_path
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a log message using log_msgRaw().
|
* Prints a log message using log_msg_raw().
|
||||||
*
|
*
|
||||||
* @param cfg A pointer to the config structure.
|
* @param cfg A pointer to the config structure.
|
||||||
* @param req_lvl The required level for this message.
|
* @param req_lvl The required level for this message.
|
||||||
@@ -100,7 +100,7 @@ void log_msg(config__t* cfg, int req_lvl, int error, const char* msg, ...)
|
|||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
|
|
||||||
log_msgRaw(req_lvl, cfg->verbose, error, (const char*)cfg->log_file, msg, args);
|
log_msg_raw(req_lvl, cfg->verbose, error, (const char*)cfg->log_file, msg, args);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user