FW3_OPT("tcp_syncookies", bool, defaults, tcp_syncookies),
FW3_OPT("tcp_ecn", bool, defaults, tcp_ecn),
- FW3_OPT("tcp_westwood", bool, defaults, tcp_westwood),
FW3_OPT("tcp_window_scaling", bool, defaults, tcp_window_scaling),
FW3_OPT("accept_redirects", bool, defaults, accept_redirects),
struct fw3_state *state)
{
struct fw3_defaults *defs = &state->defaults;
+ uint16_t mask = ~0;
#define policy(t) \
((t == FW3_TARGET_REJECT) ? "DROP" : fw3_flag_names[t])
fw3_pr(":OUTPUT %s [0:0]\n", policy(defs->policy_output));
}
- print_chains(table, family, ":%s - [0:0]\n", defs->flags,
+ /* user chains already loaded, don't create again */
+ if (hasbit(state->running_defaults.flags, FW3_DEFAULT_CUSTOM_CHAINS))
+ delbit(mask, FW3_DEFAULT_CUSTOM_CHAINS);
+
+ print_chains(table, family, ":%s - [0:0]\n", defs->flags & mask,
default_chains, ARRAY_SIZE(default_chains));
}
}
static void
+set_default(const char *name, bool set)
+{
+ FILE *f;
+ char path[sizeof("/proc/sys/net/ipv4/tcp_window_scaling\0")];
+
+ snprintf(path, sizeof(path), "/proc/sys/net/ipv4/tcp_%s", name);
+
+ info(" * Set tcp_%s to %s", name, set ? "on" : "off", name);
+
+ if (!(f = fopen(path, "w")))
+ {
+ info(" ! Unable to write value: %s", strerror(errno));
+ return;
+ }
+
+ fprintf(f, "%u\n", set);
+ fclose(f);
+}
+
+void
+fw3_set_defaults(struct fw3_state *state)
+{
+ info("Setting sysctl values");
+
+ set_default("ecn", state->defaults.tcp_ecn);
+ set_default("syncookies", state->defaults.tcp_syncookies);
+ set_default("window_scaling", state->defaults.tcp_window_scaling);
+}
+
+static void
reset_policy(enum fw3_table table)
{
if (table != FW3_TABLE_FILTER)
bool pass2, struct fw3_state *state)
{
struct fw3_defaults *d = &state->running_defaults;
+ uint16_t mask = ~0;
if (!hasbit(d->flags, family))
return;
+ /* don't touch user chains on selective stop */
+ delbit(mask, FW3_DEFAULT_CUSTOM_CHAINS);
+
if (!pass2)
{
reset_policy(table);
- print_chains(table, family, "-D %s\n", state->running_defaults.flags,
+ print_chains(table, family, "-D %s\n", d->flags & mask,
toplevel_rules, ARRAY_SIZE(toplevel_rules));
- print_chains(table, family, "-F %s\n", state->running_defaults.flags,
+ print_chains(table, family, "-F %s\n", d->flags & mask,
default_chains, ARRAY_SIZE(default_chains));
}
else
{
- print_chains(table, family, "-X %s\n", state->running_defaults.flags,
+ print_chains(table, family, "-X %s\n", d->flags & mask,
default_chains, ARRAY_SIZE(default_chains));
delbit(d->flags, family);