projects
/
project
/
firewall3.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Replace fw3_free_zone() with the generic implementation
[project/firewall3.git]
/
zones.c
diff --git
a/zones.c
b/zones.c
index
979d150
..
4de6625
100644
(file)
--- a/
zones.c
+++ b/
zones.c
@@
-189,6
+189,14
@@
fw3_load_zones(struct fw3_state *state, struct uci_package *p)
continue;
}
continue;
}
+ if (strlen(zone->name) > FW3_ZONE_MAXNAMELEN)
+ {
+ warn_elem(e, "must not have a name longer than %u characters",
+ FW3_ZONE_MAXNAMELEN);
+ fw3_free_zone(zone);
+ continue;
+ }
+
if (list_empty(&zone->networks) && list_empty(&zone->devices) &&
list_empty(&zone->subnets) && !zone->extra_src)
{
if (list_empty(&zone->networks) && list_empty(&zone->devices) &&
list_empty(&zone->subnets) && !zone->extra_src)
{
@@
-574,7
+582,7
@@
fw3_flush_zones(struct fw3_ipt_handle *handle, struct fw3_state *state,
for (c = zone_chains; c->format; c++)
{
/* don't touch user chains on selective stop */
for (c = zone_chains; c->format; c++)
{
/* don't touch user chains on selective stop */
- if (reload &&
hasbit(c->flag, FW3_FLAG_CUSTOM_CHAINS)
)
+ if (reload &&
c->flag == FW3_FLAG_CUSTOM_CHAINS
)
continue;
if (!fw3_is_family(c, handle->family))
continue;
if (!fw3_is_family(c, handle->family))
@@
-583,6
+591,9
@@
fw3_flush_zones(struct fw3_ipt_handle *handle, struct fw3_state *state,
if (c->table != handle->table)
continue;
if (c->table != handle->table)
continue;
+ if (c->flag && !has(z->flags, handle->family, c->flag))
+ continue;
+
snprintf(chain, sizeof(chain), c->format, z->name);
fw3_ipt_delete_rules(handle, chain);
fw3_ipt_delete_chain(handle, chain);
snprintf(chain, sizeof(chain), c->format, z->name);
fw3_ipt_delete_rules(handle, chain);
fw3_ipt_delete_chain(handle, chain);
@@
-632,22
+643,47
@@
fw3_lookup_zone(struct fw3_state *state, const char *name)
return NULL;
}
return NULL;
}
-void
-fw3_
free_zone
(struct fw3_zone *zone)
+struct list_head *
+fw3_
resolve_zone_addresses
(struct fw3_zone *zone)
{
{
- struct fw3_device *dev, *tmp;
+ struct fw3_device *net;
+ struct fw3_address *addr, *tmp;
+ struct list_head *addrs, *all;
+
+ all = malloc(sizeof(*all));
+
+ if (!all)
+ return NULL;
+
+ memset(all, 0, sizeof(*all));
+ INIT_LIST_HEAD(all);
- list_for_each_entry
_safe(dev, tmp, &zone->device
s, list)
+ list_for_each_entry
(net, &zone->network
s, list)
{
{
- list_del(&dev->list);
- free(dev);
+ 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);
}
}
- list_for_each_entry
_safe(dev, tmp, &zone->network
s, list)
+ list_for_each_entry
(addr, &zone->subnet
s, list)
{
{
- list_del(&dev->list);
- free(dev);
+ tmp = malloc(sizeof(*tmp));
+
+ if (!tmp)
+ continue;
+
+ memcpy(tmp, addr, sizeof(*tmp));
+ list_add_tail(&tmp->list, all);
}
}
-
fw3_free_object(zone, fw3_zone_opts)
;
+
return all
;
}
}