vif_index = pim_if_find_vifindex_by_ifindex(
pim_ifp->pim,
up->rpf.source_nexthop.interface->ifindex);
- up->channel_oil->oil.mfcc_parent = vif_index;
+ pim_channel_oil_change_iif(pim_ifp->pim, up->channel_oil,
+ vif_index, __PRETTY_FUNCTION__);
}
pim_register_join(up);
return c_oil;
}
+void pim_channel_oil_change_iif(struct pim_instance *pim,
+ struct channel_oil *c_oil,
+ int input_vif_index,
+ const char *name)
+{
+ int old_vif_index = c_oil->oil.mfcc_parent;
+ struct prefix_sg sg = {.src = c_oil->oil.mfcc_mcastgrp,
+ .grp = c_oil->oil.mfcc_origin};
+
+ if (c_oil->oil.mfcc_parent == input_vif_index) {
+ if (PIM_DEBUG_MROUTE_DETAIL)
+ zlog_debug("%s(%s): Existing channel oil %pSG4 already using %d as IIF",
+ __PRETTY_FUNCTION__, name, &sg,
+ input_vif_index);
+
+ return;
+ }
+
+ if (PIM_DEBUG_MROUTE_DETAIL)
+ zlog_debug("%s(%s): Changing channel oil %pSG4 IIF from %d to %d installed: %d",
+ __PRETTY_FUNCTION__, name, &sg,
+ c_oil->oil.mfcc_parent, input_vif_index,
+ c_oil->installed);
+
+ c_oil->oil.mfcc_parent = input_vif_index;
+ if (c_oil->installed) {
+ if (input_vif_index == MAXVIFS)
+ pim_mroute_del(c_oil, name);
+ else
+ pim_mroute_add(c_oil, name);
+ } else
+ if (old_vif_index == MAXVIFS)
+ pim_mroute_add(c_oil, name);
+
+ return;
+}
+
struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
struct prefix_sg *sg,
int input_vif_index, const char *name)
c_oil->oil.mfcc_parent,
input_vif_index);
}
- c_oil->oil.mfcc_parent = input_vif_index;
+ pim_channel_oil_change_iif(pim, c_oil, input_vif_index,
+ name);
++c_oil->oil_ref_count;
/* channel might be present prior to upstream */
c_oil->up = pim_upstream_find(pim, sg);
struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
struct prefix_sg *sg,
int input_vif_index, const char *name);
+void pim_channel_oil_change_iif(struct pim_instance *pim,
+ 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,
struct pim_upstream *up)
{
if (up->rpf.source_nexthop.interface) {
- if (up->channel_oil) {
- up->channel_oil->oil.mfcc_parent = MAXVIFS;
- pim_mroute_del(up->channel_oil, __PRETTY_FUNCTION__);
+ if (up->channel_oil)
+ pim_channel_oil_change_iif(pim, up->channel_oil,
+ MAXVIFS,
+ __PRETTY_FUNCTION__);
- }
pim_upstream_switch(pim, up, PIM_UPSTREAM_NOTJOINED);
up->rpf.source_nexthop.interface = NULL;
up->rpf.source_nexthop.mrib_nexthop_addr.u.prefix4.s_addr =
} else {
/* input interface changed */
s_route->iif = iif_index;
- s_route->c_oil.oil.mfcc_parent = iif_index;
+ pim_channel_oil_change_iif(pim, &s_route->c_oil,
+ iif_index,
+ __PRETTY_FUNCTION__);
#ifdef PIM_ENFORCE_LOOPFREE_MFC
/* check to make sure the new input was not an
{
struct in_addr vif_source;
int input_iface_vif_index;
- int old_vif_index;
pim_rp_set_upstream_addr(c_oil->pim, &vif_source,
c_oil->oil.mfcc_origin,
}
/* update iif vif_index */
- old_vif_index = c_oil->oil.mfcc_parent;
- c_oil->oil.mfcc_parent = input_iface_vif_index;
-
- /* update kernel multicast forwarding cache (MFC) */
- if (pim_mroute_add(c_oil, __PRETTY_FUNCTION__)) {
- if (PIM_DEBUG_MROUTE) {
- /* just log warning */
- struct interface *old_iif = pim_if_find_by_vif_index(
- c_oil->pim, old_vif_index);
- struct interface *new_iif = pim_if_find_by_vif_index(
- c_oil->pim, input_iface_vif_index);
- char source_str[INET_ADDRSTRLEN];
- char group_str[INET_ADDRSTRLEN];
- pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin,
- source_str, sizeof(source_str));
- pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp,
- group_str, sizeof(group_str));
- zlog_debug(
- "%s %s: (S,G)=(%s,%s) failure updating input interface from %s vif_index=%d to %s vif_index=%d",
- __FILE__, __PRETTY_FUNCTION__, source_str,
- group_str,
- old_iif ? old_iif->name : "<old_iif?>",
- c_oil->oil.mfcc_parent,
- new_iif ? new_iif->name : "<new_iif?>",
- input_iface_vif_index);
- }
- }
+ pim_channel_oil_change_iif(c_oil->pim, c_oil, input_iface_vif_index,
+ __PRETTY_FUNCTION__);
+ pim_mroute_add(c_oil, __PRETTY_FUNCTION__);
}
void pim_scan_oil(struct pim_instance *pim)