]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Add upstream children finding
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 2 Aug 2016 15:21:49 +0000 (11:21 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:04 +0000 (20:26 -0500)
When we receive a *,g find all S,G that
are related and set pointer appropriately

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_upstream.c

index 7b87bdac736e2e4754dc8cbd5cae351684d0a4d6..e71f856aa3d4e88c04b3b185f02e8eb2e6054d4c 100644 (file)
 static void join_timer_start(struct pim_upstream *up);
 static void pim_upstream_update_assert_tracking_desired(struct pim_upstream *up);
 
+/*
+ * A (*,G) or a (*,*) is going away
+ * remove the parent pointer from
+ * those pointing at us
+ */
+static void
+pim_upstream_remove_children (struct pim_upstream *up)
+{
+  struct listnode *ch_node;
+  struct pim_upstream *child;
+
+  // Basic sanity, (*,*) not currently supported
+  if ((up->sg.u.sg.src.s_addr == INADDR_ANY) &&
+      (up->sg.u.sg.grp.s_addr == INADDR_ANY))
+    return;
+
+  // Basic sanity (S,G) have no children
+  if ((up->sg.u.sg.src.s_addr != INADDR_ANY) &&
+      (up->sg.u.sg.grp.s_addr != INADDR_ANY))
+    return;
+
+  for (ALL_LIST_ELEMENTS_RO (qpim_upstream_list, ch_node, child))
+    {
+      if (child->parent == up)
+        child->parent = NULL;
+    }
+}
+
+/*
+ * A (*,G) or a (*,*) is being created
+ * Find the children that would point
+ * at us.
+ */
+static void
+pim_upstream_find_new_children (struct pim_upstream *up)
+{
+  struct pim_upstream *child;
+  struct listnode *ch_node;
+
+  if ((up->sg.u.sg.src.s_addr != INADDR_ANY) &&
+      (up->sg.u.sg.grp.s_addr != INADDR_ANY))
+    return;
+
+  if ((up->sg.u.sg.src.s_addr == INADDR_ANY) &&
+      (up->sg.u.sg.grp.s_addr == INADDR_ANY))
+    return;
+
+  for (ALL_LIST_ELEMENTS_RO (qpim_upstream_list, ch_node, child))
+    {
+      if ((up->sg.u.sg.grp.s_addr != INADDR_ANY) &&
+          (child->sg.u.sg.grp.s_addr == up->sg.u.sg.grp.s_addr) &&
+         (child != up))
+        child->parent = up;
+    }
+}
+
 /*
  * If we have a (*,*) || (S,*) there is no parent
  * If we have a (S,G), find the (*,G)
@@ -99,6 +155,7 @@ void pim_upstream_delete(struct pim_upstream *up)
   THREAD_OFF(up->t_ka_timer);
   THREAD_OFF(up->t_rs_timer);
 
+  pim_upstream_remove_children (up);
   upstream_channel_oil_detach(up);
 
   /*
@@ -378,6 +435,7 @@ static struct pim_upstream *pim_upstream_new(struct prefix *sg,
     }
 
   up->parent                     = pim_upstream_find_parent (sg);
+  pim_upstream_find_new_children (up);
   up->flags                      = 0;
   up->ref_count                  = 1;
   up->t_join_timer               = NULL;