summaryrefslogtreecommitdiff
path: root/pimd/pim_mroute.c
diff options
context:
space:
mode:
Diffstat (limited to 'pimd/pim_mroute.c')
-rw-r--r--pimd/pim_mroute.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 36b066735c..5ce7863611 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -65,10 +65,9 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
&data, data_len);
if (err) {
zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s",
- __FILE__, __PRETTY_FUNCTION__,
- pim->mroute_socket, data, errno,
- safe_strerror(errno));
+ "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP, MRT_TABLE=%d): errno=%d: %s",
+ __FILE__, __func__, pim->mroute_socket,
+ data, errno, safe_strerror(errno));
return -1;
}
@@ -86,11 +85,10 @@ static int pim_mroute_set(struct pim_instance *pim, int enable)
opt, &data, data_len);
if (err) {
zlog_warn(
- "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s",
- __FILE__, __PRETTY_FUNCTION__,
- pim->mroute_socket,
- enable ? "MRT_INIT" : "MRT_DONE", data, errno,
- safe_strerror(errno));
+ "%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,%s=%d): errno=%d: %s",
+ __FILE__, __func__, pim->mroute_socket,
+ enable ? "MRT_INIT" : "MRT_DONE", data, errno,
+ safe_strerror(errno));
return -1;
}
}
@@ -445,6 +443,7 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
{
const struct ip *ip_hdr = (const struct ip *)buf;
struct pim_interface *pim_ifp;
+ struct pim_instance *pim;
struct pim_ifchannel *ch;
struct pim_upstream *up;
struct prefix_sg star_g;
@@ -467,16 +466,18 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
star_g = sg;
star_g.src.s_addr = INADDR_ANY;
-#if 0
- ch = pim_ifchannel_find(ifp, &star_g);
- if (ch)
- {
- if (PIM_DEBUG_MROUTE)
- zlog_debug ("WRVIFWHOLE (*,G)=%s found ifchannel on interface %s",
- pim_str_sg_dump (&star_g), ifp->name);
- return -1;
- }
-#endif
+
+ pim = pim_ifp->pim;
+ /*
+ * If the incoming interface is the pimreg, then
+ * we know the callback is associated with a pim register
+ * packet and there is nothing to do here as that
+ * normal pim processing will see the packet and allow
+ * us to do the right thing.
+ */
+ if (ifp == pim->regiface) {
+ return 0;
+ }
up = pim_upstream_find(pim_ifp->pim, &sg);
if (up) {
@@ -504,8 +505,17 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp,
* the pimreg period, so I believe we can ignore this packet
*/
if (!PIM_UPSTREAM_FLAG_TEST_FHR(up->flags)) {
- // No if channel, but upstream we are at the RP.
- if (pim_nexthop_lookup(pim_ifp->pim, &source,
+ /*
+ * No if channel, but upstream we are at the RP.
+ *
+ * This could be a anycast RP too and we may
+ * not have received a register packet from
+ * the source here at all. So gracefully
+ * bow out of doing a nexthop lookup and
+ * setting the SPTBIT to true
+ */
+ if (up->upstream_register.s_addr != INADDR_ANY &&
+ pim_nexthop_lookup(pim_ifp->pim, &source,
up->upstream_register, 0)) {
pim_register_stop_send(source.interface, &sg,
pim_ifp->primary_address,
@@ -1007,8 +1017,10 @@ static int pim_mroute_add(struct channel_oil *c_oil, const char *name)
pim_channel_oil_dump(c_oil, buf, sizeof(buf)));
}
- c_oil->installed = 1;
- c_oil->mroute_creation = pim_time_monotonic_sec();
+ if (!c_oil->installed) {
+ c_oil->installed = 1;
+ c_oil->mroute_creation = pim_time_monotonic_sec();
+ }
return 0;
}