Merge pull request #70 from ifupdown-ng/feature/iface-executor-tracing

libifupdown: add interface being run for each executor
This commit is contained in:
Ariadne Conill 2020-09-09 15:52:06 -06:00 committed by GitHub
commit be9857f66f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View file

@ -140,10 +140,10 @@ lif_file_is_executable(const char *path)
} }
bool bool
lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase) lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase, const char *lifname)
{ {
if (opts->verbose) if (opts->verbose)
fprintf(stderr, "ifupdown: attempting to run %s executor for phase %s\n", executor, phase); fprintf(stderr, "ifupdown: %s: attempting to run %s executor for phase %s\n", lifname, executor, phase);
char pathbuf[4096]; char pathbuf[4096];
@ -156,10 +156,10 @@ lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[],
} }
bool bool
lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase) lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase, const char *lifname)
{ {
if (opts->verbose) if (opts->verbose)
fprintf(stderr, "ifupdown: attempting to run %s executor for phase %s\n", executor, phase); fprintf(stderr, "ifupdown: %s: attempting to run %s executor for phase %s\n", lifname, executor, phase);
char pathbuf[4096]; char pathbuf[4096];

View file

@ -32,7 +32,7 @@ struct lif_execute_opts {
extern bool lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...); extern bool lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...);
extern bool lif_execute_fmt_with_result(const struct lif_execute_opts *opts, char *buf, size_t bufsize, char *const envp[], const char *fmt, ...); extern bool lif_execute_fmt_with_result(const struct lif_execute_opts *opts, char *buf, size_t bufsize, char *const envp[], const char *fmt, ...);
extern bool lif_file_is_executable(const char *path); extern bool lif_file_is_executable(const char *path);
extern bool lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase); extern bool lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase, const char *lifname);
extern bool lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase); extern bool lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase, const char *lifname);
#endif #endif

View file

@ -47,13 +47,13 @@ handle_commands_for_phase(const struct lif_execute_opts *opts, char *const envp[
} }
static inline bool static inline bool
handle_single_executor_for_phase(const struct lif_dict_entry *entry, const struct lif_execute_opts *opts, char *const envp[], const char *phase) handle_single_executor_for_phase(const struct lif_dict_entry *entry, const struct lif_execute_opts *opts, char *const envp[], const char *phase, const char *lifname)
{ {
if (strcmp(entry->key, "use")) if (strcmp(entry->key, "use"))
return true; return true;
const char *cmd = entry->data; const char *cmd = entry->data;
if (!lif_maybe_run_executor(opts, envp, cmd, phase)) if (!lif_maybe_run_executor(opts, envp, cmd, phase, lifname))
return false; return false;
return true; return true;
@ -67,12 +67,12 @@ handle_executors_for_phase(const struct lif_execute_opts *opts, char *const envp
if (up) if (up)
{ {
LIF_DICT_FOREACH(iter, &iface->vars) LIF_DICT_FOREACH(iter, &iface->vars)
handle_single_executor_for_phase(iter->data, opts, envp, phase); handle_single_executor_for_phase(iter->data, opts, envp, phase, iface->ifname);
} }
else else
{ {
LIF_DICT_FOREACH_REVERSE(iter, &iface->vars) LIF_DICT_FOREACH_REVERSE(iter, &iface->vars)
handle_single_executor_for_phase(iter->data, opts, envp, phase); handle_single_executor_for_phase(iter->data, opts, envp, phase, iface->ifname);
} }
return true; return true;
@ -97,7 +97,7 @@ query_dependents_from_executors(const struct lif_execute_opts *opts, char *const
continue; continue;
const char *cmd = entry->data; const char *cmd = entry->data;
if (!lif_maybe_run_executor_with_result(&exec_opts, envp, cmd, resbuf, sizeof resbuf, phase)) if (!lif_maybe_run_executor_with_result(&exec_opts, envp, cmd, resbuf, sizeof resbuf, phase, iface->ifname))
return false; return false;
if (!*resbuf) if (!*resbuf)