main: avoid adding redundant interfaces
authorMarkus <markus@dd-wrt.com>
Wed, 3 Feb 2016 13:29:48 +0000 (14:29 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 3 Feb 2016 13:35:48 +0000 (14:35 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
main.c

diff --git a/main.c b/main.c
index bd330ee0581be961588e4336ca1a893835776690..b3c13f7f7a49f3693df2efa1adfcae8dbaba56cf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -653,6 +653,11 @@ static struct relayd_interface *alloc_interface(const char *ifname, bool managed
        if (strlen(ifname) >= IFNAMSIZ)
                return NULL;
 
+       list_for_each_entry(rif, &interfaces, list) {
+               if (!strncmp(rif->ifname, ifname, IFNAMSIZ))
+                       return rif;
+       }
+
        rif = calloc(1, sizeof(*rif));
        if (!rif)
                return NULL;