diff options
author | Tony Ambardar <itugrok@yahoo.com> | 2021-03-21 18:06:18 -0700 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-03-23 09:59:37 +0100 |
commit | 7b844f4fb361d28ffebc95bc305347d6450569f6 (patch) | |
tree | 9e73bc56c66dbe52731eafcdc8b6555da6787df9 | |
parent | c2c72c6fc29cb895f25759d76e10c00a8faaa148 (diff) | |
download | firewall3-7b844f4fb361d28ffebc95bc305347d6450569f6.tar.gz |
zone: avoid duplicates in devices list
While resolving zones to devices it's possible to introduce duplicates due
to the presence of aliased interfaces.
Fix this by consolidating the fw3_zone->devices list during creation.
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
-rw-r--r-- | zones.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -137,7 +137,7 @@ check_masq_addrs(struct list_head *head) static void resolve_networks(struct uci_element *e, struct fw3_zone *zone) { - struct fw3_device *net, *tmp; + struct fw3_device *net, *dev, *tmp; list_for_each_entry(net, &zone->networks, list) { @@ -149,8 +149,15 @@ resolve_networks(struct uci_element *e, struct fw3_zone *zone) continue; } + list_for_each_entry(dev, &zone->devices, list) + if (!strcmp(dev->name, tmp->name)) + goto alias; + snprintf(tmp->network, sizeof(tmp->network), "%s", net->name); list_add_tail(&tmp->list, &zone->devices); + continue; +alias: + free(tmp); } } |