]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Fix checksum calculation to not include old checksum
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 18 Feb 2020 00:43:22 +0000 (19:43 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 18 Feb 2020 14:34:18 +0000 (09:34 -0500)
As part of checksum calculation for a received packet we were
comparing the checksum returned from in_cksum.  Typically
when we calculate the checksum the value stored in the checksum
must be all 0's.  Store the received checksum and then set
the checksum to 0 and then compare.

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

index 450dfbece311480ff5288f84d26efafccdd77d37..13dcab92944c1204886550c48073a529608212dd 100644 (file)
@@ -78,6 +78,7 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
        int ip_hlen, iplen, datalen;
        struct zebra_if *zi;
        struct irdp_interface *irdp;
+       uint16_t saved_chksum;
 
        zi = ifp->info;
        if (!zi)
@@ -121,8 +122,10 @@ static void parse_irdp_packet(char *p, int len, struct interface *ifp)
 
        icmp = (struct icmphdr *)(p + ip_hlen);
 
+       saved_chksum = icmp->checksum;
+       icmp->checksum = 0;
        /* check icmp checksum */
-       if (in_cksum(icmp, datalen) != icmp->checksum) {
+       if (in_cksum(icmp, datalen) != saved_chksum) {
                flog_warn(
                        EC_ZEBRA_IRDP_BAD_CHECKSUM,
                        "IRDP: RX ICMP packet from %s. Bad checksum, silently ignored",