]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Add pim_channel_del_oif
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sun, 17 Jul 2016 23:51:56 +0000 (19:51 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:02 +0000 (20:26 -0500)
For a given interface remove the interface from the list
of outgoing interfaces for a mroute and reinstall it
into the kernel.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_oil.c
pimd/pim_oil.h

index 96f9ef2b62601c6185a174b0899c4670063beaca..d072c73dd804790209ba7ad0fb0a3f0c0ea876c0 100644 (file)
@@ -142,6 +142,92 @@ void pim_channel_oil_del(struct channel_oil *c_oil)
   }
 }
 
+int
+pim_channel_del_oif (struct channel_oil *channel_oil,
+                    struct interface *oif,
+                    uint32_t proto_mask)
+{
+  struct pim_interface *pim_ifp;
+
+  zassert (channel_oil);
+  zassert (oif);
+
+  pim_ifp = oif->info;
+
+  if (PIM_DEBUG_MROUTE)
+    {
+      char group_str[100];
+      char source_str[100];
+      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);
+    }
+
+  /*
+   * Don't do anything if we've been asked to remove a source
+   * that is not actually on it.
+   */
+  if (!(channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask))
+    {
+      if (PIM_DEBUG_MROUTE)
+       {
+         char group_str[100];
+         char source_str[100];
+         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: no existing protocol mask %u(%u) for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)",
+                    __FILE__, __PRETTY_FUNCTION__,
+                    proto_mask, channel_oil->oif_flags[pim_ifp->mroute_vif_index],
+                    oif->name, pim_ifp->mroute_vif_index,
+                    channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index],
+                    source_str, group_str);
+       }
+      return 0;
+    }
+
+  channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= ~proto_mask;
+
+  if (channel_oil->oif_flags[pim_ifp->mroute_vif_index])
+    {
+      if (PIM_DEBUG_MROUTE)
+       {
+         char group_str[100];
+         char source_str[100];
+         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: other protocol masks remain for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)",
+                    __FILE__, __PRETTY_FUNCTION__,
+                    oif->name, pim_ifp->mroute_vif_index,
+                    channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index],
+                    source_str, group_str);
+       }
+      return 0;
+    }
+
+  channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = 0;
+
+  if (pim_mroute_add (channel_oil)) {
+    if (PIM_DEBUG_MROUTE)
+      {
+        char group_str[100];
+        char source_str[100];
+        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: could not remove output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)",
+                   __FILE__, __PRETTY_FUNCTION__,
+                   oif->name, pim_ifp->mroute_vif_index,
+                   source_str, group_str);
+      }
+    return -1;
+  }
+
+  return 0;
+}
+
+
 int pim_channel_add_oif(struct channel_oil *channel_oil,
                   struct interface *oif,
                   uint32_t proto_mask)
index c63c026c0f29b5f967c91eba2eb02f6c257aa742..0edb50787e58e1e59eb66bf5e0026764ec49f3f2 100644 (file)
@@ -87,5 +87,8 @@ void pim_channel_oil_del(struct channel_oil *c_oil);
 int pim_channel_add_oif(struct channel_oil *c_oil,
                        struct interface *oif,
                        uint32_t proto_mask);
+int pim_channel_del_oif (struct channel_oil *c_oil,
+                        struct interface *oif,
+                        uint32_t proto_mask);
 
 #endif /* PIM_OIL_H */