mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
zebra: don't misappropriate errno
`errno` has its own semantics. Sometimes it is correct to write to it. This is not one of those cases - just use a separate `nl_errno`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
1350f8d1c1
commit
67b0a457ed
|
@ -159,6 +159,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
|||
int fd = -1, sock, ret;
|
||||
unsigned int seq;
|
||||
ns_id_t return_nsid = NS_UNKNOWN;
|
||||
int nl_errno;
|
||||
|
||||
/* netns path check */
|
||||
if (!netnspath && fd_param == -1)
|
||||
|
@ -231,32 +232,31 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
|
|||
|
||||
ret = -1;
|
||||
if (err->error < 0)
|
||||
errno = -err->error;
|
||||
nl_errno = -err->error;
|
||||
else
|
||||
errno = err->error;
|
||||
if (errno == 0) {
|
||||
nl_errno = err->error;
|
||||
if (nl_errno == 0) {
|
||||
/* request NEWNSID was successfull
|
||||
* return EEXIST error to get GETNSID
|
||||
*/
|
||||
errno = EEXIST;
|
||||
nl_errno = EEXIST;
|
||||
}
|
||||
} else {
|
||||
/* other errors ignored
|
||||
* attempt to get nsid
|
||||
*/
|
||||
ret = -1;
|
||||
errno = EEXIST;
|
||||
nl_errno = EEXIST;
|
||||
}
|
||||
}
|
||||
|
||||
if (errno != EEXIST && ret != 0) {
|
||||
flog_err(EC_LIB_SOCKET,
|
||||
"netlink( %u) recvfrom() error 2 when reading: %s", fd,
|
||||
safe_strerror(errno));
|
||||
if (ret != 0 && nl_errno != EEXIST) {
|
||||
flog_err(EC_LIB_SOCKET, "netlink( %u) recvfrom() error 2 when reading: %s", fd,
|
||||
safe_strerror(nl_errno));
|
||||
close(sock);
|
||||
if (netnspath)
|
||||
close(fd);
|
||||
if (errno == ENOTSUP) {
|
||||
if (nl_errno == ENOTSUP) {
|
||||
zlog_debug("NEWNSID locally generated");
|
||||
return zebra_ns_id_get_fallback(netnspath);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue