diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2024-10-16 12:53:47 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2024-10-16 13:30:25 +0200 |
commit | 67b0a457ed32fd452aa4622c20531b9721cc3328 (patch) | |
tree | 15cc848f6da92ca73b2ea5b40832bca67baa21d8 /zebra/zebra_netns_id.c | |
parent | zebra: don't try to read past EOF (diff) | |
download | frr-67b0a457ed32fd452aa4622c20531b9721cc3328.tar.xz frr-67b0a457ed32fd452aa4622c20531b9721cc3328.zip |
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>
Diffstat (limited to 'zebra/zebra_netns_id.c')
-rw-r--r-- | zebra/zebra_netns_id.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/zebra/zebra_netns_id.c b/zebra/zebra_netns_id.c index 4cee3b89f..3da79e249 100644 --- a/zebra/zebra_netns_id.c +++ b/zebra/zebra_netns_id.c @@ -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); } |