/*
* firewall3 - 3rd OpenWrt UCI firewall implementation
*
- * Copyright (C) 2013-2014 Jo-Philipp Wich <jow@openwrt.org>
+ * Copyright (C) 2013-2014 Jo-Philipp Wich <jo@mein.io>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
#include "includes.h"
#include "ubus.h"
#include "iptables.h"
+#include "helpers.h"
static enum fw3_family print_family = FW3_FAMILY_ANY;
else
{
if (!fw3_ubus_connect())
- error("Failed to connect to ubus");
+ warn("Failed to connect to ubus");
if (uci_load(state->uci, "firewall", &p))
{
fw3_ubus_rules(&b);
fw3_load_defaults(state, p);
- fw3_load_ipsets(state, p);
+ fw3_load_cthelpers(state, p);
+ fw3_load_ipsets(state, p, b.head);
fw3_load_zones(state, p);
fw3_load_rules(state, p, b.head);
- fw3_load_redirects(state, p);
+ fw3_load_redirects(state, p, b.head);
fw3_load_snats(state, p, b.head);
- fw3_load_forwards(state, p);
- fw3_load_includes(state, p);
+ fw3_load_forwards(state, p, b.head);
+ fw3_load_includes(state, p, b.head);
return true;
}
list_for_each_safe(cur, tmp, &state->includes)
fw3_free_include((struct fw3_include *)cur);
+ list_for_each_safe(cur, tmp, &state->cthelpers)
+ fw3_free_cthelper((struct fw3_cthelper *)cur);
+
uci_free_context(state->uci);
free(state);
}
build_state(false);
- build_state(true);
defs = &cfg_state->defaults;
if (optind >= argc)
print_family = family;
fw3_pr_debug = true;
- rv = start();
+ if (fw3_lock())
+ {
+ build_state(true);
+ rv = start();
+ fw3_unlock();
+ }
}
else if (!strcmp(argv[optind], "start"))
{
if (fw3_lock())
{
+ build_state(true);
rv = start();
fw3_unlock();
}
{
if (fw3_lock())
{
+ build_state(true);
rv = stop(false);
fw3_unlock();
}
{
if (fw3_lock())
{
+ build_state(true);
rv = stop(true);
fw3_unlock();
}
{
if (fw3_lock())
{
+ build_state(true);
stop(true);
rv = start();
fw3_unlock();
{
if (fw3_lock())
{
+ build_state(true);
rv = reload();
fw3_unlock();
}