gathering / gondul

Network management/monitoring system specialized for temporary events
http://tech.gathering.org
GNU General Public License v2.0
43 stars 10 forks source link

NMS: Finne ut av hvorfor 2-3 pings droppes hver gang. #7

Open KristianLyng opened 8 years ago

KristianLyng commented 8 years ago

From @KristianLyng on March 17, 2016 7:16

Håper det er grunnet testmiljøet.

Copied from original issue: tech-server/tgmanage#38

KristianLyng commented 8 years ago

Sesse har vel egentlig alt lokalisert dette:

Se http://pastebin.com/raw/QD4QU2j9

--- liboping-1.8.0.orig/src/liboping.c
+++ liboping-1.8.0/src/liboping.c
@@ -267,7 +267,7 @@ static uint16_t ping_icmp4_checksum (cha
        return (ret);
 }

-static pinghost_t *ping_receive_ipv4 (pingobj_t *obj, char *buffer,
+static pinghost_t *ping_receive_ipv4 (pingobj_t *obj, struct sockaddr_in *addr, char *buffer,
                size_t buffer_len)
 {
        struct ip *ip_hdr;
@@ -343,6 +343,9 @@ static pinghost_t *ping_receive_ipv4 (pi
                if (((ptr->sequence - 1) & 0xFFFF) != seq)
                        continue;

+               if (((struct sockaddr_in *)ptr->addr)->sin_addr.s_addr != addr->sin_addr.s_addr)
+                       continue;
+
                dprintf ("Match found: hostname = %s, ident = 0x%04"PRIx16", "
                                "seq = %"PRIu16"\n",
                                ptr->hostname, ident, seq);
@@ -379,7 +382,7 @@ static pinghost_t *ping_receive_ipv4 (pi
 # endif
 #endif

-static pinghost_t *ping_receive_ipv6 (pingobj_t *obj, char *buffer,
+static pinghost_t *ping_receive_ipv6 (pingobj_t *obj, struct sockaddr_in6 *addr, char *buffer,
                size_t buffer_len)
 {
        struct icmp6_hdr *icmp_hdr;
@@ -430,6 +433,10 @@ static pinghost_t *ping_receive_ipv6 (pi
                if (((ptr->sequence - 1) & 0xFFFF) != seq)
                        continue;

+               if (memcmp(&((struct sockaddr_in6 *)ptr->addr)->sin6_addr,
+                          &addr->sin6_addr, sizeof(struct sockaddr_in6)) != 0)
+                       continue;
+
                dprintf ("Match found: hostname = %s, ident = 0x%04"PRIx16", "
                                "seq = %"PRIu16"\n",
                                ptr->hostname, ident, seq);
@@ -591,13 +598,13 @@ static int ping_receive_one (pingobj_t *

        if (ph->addrfamily == AF_INET)
        {
-               host = ping_receive_ipv4 (obj, payload_buffer, payload_buffer_len);
+               host = ping_receive_ipv4 (obj, (struct sockaddr_in *)ph->addr, payload_buffer, payload_buffer_len);
                if (host == NULL)
                        return (-1);
        }
        else if (ph->addrfamily == AF_INET6)
        {
-               host = ping_receive_ipv6 (obj, payload_buffer, payload_buffer_len);
+               host = ping_receive_ipv6 (obj, (struct sockaddr_in6 *)ph->addr, payload_buffer, payload_buffer_len);
                if (host == NULL)
                        return (-1);
        }
KristianLyng commented 8 years ago

Usikker på om dette er samme. Orginalproblemet var falske negativer, denne patchen er mest for falske positiver...