diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-10-27 21:13:23 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetwroks.com> | 2016-05-26 02:38:35 +0200 |
commit | c8ae3ce8b6b2c5ec8ce0009118855a60593f29a3 (patch) | |
tree | fdf3ed494aae829f56d7ebf1ad44b5ff8655069d | |
parent | pimd: Move I_am_DR macro to more appropriate place (diff) | |
download | frr-c8ae3ce8b6b2c5ec8ce0009118855a60593f29a3.tar.xz frr-c8ae3ce8b6b2c5ec8ce0009118855a60593f29a3.zip |
pimd: Modify the RP data structure.
Modify the RP data structure to know how to get to it from here.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r-- | pimd/pim_cmd.c | 9 | ||||
-rw-r--r-- | pimd/pim_mroute.c | 29 | ||||
-rw-r--r-- | pimd/pim_register.c | 2 | ||||
-rw-r--r-- | pimd/pim_rp.c | 14 | ||||
-rw-r--r-- | pimd/pim_vty.c | 4 | ||||
-rw-r--r-- | pimd/pimd.c | 2 | ||||
-rw-r--r-- | pimd/pimd.h | 2 |
7 files changed, 41 insertions, 21 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 9e9b1ed08..f15d6059f 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -2487,12 +2487,17 @@ DEFUN (ip_pim_rp, { int result; - result = inet_pton(AF_INET, argv[0], &qpim_rp); + result = inet_pton(AF_INET, argv[0], &qpim_rp.rpf_addr.s_addr); if (result <= 0) { vty_out(vty, "%% Bad RP address specified: %s", argv[0]); return CMD_WARNING; } + if (pim_nexthop_lookup(&qpim_rp.source_nexthop, qpim_rp.rpf_addr) != 0) { + vty_out(vty, "%% No Path to RP address specified: %s", argv[0]); + return CMD_WARNING; + } + return CMD_SUCCESS; } @@ -2505,7 +2510,7 @@ DEFUN (no_ip_pim_rp, "Rendevous Point" "ip address of RP") { - qpim_rp.s_addr = 0; + qpim_rp.rpf_addr.s_addr = INADDR_NONE; return CMD_SUCCESS; } diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index d804ce86f..0e2a9cc00 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -30,6 +30,7 @@ #include "pim_time.h" #include "pim_iface.h" #include "pim_macro.h" +#include "pim_rp.h" /* GLOBAL VARS */ extern struct zebra_privs_t pimd_privs; @@ -73,13 +74,15 @@ pim_mroute_msg_nocache (int fd, struct interface *ifp, const struct igmpmsg *msg { struct mfcctl mc; struct pim_interface *pim_ifp = ifp->info; + struct in_addr rpg; + rpg = RP(msg->im_dst); /* * If the incoming interface is unknown OR * the Interface type is SSM we don't need to * do anything here */ - if ((qpim_rp.s_addr == INADDR_NONE) || + if ((rpg.s_addr == INADDR_NONE) || (!pim_ifp) || (!PIM_I_am_DR(pim_ifp)) || (pim_ifp->itype == PIM_INTERFACE_SSM)) @@ -106,17 +109,28 @@ pim_mroute_msg_nocache (int fd, struct interface *ifp, const struct igmpmsg *msg } static int -pim_mroute_msg_wholepkt (int fd, struct interface *ifp, const struct igmpmsg *msg, +pim_mroute_msg_wholepkt (int fd, struct interface *ifp, const char *buf, const char *src_str, const char *grp_str) { + struct pim_interface *pim_ifp = ifp->info; + struct in_addr group; + struct in_addr rpg; + const struct ip *ip_hdr; - if (qpim_rp.s_addr == INADDR_NONE) { - if (PIM_DEBUG_PIM_TRACE) { - zlog_debug("%s: Received WHOLEPKT with no RP configured to send it to", - __PRETTY_FUNCTION__); - } + ip_hdr = (const struct ip *)buf; + + group = ip_hdr->ip_dst; + + rpg = RP(group); + + if ((rpg.s_addr == INADDR_NONE) || + (!pim_ifp) || + (!PIM_I_am_DR(pim_ifp)) || + (pim_ifp->itype == PIM_INTERFACE_SSM)) { + return 0; } + //pim_register_send(buf, rpg); return 0; } @@ -261,6 +275,7 @@ int pim_mroute_msg(int fd, const char *buf, int buf_size) return pim_mroute_msg_nocache(fd, ifp, msg, src_str, grp_str); break; case IGMPMSG_WHOLEPKT: + zlog_hexdump(buf, buf_size); return pim_mroute_msg_wholepkt(fd, ifp, msg, src_str, grp_str); break; default: diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 6123e1bd5..588d2962e 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -47,7 +47,7 @@ pim_check_is_my_ip_address (struct in_addr dest_addr) * type of configuration. * Note - Premature optimization might bite our patooeys' here. */ - if (I_am_RP(dest_addr) && (dest_addr.s_addr == qpim_rp.s_addr)) + if (I_am_RP(dest_addr) && (dest_addr.s_addr == qpim_rp.rpf_addr.s_addr)) return 1; if (if_lookup_exact_address (&dest_addr, AF_INET)) diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index d3cd91673..5ad786bad 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -39,22 +39,22 @@ pim_rp_check_rp (struct in_addr old, struct in_addr new) char sold[100]; char snew[100]; char rp[100]; - pim_inet4_dump("<rp?>", qpim_rp, rp, sizeof(rp)); + pim_inet4_dump("<rp?>", qpim_rp.rpf_addr, 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 == INADDR_NONE) + if (qpim_rp.rpf_addr.s_addr == INADDR_NONE) return; - if (new.s_addr == qpim_rp.s_addr) + if (new.s_addr == qpim_rp.rpf_addr.s_addr) { i_am_rp = 1; return; } - if (old.s_addr == qpim_rp.s_addr) + if (old.s_addr == qpim_rp.rpf_addr.s_addr) { i_am_rp = 0; return; @@ -84,7 +84,7 @@ pim_rp_g (struct in_addr group) /* * For staticly configured RP, it is always the qpim_rp */ - return(qpim_rp); + return(qpim_rp.rpf_addr); } /* @@ -98,14 +98,14 @@ pim_rp_g (struct in_addr group) int pim_rp_set_upstream_addr (struct in_addr *up, struct in_addr source) { - if ((qpim_rp.s_addr == INADDR_NONE) && (source.s_addr == 0xFFFFFFFF)) + if ((qpim_rp.rpf_addr.s_addr == INADDR_NONE) && (source.s_addr == INADDR_ANY)) { if (PIM_DEBUG_PIM_TRACE) zlog_debug("%s: Received a (*,G) with no RP configured", __PRETTY_FUNCTION__); return 0; } - *up = (source.s_addr == 0xFFFFFFFF) ? qpim_rp : source; + *up = (source.s_addr == INADDR_ANY) ? qpim_rp.rpf_addr : source; return 1; } diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index 1c0c02f77..eeeda9d43 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -99,8 +99,8 @@ int pim_global_config_write(struct vty *vty) vty_out(vty, "%s%s", PIM_CMD_IP_MULTICAST_ROUTING, VTY_NEWLINE); ++writes; } - if (qpim_rp.s_addr) { - vty_out(vty, "ip pim rp %s%s", inet_ntop(AF_INET, &qpim_rp, buffer, 32), VTY_NEWLINE); + if (qpim_rp.rpf_addr.s_addr != INADDR_NONE) { + vty_out(vty, "ip pim rp %s%s", inet_ntop(AF_INET, &qpim_rp.rpf_addr, buffer, 32), VTY_NEWLINE); ++writes; } diff --git a/pimd/pimd.c b/pimd/pimd.c index 3b2be7975..868a2fca2 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -69,7 +69,7 @@ int64_t qpim_mroute_add_last = 0; int64_t qpim_mroute_del_events = 0; int64_t qpim_mroute_del_last = 0; struct list *qpim_static_route_list = 0; -struct in_addr qpim_rp = { .s_addr = INADDR_NONE }; +struct pim_rpf qpim_rp = { .rpf_addr.s_addr = INADDR_NONE }; int32_t qpim_register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT; int32_t qpim_register_probe_time = PIM_REGISTER_PROBE_TIME_DEFAULT; diff --git a/pimd/pimd.h b/pimd/pimd.h index 239c61843..3b7210729 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -101,7 +101,7 @@ int64_t qpim_mroute_add_last; int64_t qpim_mroute_del_events; int64_t qpim_mroute_del_last; struct list *qpim_static_route_list; /* list of routes added statically */ -extern struct in_addr qpim_rp; +struct pim_rpf qpim_rp; #define PIM_JP_HOLDTIME (qpim_t_periodic * 7 / 2) |