diff --git a/client/ifreload.c b/client/ifreload.c index 5130f1d25..0e633b5ac 100644 --- a/client/ifreload.c +++ b/client/ifreload.c @@ -45,6 +45,7 @@ #include "ifup.h" #include "ifdown.h" #include "ifreload.h" +#include "ifstatus.h" static int ni_do_ifreload_direct(int argc, char **argv) @@ -72,6 +73,7 @@ ni_do_ifreload_direct(int argc, char **argv) ni_string_array_t opt_ifconfig = NI_STRING_ARRAY_INIT; ni_ifworker_array_t up_marked = NI_IFWORKER_ARRAY_INIT; ni_ifworker_array_t down_marked = NI_IFWORKER_ARRAY_INIT; + ni_string_array_t ifnames = NI_STRING_ARRAY_INIT; ni_ifmatcher_t ifmatch; ni_bool_t check_prio = TRUE; ni_bool_t opt_persistent = FALSE; @@ -220,6 +222,15 @@ ni_do_ifreload_direct(int argc, char **argv) /* Getting an array of ifworkers matching arguments */ ni_fsm_get_matching_workers(fsm, &ifmatch, &down_marked); + + if (ni_string_eq(ifmatch.name, "all") || + ni_string_empty(ifmatch.name)) { + ni_string_array_destroy(&ifnames); + break; + } + + if (ni_string_array_index(&ifnames, ifmatch.name) == -1) + ni_string_array_append(&ifnames, ifmatch.name); } for (i = 0; i < down_marked.count; ++i) { @@ -295,6 +306,8 @@ ni_do_ifreload_direct(int argc, char **argv) /* Execute the down run */ if (ni_fsm_schedule(fsm) != 0) ni_fsm_mainloop(fsm); + + status = ni_ifstatus_display_result(fsm, &ifnames, opt_transient); } } else { @@ -314,15 +327,13 @@ ni_do_ifreload_direct(int argc, char **argv) if (ni_fsm_schedule(fsm) != 0) ni_fsm_mainloop(fsm); - /* No error if all interfaces were good */ - status = ni_fsm_fail_count(fsm) ? - NI_WICKED_RC_ERROR : NI_WICKED_RC_SUCCESS; + status = ni_ifstatus_display_result(fsm, &ifnames, opt_transient); /* Do not report any transient errors to systemd (e.g. dhcp * or whatever not ready in time) -- returning an error may * cause to stop the network completely. */ - if (!opt_transient) + if (!opt_systemd) status = NI_LSB_RC_SUCCESS; } } @@ -331,6 +342,7 @@ ni_do_ifreload_direct(int argc, char **argv) } cleanup: + ni_string_array_destroy(&ifnames); ni_string_array_destroy(&opt_ifconfig); ni_ifworker_array_destroy(&down_marked); ni_ifworker_array_destroy(&up_marked);