]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Add RP check code
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 2 Oct 2015 16:30:02 +0000 (09:30 -0700)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 26 May 2016 00:38:34 +0000 (20:38 -0400)
Add the ability for the node to determine if it is the RP or not.
Currently this only allows static RP's.

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

index 757c770c1d95706afaee5329c0f812c07c4a351d..506b60eabb7d4df17287a91effeea0e24f141e16 100644 (file)
  */
 #include <zebra.h>
 
+#include "log.h"
 #include "network.h"
 
 #include "pimd.h"
+#include "pim_str.h"
 #include "pim_rp.h"
 
+static int i_am_rp = 0;
+
+/*
+ * Checks to see if we should elect ourself the actual RP
+ */
+void
+pim_rp_check_rp (struct in_addr old, struct in_addr new)
+{
+  if (PIM_DEBUG_ZEBRA) {
+    char sold[100];
+    char snew[100];
+    char rp[100];
+    pim_inet4_dump("<rp?>", qpim_rp, rp, sizeof(rp));
+    pim_inet4_dump("<old?>", old, sold, sizeof(sold));
+    pim_inet4_dump("<new?>", new, snew, sizeof(snew));
+    zlog_debug("%s: %s for old %s new %s", __func__, rp, sold, snew );
+  }
+
+  if (qpim_rp.s_addr == 0)
+    return;
+
+  if (new.s_addr == qpim_rp.s_addr)
+    {
+      i_am_rp = 1;
+      return;
+    }
+
+  if (old.s_addr == qpim_rp.s_addr)
+    {
+      i_am_rp = 0;
+      return;
+    }
+}
+
+/*
+ * I_am_RP(G) is true if the group-to-RP mapping indicates that
+ * this router is the RP for the group.
+ *
+ * Since we only have static RP, all groups are part of this RP
+ */
+int
+pim_rp_i_am_rp (struct in_addr group)
+{
+  return i_am_rp;
+}
+
 /*
  * Set the upstream IP address we want to talk to based upon
  * the rp configured and the source address
index 114cc2cfd87a1c1fdcf5c9cb69c12b4de925b50b..4639e7cebfc6563550d805fd1d0dc54bb1d3b047 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef PIM_RP_H
 #define PIM_RP_H
 
+void pim_rp_check_rp (struct in_addr old, struct in_addr new);
+int pim_rp_i_am_rp (struct in_addr group);
 int pim_rp_set_upstream_addr (struct in_addr *up, struct in_addr source);
 
 #endif