]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospf6d: Fix multi nexthop route remove
authorChirag Shah <chirag@cumulusnetworks.com>
Fri, 1 Dec 2017 01:45:12 +0000 (17:45 -0800)
committerChirag Shah <chirag@cumulusnetworks.com>
Wed, 6 Dec 2017 21:12:22 +0000 (13:12 -0800)
Fix sorting of route storage to DB.
Fix two list comparison which allows route with
multiple nexthop to updates.

Ticket:CM-19025
Testing Done:
Configured a topology where ospf6 learn
ecmp route via one neighbor and upon removal
of intra-prefix route from origin, DUT removes
ECMP intra-prefix route from RIB.

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
ospf6d/ospf6_route.c

index 3c77c483ea07ea18fb26b930da75db9faf2923fa..281757222dd1d1b595ef7083af19a4144ab84062 100644 (file)
@@ -241,18 +241,25 @@ int ospf6_route_cmp_nexthops(struct ospf6_route *a, struct ospf6_route *b)
 {
        struct listnode *anode, *bnode;
        struct ospf6_nexthop *anh, *bnh;
+       bool identical = false;
 
        if (a && b) {
                if (listcount(a->nh_list) == listcount(b->nh_list)) {
                        for (ALL_LIST_ELEMENTS_RO(a->nh_list, anode, anh)) {
+                               identical = false;
                                for (ALL_LIST_ELEMENTS_RO(b->nh_list, bnode,
-                                                         bnh))
-                                       if (!ospf6_nexthop_is_same(anh, bnh))
-                                               return (1);
+                                                         bnh)) {
+                                       if (ospf6_nexthop_is_same(anh, bnh))
+                                               identical = true;
+                               }
+                               /* Currnet List A element not found List B
+                                * Non-Identical lists return */
+                               if (identical == false)
+                                       return 1;
                        }
-                       return (0);
+                       return 0;
                } else
-                       return (1);
+                       return 1;
        }
        /* One of the routes doesn't exist ? */
        return (1);
@@ -333,9 +340,14 @@ int ospf6_route_get_first_nh_index(struct ospf6_route *route)
 
 static int ospf6_nexthop_cmp(struct ospf6_nexthop *a, struct ospf6_nexthop *b)
 {
-       if ((a)->ifindex == (b)->ifindex &&
-           IN6_ARE_ADDR_EQUAL(&(a)->address, &(b)->address))
+       if (a->ifindex < b->ifindex)
+               return -1;
+       else if (a->ifindex > b->ifindex)
                return 1;
+       else
+               return memcmp(&a->address, &b->address,
+                             sizeof(struct in6_addr));
+
        return 0;
 }