]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Create raw socket for register packets to be forwarded.
authorDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 28 Jul 2016 01:17:54 +0000 (21:17 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:04 +0000 (20:26 -0500)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_cmd.c
pimd/pim_rp.c
pimd/pim_rp.h

index b94fb1c767aaa06a9d4cf1d4ded85f4f0fc41c14..e9ef72c637af6cad696e330ceca442274832769b 100644 (file)
@@ -2438,10 +2438,11 @@ DEFUN (ip_pim_rp,
     return CMD_WARNING;
   }
 
-  if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) {
-    vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg);
-    return CMD_WARNING;
-  }
+  if (!pim_rp_setup ())
+    {
+      vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg);
+      return CMD_WARNING;
+    }
 
   return CMD_SUCCESS;
 }
index 26d108bcaac5ad004dec478c41a5829d05f1d270..e7c03792cd06bd6c2c924937c36e6b31b3abc2cf 100644 (file)
 #include "pim_rp.h"
 #include "pim_str.h"
 #include "pim_rpf.h"
+#include "pim_sock.h"
 
 static int i_am_rp = 0;
 
+/*
+ * The Raw socket to pump packets down
+ * if we are the RP
+ */
+static int fd_rp = -1;
+
+static void
+pim_rp_create_socket (void)
+{
+  fd_rp = pim_socket_raw (IPPROTO_RAW);
+  if (pim_socket_bind (fd_rp, qpim_rp.source_nexthop.interface) != 0)
+    zlog_debug ("Unable to Bind to a particular socket");
+}
+
+int
+pim_rp_setup (void)
+{
+  if (pim_nexthop_lookup (&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0)
+    {
+      zlog_err ("Unable to lookup nexthop for rp specified");
+      return 0;
+    }
+
+  pim_rp_create_socket ();
+
+  return 1;
+}
+
 /*
  * Checks to see if we should elect ourself the actual RP
  */
@@ -54,6 +83,7 @@ pim_rp_check_rp (struct in_addr old, struct in_addr new)
   if (new.s_addr == qpim_rp.rpf_addr.s_addr)
     {
       i_am_rp = 1;
+      pim_rp_create_socket();
       return;
     }
 
index bb785e7efc3f1f18cd824130dc9a5a9a7c262b45..35a7e9dfc7d7c60e0c9f33287bc9fbe6182cc814 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef PIM_RP_H
 #define PIM_RP_H
 
+int pim_rp_setup (void);
 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);