X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=blobdiff_plain;f=redirects.c;fp=redirects.c;h=080e2c17d49fc1117d1467260ab81cda0eb9b8d6;hp=f1fa1f431a79d8bb11daeaec5a7be9854933fc6d;hb=92281eb747b56e748b7c3d754055919c23befdd4;hpb=a9c694d5b6ea026a0c745e5b650993bf0f1c13dc diff --git a/redirects.c b/redirects.c index f1fa1f4..080e2c1 100644 --- a/redirects.c +++ b/redirects.c @@ -171,8 +171,7 @@ check_local(struct uci_element *e, struct fw3_redirect *redir, { struct fw3_zone *zone; struct fw3_device *net; - struct fw3_address *addr; - struct list_head *addrs; + struct fw3_address *addr, *tmp; if (redir->target != FW3_FLAG_DNAT) return false; @@ -187,25 +186,23 @@ check_local(struct uci_element *e, struct fw3_redirect *redir, { list_for_each_entry(net, &zone->networks, list) { - addrs = fw3_ubus_address(net->name); - - if (!addrs) - continue; + LIST_HEAD(addrs); - list_for_each_entry(addr, addrs, list) + fw3_ubus_address(&addrs, net->name); + list_for_each_entry_safe(addr, tmp, &addrs, list) { - if (!compare_addr(&redir->ip_redir, addr)) - continue; + if (compare_addr(&redir->ip_redir, addr)) { + warn_elem(e, "refers to a destination address on this router, " + "assuming port redirection"); - warn_elem(e, "refers to a destination address on this router, " - "assuming port redirection"); + redir->local = true; + continue; + } - redir->local = true; - break; + list_del(&addr->list); + free(addr); } - fw3_free_list(addrs); - if (redir->local) return true; }