Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Coverity fixes for RPKI per-VRF #15200

Closed
wants to merge 14 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions bgpd/bgp_rpki.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,11 +1345,29 @@ static int rpki_create_socket(void *_cache)
timeout.tv_usec = 0;

optlen = sizeof(prev_rcv_tmout);
getsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &prev_rcv_tmout, &optlen);
getsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &prev_snd_tmout, &optlen);

setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
ret = getsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &prev_rcv_tmout,
&optlen);
if (ret < 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to free res when if (ret < 0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, that was correct.

zlog_warn("%s: failed to getsockopt SO_RCVTIMEO for socket %d",
__func__, socket);

ret = getsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &prev_snd_tmout,
&optlen);
if (ret < 0)
zlog_warn("%s: failed to getsockopt SO_SNDTIMEO for socket %d",
__func__, socket);

ret = setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &timeout,
sizeof(timeout));
if (ret < 0)
zlog_warn("%s: failed to setsockopt SO_RCVTIMEO for socket %d",
__func__, socket);

ret = setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &timeout,
sizeof(timeout));
if (ret < 0)
zlog_warn("%s: failed to setsockopt SO_SNDTIMEO for socket %d",
__func__, socket);

if (connect(socket, res->ai_addr, res->ai_addrlen) == -1) {
if (res)
Expand All @@ -1363,10 +1381,17 @@ static int rpki_create_socket(void *_cache)
freeaddrinfo(res);
pthread_setcancelstate(cancel_state, NULL);

setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &prev_rcv_tmout,
sizeof(prev_rcv_tmout));
setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &prev_snd_tmout,
sizeof(prev_snd_tmout));
ret = setsockopt(socket, SOL_SOCKET, SO_RCVTIMEO, &prev_rcv_tmout,
sizeof(prev_rcv_tmout));
if (ret < 0)
zlog_warn("%s: failed to setsockopt SO_RCVTIMEO for socket %d",
__func__, socket);

ret = setsockopt(socket, SOL_SOCKET, SO_SNDTIMEO, &prev_snd_tmout,
sizeof(prev_snd_tmout));
if (ret < 0)
zlog_warn("%s: failed to setsockopt SO_SNDTIMEO for socket %d",
__func__, socket);

return socket;
}
Expand Down