]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Don't allow invalid groups to be passed for igmp
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 1 Dec 2016 22:12:21 +0000 (17:12 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:17 +0000 (20:26 -0500)
When we receive a invalid group( say outside of the 224/4
range) don't allow it to create state.  Nicely reject
the rejectable.

Ticket: CM-13821
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_igmp.c
pimd/pim_util.c
pimd/pim_util.h

index 87a54d68d0e06d3ddce044e7d7c1bfe616206d88..1ca79a5a546adc0c34e9800e649acd1738f1f35e 100644 (file)
@@ -1050,6 +1050,13 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
     return group;
   }
 
+  if (!pim_is_group_224_4 (group_addr))
+    {
+      zlog_warn("%s: Group Specified is not part of 224.0.0.0/4",
+               __PRETTY_FUNCTION__);
+      return NULL;
+    }
+
   /*
     Non-existant group is created as INCLUDE {empty}:
 
@@ -1067,7 +1074,7 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
   if (!group) {
     zlog_warn("%s %s: XCALLOC() failure",
              __FILE__, __PRETTY_FUNCTION__);
-    return 0; /* error, not found, could not create */
+    return NULL; /* error, not found, could not create */
   }
 
   group->group_source_list = list_new();
@@ -1075,7 +1082,7 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
     zlog_warn("%s %s: list_new() failure",
              __FILE__, __PRETTY_FUNCTION__);
     XFREE(MTYPE_PIM_IGMP_GROUP, group); /* discard group */
-    return 0; /* error, not found, could not initialize */
+    return NULL; /* error, not found, could not initialize */
   }
   group->group_source_list->del = (void (*)(void *)) igmp_source_free;
 
index daee941f8b35f4e3cc385bdd9eff6864e25dad4f..f5255a241da38be05b703a1af06061ff7edcf801 100644 (file)
@@ -22,6 +22,7 @@
 #include <zebra.h>
 
 #include "log.h"
+#include "prefix.h"
 
 #include "pim_util.h"
 
@@ -104,3 +105,20 @@ void pim_pkt_dump(const char *label, const uint8_t *buf, int size)
             size);
   zlog_hexdump(buf, size);
 }
+
+int
+pim_is_group_224_4 (struct in_addr group_addr)
+{
+  static int first = 1;
+  static struct prefix group_all;
+  struct prefix group;
+
+  if (first)
+    str2prefix ("224.0.0.0/4", &group_all);
+
+  group.family = AF_INET;
+  group.u.prefix4 = group_addr;
+  group.prefixlen = 32;
+
+  return prefix_match (&group_all, &group);
+}
index 23a968864793327d7dd100a625665353bf9bb784..a948f81ce865a2f8de7c37867ec6c4838df4c6c8 100644 (file)
@@ -33,4 +33,5 @@ uint16_t igmp_msg_decode8to16(uint8_t code);
 
 void pim_pkt_dump(const char *label, const uint8_t *buf, int size);
 
+int pim_is_group_224_4 (struct in_addr group_addr);
 #endif /* PIM_UTIL_H */