summaryrefslogtreecommitdiff
path: root/pimd/pim_pim.c
diff options
context:
space:
mode:
authorChirag Shah <chirag@cumulusnetworks.com>2017-01-11 19:36:50 -0800
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-02-14 15:52:09 -0500
commit5637da0501faa600273ecd7a2ed39cdbbe4531b1 (patch)
tree91c9476f77893d7b9c201ec41c7b761e63a75d96 /pimd/pim_pim.c
parent48f6dc2dae2572864db373ddc556518c2ab2ad85 (diff)
pimd: non-null register checksum incorrect
Ticket: CM-12041 Reviewed By: sharpd, CCR-5556 Testing Done: Tested on Local setup generating PIM Register (Data/Null) and processing both Tx/Rx with correct checksum. Provided quagga debian to submitter and checksum cases passed on submitter setup. 1. PIM Register msg checksum only accounts for 8 bytes (4 bytes for PIM header and next 4 byetes before data payload). In PIM header checksum calculation checked PIM packet type (in this case REGISTER type) then only pass 8 bytes as length rather than full packet length. 2. PIM Register Rx path also handled with 8 byte and full pim lenth checksum. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'pimd/pim_pim.c')
-rw-r--r--pimd/pim_pim.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index f727d3e627..840004c375 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -197,13 +197,37 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
/* for computing checksum */
*(uint16_t *) PIM_MSG_HDR_OFFSET_CHECKSUM(pim_msg) = 0;
- checksum = in_cksum(pim_msg, pim_msg_len);
- if (checksum != pim_checksum) {
- if (PIM_DEBUG_PIM_PACKETS)
- zlog_debug("Ignoring PIM pkt from %s with invalid checksum: received=%x calculated=%x",
- ifp->name, pim_checksum, checksum);
- return -1;
- }
+ if (pim_type == PIM_MSG_TYPE_REGISTER)
+ {
+ /* First 8 byte header checksum */
+ checksum = in_cksum (pim_msg, PIM_MSG_REGISTER_LEN);
+ if (checksum != pim_checksum)
+ {
+ checksum = in_cksum (pim_msg, pim_msg_len);
+ if (checksum != pim_checksum)
+ {
+ if (PIM_DEBUG_PIM_PACKETS)
+ zlog_debug
+ ("Ignoring PIM pkt from %s with invalid checksum: received=%x calculated=%x",
+ ifp->name, pim_checksum, checksum);
+
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ checksum = in_cksum (pim_msg, pim_msg_len);
+ if (checksum != pim_checksum)
+ {
+ if (PIM_DEBUG_PIM_PACKETS)
+ zlog_debug
+ ("Ignoring PIM pkt from %s with invalid checksum: received=%x calculated=%x",
+ ifp->name, pim_checksum, checksum);
+
+ return -1;
+ }
+ }
if (PIM_DEBUG_PIM_PACKETS) {
pim_inet4_dump("<src?>", ip_hdr->ip_src, src_str, sizeof(src_str));