]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd: Ensure we should accept a kernel upcall
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 29 Jun 2016 16:12:13 +0000 (12:12 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 29 Jun 2016 16:12:13 +0000 (12:12 -0400)
When we receive a multicast packet from a source
that is not connected to us, silently ignore it.

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

index 624264b3b5c4498eaff93cce1116c7e17c2e82c4..8048d4b3c70bd726953eb5b547cde5f7e4f319d3 100644 (file)
@@ -24,6 +24,7 @@
 #include "log.h"
 #include "privs.h"
 #include "if.h"
+#include "prefix.h"
 
 #include "pimd.h"
 #include "pim_mroute.h"
@@ -66,6 +67,29 @@ static int pim_mroute_set(int fd, int enable)
   return 0;
 }
 
+static int
+pim_mroute_connected_to_source (struct interface *ifp, struct in_addr src)
+{
+  struct listnode *cnode;
+  struct connected *c;
+  struct prefix p;
+
+  p.family = AF_INET;
+  p.u.prefix4 = src;
+  p.prefixlen = IPV4_MAX_BITLEN;
+
+  for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
+    {
+      if ((c->address->family == AF_INET) &&
+         prefix_match (CONNECTED_PREFIX (c), &p))
+       {
+        return 1;
+       }
+    }
+
+  return 0;
+}
+
 static const char *igmpmsgtype2str[IGMPMSG_WHOLEPKT + 1] = {
   "<unknown_upcall?>",
   "NOCACHE",
@@ -77,8 +101,8 @@ pim_mroute_msg_nocache (int fd, struct interface *ifp, const struct igmpmsg *msg
                        const char *src_str, const char *grp_str)
 {
   struct pim_interface *pim_ifp = ifp->info;
-  struct pim_rpf *rpg;
   struct pim_upstream *up;
+  struct pim_rpf *rpg;
 
   rpg = RP(msg->im_dst);
   /*
@@ -92,6 +116,18 @@ pim_mroute_msg_nocache (int fd, struct interface *ifp, const struct igmpmsg *msg
       (pim_ifp->itype == PIM_INTERFACE_SSM))
     return 0;
 
+  /*
+   * If we've received a multicast packet that isn't connected to
+   * us
+   */
+  if (!pim_mroute_connected_to_source (ifp, msg->im_src))
+    {
+      if (PIM_DEBUG_PIM_TRACE)
+       zlog_debug ("%s: Received incoming packet that does originate on our seg",
+                  __PRETTY_FUNCTION__);
+      return 0;
+    }
+
   if (PIM_DEBUG_PIM_TRACE) {
     zlog_debug("%s: Adding a Route for %s from %s for WHOLEPKT consumption",
               __PRETTY_FUNCTION__, grp_str, src_str);