mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-03 05:21:31 +00:00
Merge pull request #7148 from pguibert6WIND/fix_fd_not_closed
zebra: fix fd going out of scope leaks the handle
This commit is contained in:
commit
aa178efd49
@ -182,7 +182,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
||||
if (sock < 0) {
|
||||
flog_err_sys(EC_LIB_SOCKET, "netlink( %u) socket() error: %s",
|
||||
sock, safe_strerror(errno));
|
||||
if (fd_param == -1)
|
||||
if (netnspath)
|
||||
close(fd);
|
||||
return NS_UNKNOWN;
|
||||
}
|
||||
@ -196,7 +196,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
||||
"netlink( %u) socket() bind error: %s", sock,
|
||||
safe_strerror(errno));
|
||||
close(sock);
|
||||
if (fd_param == -1)
|
||||
if (netnspath)
|
||||
close(fd);
|
||||
return NS_UNKNOWN;
|
||||
}
|
||||
@ -219,7 +219,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
||||
ret = send_receive(sock, nlh, seq, buf);
|
||||
if (ret < 0) {
|
||||
close(sock);
|
||||
if (fd_param == -1)
|
||||
if (netnspath)
|
||||
close(fd);
|
||||
return NS_UNKNOWN;
|
||||
}
|
||||
@ -264,7 +264,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
||||
"netlink( %u) recvfrom() error 2 when reading: %s",
|
||||
fd, safe_strerror(errno));
|
||||
close(sock);
|
||||
if (fd_param == -1)
|
||||
if (netnspath)
|
||||
close(fd);
|
||||
if (errno == ENOTSUP) {
|
||||
zlog_debug("NEWNSID locally generated");
|
||||
@ -286,7 +286,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
||||
ret = send_receive(sock, nlh, seq, buf);
|
||||
if (ret < 0) {
|
||||
close(sock);
|
||||
if (fd_param == -1)
|
||||
if (netnspath)
|
||||
close(fd);
|
||||
return NS_UNKNOWN;
|
||||
}
|
||||
@ -318,7 +318,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
||||
} while (len != 0 && ret == 0);
|
||||
}
|
||||
|
||||
if (fd_param == -1)
|
||||
if (netnspath)
|
||||
close(fd);
|
||||
close(sock);
|
||||
return return_nsid;
|
||||
|
Loading…
Reference in New Issue
Block a user