diff --git a/cmd/ifupdown.c b/cmd/ifupdown.c index 9124320..6405cbf 100644 --- a/cmd/ifupdown.c +++ b/cmd/ifupdown.c @@ -96,6 +96,9 @@ acquire_state_lock(const char *state_path, const char *lifname) bool skip_interface(struct lif_interface *iface, const char *ifname) { + if (exec_opts.force) + return false; + if (up && iface->refcount > 0) { fprintf(stderr, "%s: skipping %s (already configured), use --force to force configuration\n", diff --git a/cmd/multicall-exec-options.c b/cmd/multicall-exec-options.c index cd57a22..f56228c 100644 --- a/cmd/multicall-exec-options.c +++ b/cmd/multicall-exec-options.c @@ -68,13 +68,14 @@ set_no_lock(const char *opt_arg) } static void -no_op(const char *opt_arg) +set_force(const char *opt_arg) { (void) opt_arg; + exec_opts.force = true; } static struct if_option exec_options[] = { - {'f', "force", NULL, "force (de)configuration", false, no_op}, + {'f', "force", NULL, "force (de)configuration", false, set_force}, {'i', "interfaces", "interfaces FILE", "use FILE for interface definitions", true, set_interfaces_file}, {'l', "no-lock", NULL, "do not use a lockfile to serialize state changes", false, set_no_lock}, {'n', "no-act", NULL, "do not actually run any commands", false, set_no_act}, diff --git a/libifupdown/execute.h b/libifupdown/execute.h index fa4af78..89b9815 100644 --- a/libifupdown/execute.h +++ b/libifupdown/execute.h @@ -23,6 +23,7 @@ struct lif_execute_opts { bool verbose; bool mock; bool no_lock; + bool force; const char *executor_path; const char *interfaces_file; const char *state_file;