From 9bf5f19cae44fcd2e9d9b243a81f7cd9be5c49ce Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 14 Jun 2019 19:01:46 -0400 Subject: [PATCH 1/2] pimd: Display ifp name in pim_channel_oil_dump The vifi being displayed is just confusing. Display the actual interface name being used in the mroute. Signed-off-by: Donald Sharp --- pimd/pim_oil.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 22045c2d33..033148ea9c 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -38,18 +38,22 @@ char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size) { char *out; + struct interface *ifp; struct prefix_sg sg; int i; sg.src = c_oil->oil.mfcc_origin; sg.grp = c_oil->oil.mfcc_mcastgrp; - snprintf(buf, size, "%s IIF: %d, OIFS: ", pim_str_sg_dump(&sg), - c_oil->oil.mfcc_parent); + ifp = pim_if_find_by_vif_index(c_oil->pim, c_oil->oil.mfcc_parent); + snprintf(buf, size, "%s IIF: %s, OIFS: ", pim_str_sg_dump(&sg), + ifp ? ifp->name : "(?)"); out = buf + strlen(buf); for (i = 0; i < MAXVIFS; i++) { if (c_oil->oil.mfcc_ttls[i] != 0) { - snprintf(out, buf + size - out, "%d ", i); + ifp = pim_if_find_by_vif_index(c_oil->pim, i); + snprintf(out, buf + size - out, "%s ", + ifp ? ifp->name : "(?)"); out += strlen(out); } } From 8a3e7e9ed983e2d8b686b1087714fe45592090d5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 14 Jun 2019 19:18:51 -0400 Subject: [PATCH 2/2] pimd: Add debugs for channel_oil creation and deletion Add some debugs so we can see channel oil creation and deletion events. Signed-off-by: Donald Sharp --- pimd/pim_igmpv3.c | 3 ++- pimd/pim_mroute.c | 9 ++++++--- pimd/pim_oil.c | 38 +++++++++++++++++++++++++++----------- pimd/pim_oil.h | 4 ++-- pimd/pim_upstream.c | 22 +++++++++++++--------- pimd/pim_zebra.c | 27 ++++++++++++++++----------- 6 files changed, 66 insertions(+), 37 deletions(-) diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index bc0460fa03..d9b940bba7 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -332,7 +332,8 @@ void igmp_source_free(struct igmp_source *source) static void source_channel_oil_detach(struct igmp_source *source) { if (source->source_channel_oil) { - pim_channel_oil_del(source->source_channel_oil); + pim_channel_oil_del(source->source_channel_oil, + __PRETTY_FUNCTION__); source->source_channel_oil = NULL; } } diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index ca05824347..2bdec12cd1 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -203,7 +203,8 @@ static int pim_mroute_msg_nocache(int fd, struct interface *ifp, * and causing us to consider them. */ c_oil = pim_channel_oil_add(pim_ifp->pim, &sg, - pim_ifp->mroute_vif_index); + pim_ifp->mroute_vif_index, + __PRETTY_FUNCTION__); pim_mroute_add(c_oil, __PRETTY_FUNCTION__); return 0; @@ -523,7 +524,8 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, if (!up->channel_oil) up->channel_oil = pim_channel_oil_add( pim_ifp->pim, &sg, - pim_ifp->mroute_vif_index); + pim_ifp->mroute_vif_index, + __PRETTY_FUNCTION__); pim_upstream_inherited_olist(pim_ifp->pim, up); if (!up->channel_oil->installed) pim_mroute_add(up->channel_oil, @@ -548,7 +550,8 @@ static int pim_mroute_msg_wrvifwhole(int fd, struct interface *ifp, } pim_ifp = ifp->info; - oil = pim_channel_oil_add(pim_ifp->pim, &sg, pim_ifp->mroute_vif_index); + oil = pim_channel_oil_add(pim_ifp->pim, &sg, pim_ifp->mroute_vif_index, + __PRETTY_FUNCTION__); if (!oil->installed) pim_mroute_add(oil, __PRETTY_FUNCTION__); if (pim_if_connected_to_source(ifp, sg.src)) { diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 033148ea9c..307a1760d9 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -148,7 +148,7 @@ struct channel_oil *pim_find_channel_oil(struct pim_instance *pim, struct channel_oil *pim_channel_oil_add(struct pim_instance *pim, struct prefix_sg *sg, - int input_vif_index) + int input_vif_index, const char *name) { struct channel_oil *c_oil; struct interface *ifp; @@ -157,18 +157,23 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim, if (c_oil) { if (c_oil->oil.mfcc_parent != input_vif_index) { c_oil->oil_inherited_rescan = 1; - if (PIM_DEBUG_MROUTE) + if (PIM_DEBUG_MROUTE_DETAIL) zlog_debug( - "%s: Existing channel oil %s points to %d, modifying to point at %d", - __PRETTY_FUNCTION__, - pim_str_sg_dump(sg), + "%s: Existing channel oil %pSG4 points to %d, modifying to point at %d", + __PRETTY_FUNCTION__, sg, c_oil->oil.mfcc_parent, input_vif_index); } c_oil->oil.mfcc_parent = input_vif_index; ++c_oil->oil_ref_count; - c_oil->up = pim_upstream_find( - pim, sg); // channel might be present prior to upstream + /* channel might be present prior to upstream */ + c_oil->up = pim_upstream_find(pim, sg); + + if (PIM_DEBUG_MROUTE) + zlog_debug( + "%s(%s): Existing oil for %pSG4 Ref Count: %d (Post Increment)", + __PRETTY_FUNCTION__, name, sg, + c_oil->oil_ref_count); return c_oil; } @@ -177,9 +182,8 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim, if (!ifp) { /* warning only */ zlog_warn( - "%s: (S,G)=%s could not find input interface for input_vif_index=%d", - __PRETTY_FUNCTION__, pim_str_sg_dump(sg), - input_vif_index); + "%s:%s (S,G)=%pSG4 could not find input interface for input_vif_index=%d", + __PRETTY_FUNCTION__, name, sg, input_vif_index); } } @@ -197,11 +201,23 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim, listnode_add_sort(pim->channel_oil_list, c_oil); + if (PIM_DEBUG_MROUTE) + zlog_debug( + "%s(%s): New oil for %pSG4 vif_index: %d Ref Count: 1 (Post Increment)", + __PRETTY_FUNCTION__, name, sg, input_vif_index); return c_oil; } -void pim_channel_oil_del(struct channel_oil *c_oil) +void pim_channel_oil_del(struct channel_oil *c_oil, const char *name) { + if (PIM_DEBUG_MROUTE) { + struct prefix_sg sg = {.src = c_oil->oil.mfcc_mcastgrp, + .grp = c_oil->oil.mfcc_origin}; + + zlog_debug( + "%s(%s): Del oil for %pSG4, Ref Count: %d (Predecrement)", + __PRETTY_FUNCTION__, name, &sg, c_oil->oil_ref_count); + } --c_oil->oil_ref_count; if (c_oil->oil_ref_count < 1) { diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h index d097da6b3e..485299196d 100644 --- a/pimd/pim_oil.h +++ b/pimd/pim_oil.h @@ -113,8 +113,8 @@ struct channel_oil *pim_find_channel_oil(struct pim_instance *pim, struct prefix_sg *sg); struct channel_oil *pim_channel_oil_add(struct pim_instance *pim, struct prefix_sg *sg, - int input_vif_index); -void pim_channel_oil_del(struct channel_oil *c_oil); + int input_vif_index, const char *name); +void pim_channel_oil_del(struct channel_oil *c_oil, const char *name); int pim_channel_add_oif(struct channel_oil *c_oil, struct interface *oif, uint32_t proto_mask); diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 50c68c66bd..2e6c5c7803 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -146,7 +146,7 @@ static void upstream_channel_oil_detach(struct pim_upstream *up) but upstream would not keep reference of it */ up->channel_oil->up = NULL; - pim_channel_oil_del(up->channel_oil); + pim_channel_oil_del(up->channel_oil, __PRETTY_FUNCTION__); up->channel_oil = NULL; } } @@ -740,13 +740,15 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim, pim_upstream_fill_static_iif(up, incoming); pim_ifp = up->rpf.source_nexthop.interface->info; assert(pim_ifp); - up->channel_oil = pim_channel_oil_add(pim, - &up->sg, pim_ifp->mroute_vif_index); + up->channel_oil = pim_channel_oil_add(pim, &up->sg, + pim_ifp->mroute_vif_index, + __PRETTY_FUNCTION__); } else if (up->upstream_addr.s_addr == INADDR_ANY) { /* Create a dummmy channel oil with incoming ineterface MAXVIFS, * since RP is not configured */ - up->channel_oil = pim_channel_oil_add(pim, &up->sg, MAXVIFS); + up->channel_oil = pim_channel_oil_add(pim, &up->sg, MAXVIFS, + __PRETTY_FUNCTION__); } else { rpf_result = pim_rpf_update(pim, up, NULL); @@ -759,14 +761,15 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim, * MAXVIFS, since RP is not reachable */ up->channel_oil = pim_channel_oil_add( - pim, &up->sg, MAXVIFS); + pim, &up->sg, MAXVIFS, __PRETTY_FUNCTION__); } if (up->rpf.source_nexthop.interface) { pim_ifp = up->rpf.source_nexthop.interface->info; if (pim_ifp) - up->channel_oil = pim_channel_oil_add(pim, - &up->sg, pim_ifp->mroute_vif_index); + up->channel_oil = pim_channel_oil_add( + pim, &up->sg, pim_ifp->mroute_vif_index, + __PRETTY_FUNCTION__); } } @@ -1524,8 +1527,9 @@ int pim_upstream_inherited_olist_decide(struct pim_instance *pim, __PRETTY_FUNCTION__, up->sg_str); } if (pim_ifp && !up->channel_oil) - up->channel_oil = pim_channel_oil_add( - pim, &up->sg, pim_ifp->mroute_vif_index); + up->channel_oil = pim_channel_oil_add(pim, &up->sg, + pim_ifp->mroute_vif_index, + __PRETTY_FUNCTION__); FOR_ALL_INTERFACES (pim->vrf, ifp) { if (!ifp->info) diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 25ac307ac4..e09163a527 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -974,8 +974,8 @@ void igmp_source_forward_start(struct pim_instance *pim, if (!pim_rp_set_upstream_addr(pim, &vif_source, source->source_addr, sg.grp)) { /*Create a dummy channel oil */ - source->source_channel_oil = - pim_channel_oil_add(pim, &sg, MAXVIFS); + source->source_channel_oil = pim_channel_oil_add( + pim, &sg, MAXVIFS, __PRETTY_FUNCTION__); if (!source->source_channel_oil) { if (PIM_DEBUG_IGMP_TRACE) { @@ -1035,7 +1035,9 @@ void igmp_source_forward_start(struct pim_instance *pim, source_str); } source->source_channel_oil = - pim_channel_oil_add(pim, &sg, MAXVIFS); + pim_channel_oil_add( + pim, &sg, MAXVIFS, + __PRETTY_FUNCTION__); } else { @@ -1065,8 +1067,9 @@ void igmp_source_forward_start(struct pim_instance *pim, } source->source_channel_oil = - pim_channel_oil_add(pim, &sg, - input_iface_vif_index); + pim_channel_oil_add( + pim, &sg, input_iface_vif_index, + __PRETTY_FUNCTION__); if (!source->source_channel_oil) { if (PIM_DEBUG_IGMP_TRACE) { zlog_debug( @@ -1241,13 +1244,14 @@ void pim_forward_start(struct pim_ifchannel *ch) __FILE__, __PRETTY_FUNCTION__, source_str); } - up->channel_oil = pim_channel_oil_add(pim, &up->sg, - MAXVIFS); + up->channel_oil = pim_channel_oil_add( + pim, &up->sg, MAXVIFS, __PRETTY_FUNCTION__); } else { - up->channel_oil = pim_channel_oil_add(pim, &up->sg, - input_iface_vif_index); + up->channel_oil = pim_channel_oil_add( + pim, &up->sg, input_iface_vif_index, + __PRETTY_FUNCTION__); if (!up->channel_oil) { if (PIM_DEBUG_PIM_TRACE) zlog_debug( @@ -1268,8 +1272,9 @@ void pim_forward_start(struct pim_ifchannel *ch) input_iface_vif_index, up->sg_str); } - up->channel_oil = pim_channel_oil_add(pim, &up->sg, - input_iface_vif_index); + up->channel_oil = + pim_channel_oil_add(pim, &up->sg, input_iface_vif_index, + __PRETTY_FUNCTION__); if (!up->channel_oil) { if (PIM_DEBUG_PIM_TRACE) zlog_debug(