struct fw3_state *state = NULL;
struct uci_package *p = NULL;
+ if (!fw3_ubus_connect())
+ error("Failed to connect to ubus");
+
state = malloc(sizeof(*state));
if (!state)
}
static int
-start(struct fw3_state *state, bool restart)
+start(struct fw3_state *state, bool reload)
{
int rv = 1;
enum fw3_family family;
enum fw3_table table;
- if (!print_rules && !restart &&
+ if (!print_rules && !reload &&
fw3_command_pipe(false, "ipset", "-exist", "-"))
{
fw3_create_ipsets(state);
if (!family_used(family))
continue;
- if (!print_rules && !restart && family_running(state, family))
+ if (!print_rules && !reload && family_running(state, family))
{
warn("The %s firewall appears to be started already. "
"If it is indeed empty, remove the %s file and retry.",
fw3_pr("COMMIT\n");
}
+ if (!reload)
+ fw3_print_includes(family, state);
+
fw3_command_close();
family_set(state, family, true);
rv = 0;
}
+ if (!reload && !print_rules)
+ fw3_run_includes(state);
+
if (!rv && !print_rules)
fw3_write_statefile(state);
static int
usage(void)
{
- fprintf(stderr, "fw3 [-4] [-6] [-q] {start|stop|flush|restart|print}\n");
+ fprintf(stderr, "fw3 [-4] [-6] [-q] {start|stop|flush|reload|restart|print}\n");
fprintf(stderr, "fw3 [-q] network {net}\n");
fprintf(stderr, "fw3 [-q] device {dev}\n");
}
}
- if (!fw3_ubus_connect())
- error("Failed to connect to ubus");
-
state = build_state();
defs = &state->defaults;
}
else if (!strcmp(argv[optind], "restart"))
{
+ stop(state, true, false);
+ free_state(state);
+
+ state = build_state();
+ rv = start(state, false);
+ }
+ else if (!strcmp(argv[optind], "reload"))
+ {
rv = stop(state, false, true);
rv = start(state, !rv);
}