diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2024-09-25 12:30:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-25 12:30:19 -0400 |
| commit | c57712c11de545d3a02b36c8fbe447845fb6c02b (patch) | |
| tree | 82bfa6fe38e6f2da0bed0c15fca87f496e52e55e /pimd/pim_autorp.c | |
| parent | f5fb095433e8e1d048ca753ffa84cb68e70fdc7d (diff) | |
| parent | 3e6cc0d0f19e925d20e709af5a0518896fa94b51 (diff) | |
Merge pull request #16916 from nabahr/pim-coverity
pimd: Fix new issues found in coverity
Diffstat (limited to 'pimd/pim_autorp.c')
| -rw-r--r-- | pimd/pim_autorp.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/pimd/pim_autorp.c b/pimd/pim_autorp.c index cf0b9d5550..8f3b8de3cd 100644 --- a/pimd/pim_autorp.c +++ b/pimd/pim_autorp.c @@ -540,9 +540,13 @@ static void autorp_send_announcement(struct event *evt) inet_pton(PIM_AF, PIM_AUTORP_ANNOUNCEMENT_GRP, &announceGrp.sin_addr); if (autorp->annouce_pkt_sz >= MIN_AUTORP_PKT_SZ) { - setsockopt(autorp->sock, IPPROTO_IP, IP_MULTICAST_TTL, - &(autorp->announce_scope), - sizeof(autorp->announce_scope)); + if (setsockopt(autorp->sock, IPPROTO_IP, IP_MULTICAST_TTL, + &(autorp->announce_scope), + sizeof(autorp->announce_scope)) < 0) { + if (PIM_DEBUG_AUTORP) + zlog_err("%s: Failed to set Multicast TTL for sending AutoRP announcement message, errno=%d, %s", + __func__, errno, safe_strerror(errno)); + } FOR_ALL_INTERFACES (autorp->pim->vrf, ifp) { pim_ifp = ifp->info; @@ -553,14 +557,25 @@ static void autorp_send_announcement(struct event *evt) pim_ifp && pim_ifp->pim_enable && !pim_ifp->pim_passive_enable && !pim_addr_is_any(pim_ifp->primary_address)) { - setsockopt(autorp->sock, IPPROTO_IP, - IP_MULTICAST_IF, - &(pim_ifp->primary_address), - sizeof(pim_ifp->primary_address)); - sendto(autorp->sock, autorp->annouce_pkt, - autorp->annouce_pkt_sz, 0, - (struct sockaddr *)&announceGrp, - sizeof(announceGrp)); + if (setsockopt(autorp->sock, IPPROTO_IP, + IP_MULTICAST_IF, + &(pim_ifp->primary_address), + sizeof(pim_ifp->primary_address)) < + 0) { + if (PIM_DEBUG_AUTORP) + zlog_err("%s: Failed to set Multicast Interface for sending AutoRP announcement message, errno=%d, %s", + __func__, errno, + safe_strerror(errno)); + } + if (sendto(autorp->sock, autorp->annouce_pkt, + autorp->annouce_pkt_sz, 0, + (struct sockaddr *)&announceGrp, + sizeof(announceGrp)) <= 0) { + if (PIM_DEBUG_AUTORP) + zlog_err("%s: Failed to send AutoRP announcement message, errno=%d, %s", + __func__, errno, + safe_strerror(errno)); + } } } } |
