summaryrefslogtreecommitdiff
path: root/pimd/pim_upstream.c
diff options
context:
space:
mode:
Diffstat (limited to 'pimd/pim_upstream.c')
-rw-r--r--pimd/pim_upstream.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c
index 19f7d3336c..183db532ba 100644
--- a/pimd/pim_upstream.c
+++ b/pimd/pim_upstream.c
@@ -52,6 +52,7 @@
#include "pim_register.h"
#include "pim_msdp.h"
#include "pim_jp_agg.h"
+#include "pim_nht.h"
struct hash *pim_upstream_hash = NULL;
struct list *pim_upstream_list = NULL;
@@ -142,6 +143,7 @@ pim_upstream_find_parent (struct pim_upstream *child)
void pim_upstream_free(struct pim_upstream *up)
{
XFREE(MTYPE_PIM_UPSTREAM, up);
+ up = NULL;
}
static void upstream_channel_oil_detach(struct pim_upstream *up)
@@ -156,6 +158,7 @@ void
pim_upstream_del(struct pim_upstream *up, const char *name)
{
bool notify_msdp = false;
+ struct prefix nht_p;
if (PIM_DEBUG_TRACE)
zlog_debug ("%s(%s): Delete %s ref count: %d",
@@ -209,10 +212,25 @@ pim_upstream_del(struct pim_upstream *up, const char *name)
listnode_delete (pim_upstream_list, up);
hash_release (pim_upstream_hash, up);
- if (notify_msdp) {
- pim_msdp_up_del(&up->sg);
- }
- pim_upstream_free(up);
+ if (notify_msdp)
+ {
+ pim_msdp_up_del (&up->sg);
+ }
+
+ /* Deregister addr with Zebra NHT */
+ nht_p.family = AF_INET;
+ nht_p.prefixlen = IPV4_MAX_BITLEN;
+ nht_p.u.prefix4 = up->upstream_addr;
+ if (PIM_DEBUG_TRACE)
+ {
+ char buf[PREFIX2STR_BUFFER];
+ prefix2str (&nht_p, buf, sizeof (buf));
+ zlog_debug ("%s: Deregister upstream %s upstream addr %s with NHT ",
+ __PRETTY_FUNCTION__, up->sg_str, buf);
+ }
+ pim_delete_tracked_nexthop (&nht_p, up, NULL);
+
+ pim_upstream_free (up);
}
void
@@ -517,7 +535,7 @@ pim_upstream_switch(struct pim_upstream *up,
}
}
-static int
+int
pim_upstream_compare (void *arg1, void *arg2)
{
const struct pim_upstream *up1 = (const struct pim_upstream *)arg1;
@@ -548,11 +566,12 @@ pim_upstream_new (struct prefix_sg *sg,
struct pim_upstream *up;
up = XCALLOC(MTYPE_PIM_UPSTREAM, sizeof(*up));
- if (!up) {
- zlog_err("%s: PIM XCALLOC(%zu) failure",
+ if (!up)
+ {
+ zlog_err("%s: PIM XCALLOC(%zu) failure",
__PRETTY_FUNCTION__, sizeof(*up));
- return NULL;
- }
+ return NULL;
+ }
up->sg = *sg;
pim_str_sg_set (sg, up->sg_str);
@@ -600,7 +619,7 @@ pim_upstream_new (struct prefix_sg *sg,
if (up->sg.src.s_addr != INADDR_ANY)
wheel_add_item (pim_upstream_sg_wheel, up);
- rpf_result = pim_rpf_update(up, NULL);
+ rpf_result = pim_rpf_update(up, NULL, 1);
if (rpf_result == PIM_RPF_FAILURE) {
if (PIM_DEBUG_TRACE)
zlog_debug ("%s: Attempting to create upstream(%s), Unable to RPF for source", __PRETTY_FUNCTION__,
@@ -631,7 +650,11 @@ pim_upstream_new (struct prefix_sg *sg,
listnode_add_sort(pim_upstream_list, up);
if (PIM_DEBUG_TRACE)
- zlog_debug ("%s: Created Upstream %s", __PRETTY_FUNCTION__, up->sg_str);
+ {
+ zlog_debug ("%s: Created Upstream %s upstream_addr %s",
+ __PRETTY_FUNCTION__, up->sg_str,
+ inet_ntoa (up->upstream_addr));
+ }
return up;
}
@@ -1403,7 +1426,7 @@ pim_upstream_find_new_rpf (void)
if (PIM_DEBUG_TRACE)
zlog_debug ("Upstream %s without a path to send join, checking",
up->sg_str);
- pim_rpf_update (up, NULL);
+ pim_rpf_update (up, NULL, 1);
}
}
}