pimd: del_oif and pim_channel_del_oif are the same function

These two functions do the exact same thing.  Refactor

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-03-23 07:47:41 -04:00
parent d78f0ac13c
commit 220dbacef6

View File

@ -53,9 +53,6 @@
static struct zclient *zclient = NULL;
static int fib_lookup_if_vif_index(struct in_addr addr);
static int del_oif(struct channel_oil *channel_oil,
struct interface *oif,
uint32_t proto_mask);
/* Router-id update message from zebra. */
static int pim_router_id_update_zebra(int command, struct zclient *zclient,
@ -521,8 +518,6 @@ pim_scan_individual_oil (struct channel_oil *c_oil, int in_vif_index)
source_str, group_str,
new_iif->name, input_iface_vif_index);
}
//del_oif(c_oil, new_iif, PIM_OIF_FLAG_PROTO_ANY);
}
/* update iif vif_index */
@ -765,121 +760,6 @@ static int fib_lookup_if_vif_index(struct in_addr addr)
return vif_index;
}
static int del_oif(struct channel_oil *channel_oil,
struct interface *oif,
uint32_t proto_mask)
{
struct pim_interface *pim_ifp;
int old_ttl;
pim_ifp = oif->info;
if (PIM_DEBUG_MROUTE) {
char group_str[INET_ADDRSTRLEN];
char source_str[INET_ADDRSTRLEN];
pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, source_str, sizeof(source_str));
zlog_debug("%s %s: (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d",
__FILE__, __PRETTY_FUNCTION__,
source_str, group_str,
proto_mask, oif->name, pim_ifp->mroute_vif_index);
}
/* Prevent single protocol from unsubscribing same interface from
channel (S,G) multiple times */
if (!(channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask)) {
if (PIM_DEBUG_MROUTE)
{
char group_str[INET_ADDRSTRLEN];
char source_str[INET_ADDRSTRLEN];
pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, source_str, sizeof(source_str));
zlog_debug("%s %s: nonexistent protocol mask %u removed OIF %s (vif_index=%d, min_ttl=%d) from channel (S,G)=(%s,%s)",
__FILE__, __PRETTY_FUNCTION__,
proto_mask, oif->name, pim_ifp->mroute_vif_index,
channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index],
source_str, group_str);
}
return -2;
}
/* Mark that protocol is no longer interested in this OIF */
channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= ~proto_mask;
/* Allow multiple protocols to unsubscribe same interface from
channel (S,G) multiple times, by silently ignoring requests while
there is at least one protocol interested in the channel */
if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & PIM_OIF_FLAG_PROTO_ANY) {
/* Check the OIF keeps existing before returning, and only log
warning otherwise */
if (channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] < 1) {
if (PIM_DEBUG_MROUTE)
{
char group_str[INET_ADDRSTRLEN];
char source_str[INET_ADDRSTRLEN];
pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, source_str, sizeof(source_str));
zlog_debug("%s %s: protocol mask %u removing nonexistent OIF %s (vif_index=%d, min_ttl=%d) from channel (S,G)=(%s,%s)",
__FILE__, __PRETTY_FUNCTION__,
proto_mask, oif->name, pim_ifp->mroute_vif_index,
channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index],
source_str, group_str);
}
}
return 0;
}
old_ttl = channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index];
if (old_ttl < 1) {
if (PIM_DEBUG_MROUTE)
{
char group_str[INET_ADDRSTRLEN];
char source_str[INET_ADDRSTRLEN];
pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, source_str, sizeof(source_str));
zlog_debug("%s %s: interface %s (vif_index=%d) is not output for channel (S,G)=(%s,%s)",
__FILE__, __PRETTY_FUNCTION__,
oif->name, pim_ifp->mroute_vif_index,
source_str, group_str);
}
return -3;
}
channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = 0;
if (pim_mroute_add(channel_oil, __PRETTY_FUNCTION__)) {
char group_str[INET_ADDRSTRLEN];
char source_str[INET_ADDRSTRLEN];
pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, source_str, sizeof(source_str));
zlog_warn("%s %s: could not remove output interface %s (vif_index=%d) from channel (S,G)=(%s,%s)",
__FILE__, __PRETTY_FUNCTION__,
oif->name, pim_ifp->mroute_vif_index,
source_str, group_str);
channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = old_ttl;
return -4;
}
--channel_oil->oil_size;
if (PIM_DEBUG_MROUTE) {
char group_str[INET_ADDRSTRLEN];
char source_str[INET_ADDRSTRLEN];
pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, source_str, sizeof(source_str));
zlog_debug("%s %s: (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d: DONE",
__FILE__, __PRETTY_FUNCTION__,
source_str, group_str,
proto_mask, oif->name, pim_ifp->mroute_vif_index);
}
return 0;
}
void igmp_source_forward_start(struct igmp_source *source)
{
struct igmp_group *group;
@ -1034,16 +914,16 @@ void igmp_source_forward_stop(struct igmp_source *source)
Possibly because of multiple calls. When that happens, we
enter the below if statement and this function returns early
which in turn triggers the calling function to assert.
Making the call to del_oif and ignoring the return code
fixes the issue without ill effect, similar to
pim_forward_stop below.
Making the call to pim_channel_del_oif and ignoring the return code
fixes the issue without ill effect, similar to
pim_forward_stop below.
*/
result = del_oif(source->source_channel_oil,
group->group_igmp_sock->interface,
PIM_OIF_FLAG_PROTO_IGMP);
result = pim_channel_del_oif(source->source_channel_oil,
group->group_igmp_sock->interface,
PIM_OIF_FLAG_PROTO_IGMP);
if (result) {
if (PIM_DEBUG_IGMP_TRACE)
zlog_debug("%s: del_oif() failed with return=%d",
zlog_debug("%s: pim_channel_del_oif() failed with return=%d",
__func__, result);
return;
}
@ -1117,18 +997,9 @@ void pim_forward_stop(struct pim_ifchannel *ch)
ch->sg_str, ch->interface->name);
}
if (!up->channel_oil) {
if (PIM_DEBUG_PIM_TRACE)
zlog_debug("%s: (S,G)=%s oif=%s missing channel OIL",
__PRETTY_FUNCTION__,
ch->sg_str, ch->interface->name);
return;
}
del_oif(up->channel_oil,
ch->interface,
PIM_OIF_FLAG_PROTO_PIM);
pim_channel_del_oif(up->channel_oil,
ch->interface,
PIM_OIF_FLAG_PROTO_PIM);
}
void