X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=zones.c;h=6ab3d12176e49c6c7a85dc8f4050280ed2bc538a;hb=0aaf63b89efb27bfa370aabc7550de10335abbe3;hp=982424930a365887fe657b4c06c2d817ffed3d57;hpb=d54cb962ebafdf2fde7256e234a2f3cfe8223c71;p=project%2Ffirewall3.git diff --git a/zones.c b/zones.c index 9824249..6ab3d12 100644 --- a/zones.c +++ b/zones.c @@ -128,13 +128,10 @@ fw3_alloc_zone(void) { struct fw3_zone *zone; - zone = malloc(sizeof(*zone)); - + zone = calloc(1, sizeof(*zone)); if (!zone) return NULL; - memset(zone, 0, sizeof(*zone)); - INIT_LIST_HEAD(&zone->networks); INIT_LIST_HEAD(&zone->devices); INIT_LIST_HEAD(&zone->subnets); @@ -477,11 +474,13 @@ print_zone_rule(struct fw3_ipt_handle *handle, struct fw3_state *state, { r = fw3_ipt_rule_new(handle); fw3_ipt_rule_extra(r, "-m conntrack --ctstate DNAT"); + fw3_ipt_rule_comment(r, "Accept port redirections"); fw3_ipt_rule_target(r, fw3_flag_names[FW3_FLAG_ACCEPT]); fw3_ipt_rule_append(r, "zone_%s_input", zone->name); r = fw3_ipt_rule_new(handle); fw3_ipt_rule_extra(r, "-m conntrack --ctstate DNAT"); + fw3_ipt_rule_comment(r, "Accept port forwards"); fw3_ipt_rule_target(r, fw3_flag_names[FW3_FLAG_ACCEPT]); fw3_ipt_rule_append(r, "zone_%s_forward", zone->name); } @@ -679,31 +678,16 @@ fw3_resolve_zone_addresses(struct fw3_zone *zone) { struct fw3_device *net; struct fw3_address *addr, *tmp; - struct list_head *addrs, *all; - - all = malloc(sizeof(*all)); + struct list_head *all; + all = calloc(1, sizeof(*all)); if (!all) return NULL; - memset(all, 0, sizeof(*all)); INIT_LIST_HEAD(all); list_for_each_entry(net, &zone->networks, list) - { - addrs = fw3_ubus_address(net->name); - - if (!addrs) - continue; - - list_for_each_entry_safe(addr, tmp, addrs, list) - { - list_del(&addr->list); - list_add_tail(&addr->list, all); - } - - free(addrs); - } + fw3_ubus_address(all, net->name); list_for_each_entry(addr, &zone->subnets, list) {