+ family_set(run_state, family, true);
+ family_set(cfg_state, family, true);
+
+ rv = 0;
+ }
+
+ if (!rv)
+ {
+ fw3_set_defaults(cfg_state);
+
+ if (!print_rules)
+ {
+ fw3_run_includes(cfg_state, false);
+ fw3_hotplug_zones(cfg_state, true);
+ fw3_write_statefile(cfg_state);
+ }
+ }
+
+ return rv;
+}
+
+
+static int
+reload(void)
+{
+ int rv = 1;
+ enum fw3_family family;
+ enum fw3_table table;
+ struct fw3_ipt_handle *handle;
+
+ if (!print_rules && run_state)
+ fw3_hotplug_zones(run_state, false);
+
+ for (family = FW3_FAMILY_V4; family <= FW3_FAMILY_V6; family++)
+ {
+ if (!family_running(family))
+ goto start;
+
+ for (table = FW3_TABLE_FILTER; table <= FW3_TABLE_RAW; table++)
+ {
+ if (!fw3_has_table(family == FW3_FAMILY_V6, fw3_flag_names[table]))
+ continue;
+
+ if (!(handle = fw3_ipt_open(family, table)))
+ continue;
+
+ info(" * Clearing %s %s table",
+ fw3_flag_names[family], fw3_flag_names[table]);
+
+ if (run_state)
+ {
+ fw3_flush_rules(handle, run_state, true);
+ fw3_flush_zones(handle, run_state, true);
+ }
+
+ fw3_ipt_commit(handle);
+ }
+
+ family_set(run_state, family, false);
+ family_set(cfg_state, family, false);
+
+start:
+ if (!restore_pipe(family, true))
+ continue;
+
+ if (family == FW3_FAMILY_V6 && cfg_state->defaults.disable_ipv6)
+ goto skip;
+
+ for (table = FW3_TABLE_FILTER; table <= FW3_TABLE_RAW; table++)
+ {
+ if (!fw3_has_table(family == FW3_FAMILY_V6, fw3_flag_names[table]))
+ continue;
+
+ info(" * Populating %s %s table",
+ fw3_flag_names[family], fw3_flag_names[table]);
+
+ fw3_pr("*%s\n", fw3_flag_names[table]);
+ fw3_print_default_chains(cfg_state, family, table, true);
+ fw3_print_zone_chains(cfg_state, family, table, true);
+ fw3_print_default_head_rules(cfg_state, family, table, true);
+ fw3_print_rules(cfg_state, family, table);
+ fw3_print_redirects(cfg_state, family, table);
+ fw3_print_forwards(cfg_state, family, table);
+ fw3_print_zone_rules(cfg_state, family, table, true);
+ fw3_print_default_tail_rules(cfg_state, family, table, true);
+ fw3_pr("COMMIT\n");
+ }
+
+ fw3_print_includes(cfg_state, family, true);
+
+ family_set(run_state, family, true);
+ family_set(cfg_state, family, true);