pimd: Create raw socket for register packets to be forwarded.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-07-27 21:17:54 -04:00 committed by Donald Sharp
parent 728cd66300
commit 13afbd05fd
3 changed files with 36 additions and 4 deletions

View file

@ -2438,7 +2438,8 @@ DEFUN (ip_pim_rp,
return CMD_WARNING; return CMD_WARNING;
} }
if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr, NULL) != 0) { if (!pim_rp_setup ())
{
vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg); vty_out(vty, "%% No Path to RP address specified: %s", argv[idx_ipv4]->arg);
return CMD_WARNING; return CMD_WARNING;
} }

View file

@ -29,9 +29,38 @@
#include "pim_rp.h" #include "pim_rp.h"
#include "pim_str.h" #include "pim_str.h"
#include "pim_rpf.h" #include "pim_rpf.h"
#include "pim_sock.h"
static int i_am_rp = 0; 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 * 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) if (new.s_addr == qpim_rp.rpf_addr.s_addr)
{ {
i_am_rp = 1; i_am_rp = 1;
pim_rp_create_socket();
return; return;
} }

View file

@ -21,6 +21,7 @@
#ifndef PIM_RP_H #ifndef PIM_RP_H
#define 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); 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_i_am_rp (struct in_addr group);
int pim_rp_set_upstream_addr (struct in_addr *up, struct in_addr source); int pim_rp_set_upstream_addr (struct in_addr *up, struct in_addr source);