From e3a55f03bf83ff637ab12d997376fb6442a07163 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 20 Apr 2017 12:21:02 -0400 Subject: [PATCH] pimd: Tweak pim_ifchannel_compare to be faster Tweak the ifchannel compare to sort based upon interface first Ticket: CM-15629 Signed-off-by: Donald Sharp --- pimd/pim_ifchannel.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index ab01c7f13e..c87320d0f8 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -50,30 +50,25 @@ pim_ifchannel_compare (struct pim_ifchannel *ch1, struct pim_ifchannel *ch2) struct pim_interface *pim_ifp1; struct pim_interface *pim_ifp2; - if (ntohl(ch1->sg.grp.s_addr) < ntohl(ch2->sg.grp.s_addr)) - return -1; - - if (ntohl(ch1->sg.grp.s_addr) > ntohl(ch2->sg.grp.s_addr)) - return 1; + pim_ifp1 = ch1->interface->info; + pim_ifp2 = ch2->interface->info; - if (ntohl(ch1->sg.src.s_addr) < ntohl(ch2->sg.src.s_addr)) + if (pim_ifp1->mroute_vif_index < pim_ifp2->mroute_vif_index) return -1; - if (ntohl(ch1->sg.src.s_addr) > ntohl(ch2->sg.src.s_addr)) + if (pim_ifp1->mroute_vif_index > pim_ifp2->mroute_vif_index) return 1; - pim_ifp1 = ch1->interface->info; - pim_ifp2 = ch2->interface->info; - if (ntohl(pim_ifp1->primary_address.s_addr) < ntohl(pim_ifp2->primary_address.s_addr)) + if (ntohl(ch1->sg.grp.s_addr) < ntohl(ch2->sg.grp.s_addr)) return -1; - if (ntohl(pim_ifp1->primary_address.s_addr) > ntohl(pim_ifp2->primary_address.s_addr)) + if (ntohl(ch1->sg.grp.s_addr) > ntohl(ch2->sg.grp.s_addr)) return 1; - if (pim_ifp1->mroute_vif_index < pim_ifp2->mroute_vif_index) + if (ntohl(ch1->sg.src.s_addr) < ntohl(ch2->sg.src.s_addr)) return -1; - if (pim_ifp1->mroute_vif_index > pim_ifp2->mroute_vif_index) + if (ntohl(ch1->sg.src.s_addr) > ntohl(ch2->sg.src.s_addr)) return 1; return 0; -- 2.39.5