+ /* Linux 5.15+: make sure the tables are loaded and
+ * /proc/net/ip{,6}_tables_names are thus populated.
+ */
+ for (table = FW3_TABLE_FILTER; table <= FW3_TABLE_RAW; table++)
+ {
+ if (!(handle = fw3_ipt_open(family, table)))
+ continue;
+
+ fw3_ipt_close(handle);
+ }
+
+ 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(" * Populating %s %s table",
+ fw3_flag_names[family], fw3_flag_names[table]);
+
+ fw3_print_default_chains(handle, cfg_state, false);
+ fw3_print_zone_chains(handle, cfg_state, false);
+ fw3_print_default_head_rules(handle, cfg_state, false);
+ fw3_print_rules(handle, cfg_state);
+ fw3_print_redirects(handle, cfg_state);
+ fw3_print_snats(handle, cfg_state);
+ fw3_print_forwards(handle, cfg_state);
+ fw3_print_zone_rules(handle, cfg_state, false);
+ fw3_print_default_tail_rules(handle, cfg_state, false);
+
+ if (!print_family)
+ fw3_ipt_commit(handle);
+
+ fw3_ipt_close(handle);
+ }
+
+ if (!print_family)
+ fw3_print_includes(cfg_state, family, false);
+
+ family_set(run_state, family, true);
+ family_set(cfg_state, family, true);
+
+ rv = 0;
+ }
+
+ if (!rv)
+ {
+ fw3_flush_conntrack(run_state);
+ fw3_set_defaults(cfg_state);
+
+ if (!print_family)
+ {
+ 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 (!run_state)
+ return start();
+
+ 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]);
+
+ fw3_flush_rules(handle, run_state, true);
+ fw3_flush_zones(handle, run_state, true);
+ fw3_ipt_commit(handle);
+ fw3_ipt_close(handle);
+ }
+
+ fw3_ipsets_update_run_state(family, run_state, cfg_state);
+ fw3_destroy_ipsets(run_state, family, true);
+
+ family_set(run_state, family, false);
+ family_set(cfg_state, family, false);
+
+start:
+ if (family == FW3_FAMILY_V6 && cfg_state->defaults.disable_ipv6)
+ continue;
+
+ fw3_create_ipsets(cfg_state, family, true);