]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd: sort pim_ifchannel_list
authorDaniel Walton <dwalton@cumulusnetworks.com>
Wed, 28 Sep 2016 00:40:58 +0000 (00:40 +0000)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:10 +0000 (20:26 -0500)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_iface.c
pimd/pim_ifchannel.c

index e55ef30b31babf61b180a7868e1cf7571210f738..b6012d1ed189c7b8565ec0fbac91badd73fd0bd5 100644 (file)
@@ -72,6 +72,24 @@ static void *if_list_clean(struct pim_interface *pim_ifp)
   return 0;
 }
 
+static int
+pim_ifchannel_compare (struct pim_ifchannel *ch1, struct pim_ifchannel *ch2)
+{
+   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;
+
+   if (ntohl(ch1->sg.src.s_addr) < ntohl(ch2->sg.src.s_addr))
+     return -1;
+
+   if (ntohl(ch1->sg.src.s_addr) > ntohl(ch2->sg.src.s_addr))
+     return 1;
+
+  return 0;
+}
+
 struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim)
 {
   struct pim_interface *pim_ifp;
@@ -142,6 +160,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim)
     return if_list_clean(pim_ifp);
   }
   pim_ifp->pim_ifchannel_list->del = (void (*)(void *)) pim_ifchannel_free;
+  pim_ifp->pim_ifchannel_list->cmp = (int (*)(void *, void *)) pim_ifchannel_compare;
 
   ifp->info = pim_ifp;
 
index 1bc10f4ccef19770857a544b53aa5e041f788283..ee388b7d68c05ed482c1f0c4ac50748e87872abc 100644 (file)
@@ -429,7 +429,7 @@ pim_ifchannel_add(struct interface *ifp,
     PIM_IF_FLAG_UNSET_ASSERT_TRACKING_DESIRED(ch->flags);
 
   /* Attach to list */
-  listnode_add(pim_ifp->pim_ifchannel_list, ch);
+  listnode_add_sort(pim_ifp->pim_ifchannel_list, ch);
 
   zassert(IFCHANNEL_NOINFO(ch));