pim_free_bsgrp_data(bsgrp);
}
- if (pim->global_scope.bsrp_table)
- route_table_finish(pim->global_scope.bsrp_table);
+ route_table_finish(pim->global_scope.bsrp_table);
}
static bool is_hold_time_elapsed(void *data)
return false;
}
- pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address, dst_addr,
- buf, len, ifp->name);
+ if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address,
+ dst_addr, buf, len, ifp->name)) {
+ zlog_warn("%s: Could not send BSM message on interface: %s",
+ __PRETTY_FUNCTION__, ifp->name);
+ return false;
+ }
+
pim_ifp->pim_ifstat_bsm_tx++;
pim_ifp->pim->bsm_sent++;
return true;
/* MTU passed here is PIM MTU (IP MTU less IP Hdr) */
if (pim_mtu < (PIM_MIN_BSM_LEN)) {
zlog_warn(
- "%s: mtu(pim mtu: %d) size less than minimum bootsrap len",
+ "%s: mtu(pim mtu: %d) size less than minimum bootstrap len",
__PRETTY_FUNCTION__, pim_mtu);
if (PIM_DEBUG_BSM)
zlog_debug(
- "%s: mtu (pim mtu:%d) less than minimum bootsrap len",
+ "%s: mtu (pim mtu:%d) less than minimum bootstrap len",
__PRETTY_FUNCTION__, pim_mtu);
return false;
}
struct pim_interface *pim_ifp;
struct in_addr dst_addr;
uint32_t pim_mtu;
- bool no_fwd = FALSE;
- bool ret = FALSE;
+ bool no_fwd = false;
+ bool ret = false;
/* For now only global scope zone is supported, so send on all
* pim interfaces in the vrf
if (!pim_bsm_send_intf(buf, len, ifp, dst_addr)) {
if (PIM_DEBUG_BSM)
zlog_debug(
- "%s: pim_bsm_send_intf returned FALSE",
+ "%s: pim_bsm_send_intf returned false",
__PRETTY_FUNCTION__);
}
}
else
grpaddr = grpaddr & mask;
rp_add = ntohl(rp.s_addr);
- temp = 1103515245 * ((1103515245 * grpaddr + 12345) ^ rp_add) + 12345;
+ temp = 1103515245 * ((1103515245 * (uint64_t)grpaddr + 12345) ^ rp_add)
+ + 12345;
hash = temp & (0x7fffffff);
return hash;
}
int ins_count = 0;
while (buflen > offset) {
+ if (offset + (int)sizeof(struct bsmmsg_grpinfo) > buflen) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug(
+ "%s: buflen received %d is less than the internal data structure of the packet would suggest",
+ __PRETTY_FUNCTION__, buflen);
+ return false;
+ }
/* Extract Group tlv from BSM */
memcpy(&grpinfo, buf, sizeof(struct bsmmsg_grpinfo));
}
group.family = AF_INET;
+ if (grpinfo.group.mask > IPV4_MAX_BITLEN) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug("%s, v4 prefix length specified: %d is too long",
+ __PRETTY_FUNCTION__, grpinfo.group.mask);
+ return false;
+ }
group.prefixlen = grpinfo.group.mask;
group.u.prefix4.s_addr = grpinfo.group.addr.s_addr;
ins_count = 0;
while (frag_rp_cnt--) {
+ if (offset + (int)sizeof(struct bsmmsg_rpinfo)
+ > buflen) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug(
+ "%s, buflen received: %u is less than the internal data structure of the packet would suggest",
+ __PRETTY_FUNCTION__, buflen);
+ return false;
+ }
+
/* Extract RP address tlv from BSM */
memcpy(&rpinfo, buf, sizeof(struct bsmmsg_rpinfo));
rpinfo.rp_holdtime = ntohs(rpinfo.rp_holdtime);
struct pim_instance *pim;
char bsr_str[INET_ADDRSTRLEN];
uint16_t frag_tag;
- bool empty_bsm = FALSE;
+ bool empty_bsm = false;
/* BSM Packet acceptance validation */
pim_ifp = ifp->info;
return -1;
}
+ if (buf_size < (PIM_MSG_HEADER_LEN + sizeof(struct bsm_hdr))) {
+ if (PIM_DEBUG_BSM)
+ zlog_debug("%s: received buffer length of %d which is too small to properly decode",
+ __PRETTY_FUNCTION__, buf_size);
+ return -1;
+ }
+
bshdr = (struct bsm_hdr *)(buf + PIM_MSG_HEADER_LEN);
pim_inet4_dump("<bsr?>", bshdr->bsr_addr.addr, bsr_str,
sizeof(bsr_str));