]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_igmp.c
Merge pull request #5767 from ton31337/fix/replace_s_addr_0_to_INADDR_ANY
[mirror_frr.git] / pimd / pim_igmp.c
index 7dfd26ea655d9c67662c5510ebf0313c15876223..39ef706f79c1118e11ba3b87c4bf4283aa9cb06f 100644 (file)
@@ -312,6 +312,13 @@ static int igmp_recv_query(struct igmp_sock *igmp, int query_version,
                return 0;
        }
 
+       if (if_lookup_address(&from, AF_INET, ifp->vrf_id)) {
+               if (PIM_DEBUG_IGMP_PACKETS)
+                       zlog_debug("Recv IGMP query on interface: %s from ourself %s",
+                                  ifp->name, from_str);
+               return 0;
+       }
+
        /* Collecting IGMP Rx stats */
        switch (query_version) {
        case 1:
@@ -471,30 +478,31 @@ int pim_igmp_packet(struct igmp_sock *igmp, char *buf, size_t len)
 
        ip_hlen = ip_hdr->ip_hl << 2; /* ip_hl gives length in 4-byte words */
 
-       if (PIM_DEBUG_IGMP_PACKETS) {
-               zlog_debug(
-                       "Recv IP packet from %s to %s on %s: size=%zu ip_header_size=%zu ip_proto=%d",
-                       from_str, to_str, igmp->interface->name, len, ip_hlen,
-                       ip_hdr->ip_p);
+       if (ip_hlen > len) {
+               zlog_warn(
+                       "IGMP packet header claims size %zu, but we only have %zu bytes",
+                       ip_hlen, len);
+               return -1;
        }
 
        igmp_msg = buf + ip_hlen;
-       msg_type = *igmp_msg;
        igmp_msg_len = len - ip_hlen;
 
-       if (PIM_DEBUG_IGMP_PACKETS) {
-               zlog_debug(
-                       "Recv IGMP packet from %s to %s on %s: ttl=%d msg_type=%d msg_size=%d",
-                       from_str, to_str, igmp->interface->name, ip_hdr->ip_ttl,
-                       msg_type, igmp_msg_len);
-       }
-
        if (igmp_msg_len < PIM_IGMP_MIN_LEN) {
                zlog_warn("IGMP message size=%d shorter than minimum=%d",
                          igmp_msg_len, PIM_IGMP_MIN_LEN);
                return -1;
        }
 
+       msg_type = *igmp_msg;
+
+       if (PIM_DEBUG_IGMP_PACKETS) {
+               zlog_debug(
+                       "Recv IGMP packet from %s to %s on %s: size=%zu ttl=%d msg_type=%d msg_size=%d",
+                       from_str, to_str, igmp->interface->name, len, ip_hdr->ip_ttl,
+                       msg_type, igmp_msg_len);
+       }
+
        switch (msg_type) {
        case PIM_IGMP_MEMBERSHIP_QUERY: {
                int max_resp_code = igmp_msg[1];
@@ -1105,8 +1113,10 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
        }
 
        if (pim_is_group_224_0_0_0_24(group_addr)) {
-               zlog_warn("%s: Group specified is part of 224.0.0.0/24",
-                         __PRETTY_FUNCTION__);
+               if (PIM_DEBUG_IGMP_TRACE)
+                       zlog_debug(
+                               "%s: Group specified %s is part of 224.0.0.0/24",
+                               __PRETTY_FUNCTION__, inet_ntoa(group_addr));
                return NULL;
        }
        /*