]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/interface.c
Merge pull request #5412 from opensourcerouting/bfdd-vrf-fix
[mirror_frr.git] / ldpd / interface.c
index a064a58b2e15c5fd44a2ee9685a8de9a9a22e985..8b45703d22f7e3b535dbcd96ad8e202a515d7f06 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "sockopt.h"
 
-static __inline int     iface_compare(struct iface *, struct iface *);
+static __inline int     iface_compare(const struct iface *, const struct iface *);
 static struct if_addr  *if_addr_new(struct kaddr *);
 static struct if_addr  *if_addr_lookup(struct if_addr_head *, struct kaddr *);
 static int              if_start(struct iface *, int);
@@ -43,9 +43,9 @@ static int             if_leave_ipv6_group(struct iface *, struct in6_addr *);
 RB_GENERATE(iface_head, iface, entry, iface_compare)
 
 static __inline int
-iface_compare(struct iface *a, struct iface *b)
+iface_compare(const struct iface *a, const struct iface *b)
 {
-       return (strcmp(a->name, b->name));
+       return if_cmp_name_func(a->name, b->name);
 }
 
 struct iface *
@@ -81,12 +81,12 @@ ldpe_if_init(struct iface *iface)
        /* ipv4 */
        iface->ipv4.iface = iface;
        iface->ipv4.state = IF_STA_DOWN;
-       RB_INIT(&iface->ipv4.adj_tree);
+       RB_INIT(ia_adj_head, &iface->ipv4.adj_tree);
 
        /* ipv6 */
        iface->ipv6.iface = iface;
        iface->ipv6.state = IF_STA_DOWN;
-       RB_INIT(&iface->ipv6.adj_tree);
+       RB_INIT(ia_adj_head, &iface->ipv6.adj_tree);
 }
 
 void
@@ -103,6 +103,7 @@ ldpe_if_exit(struct iface *iface)
 
        while ((if_addr = LIST_FIRST(&iface->addr_list)) != NULL) {
                LIST_REMOVE(if_addr, entry);
+               assert(if_addr != LIST_FIRST(&iface->addr_list));
                free(if_addr);
        }
 }
@@ -305,8 +306,11 @@ if_reset(struct iface *iface, int af)
        ia = iface_af_get(iface, af);
        if_stop_hello_timer(ia);
 
-       while ((adj = RB_ROOT(&ia->adj_tree)) != NULL)
+       while (!RB_EMPTY(ia_adj_head, &ia->adj_tree)) {
+               adj = RB_ROOT(ia_adj_head, &ia->adj_tree);
+
                adj_del(adj, S_SHUTDOWN);
+       }
 
        /* try to cleanup */
        switch (af) {