From f867df185a204d9b96d444e7f119bcbac09d5ec7 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Thu, 30 Nov 2017 17:45:12 -0800 Subject: [PATCH] ospf6d: Fix multi nexthop route remove 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 --- ospf6d/ospf6_route.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 3c77c483ea..281757222d 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -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; } -- 2.39.5