summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--babeld/babel_interface.c4
-rw-r--r--babeld/babel_main.c14
-rw-r--r--babeld/babeld.c4
-rw-r--r--bgpd/bgp_fsm.c6
-rw-r--r--bgpd/bgp_network.c26
-rw-r--r--bgpd/bgp_packet.c6
-rw-r--r--eigrpd/eigrp_network.c4
-rw-r--r--eigrpd/eigrpd.c5
-rw-r--r--ldpd/ldpd.c6
-rw-r--r--lib/buffer.c11
-rw-r--r--lib/command.c4
-rw-r--r--lib/libfrr.c12
-rw-r--r--lib/log.c28
-rw-r--r--lib/log.h2
-rw-r--r--lib/netns_linux.c6
-rw-r--r--lib/pid_output.c28
-rw-r--r--lib/sigevent.c4
-rw-r--r--lib/sockopt.c13
-rw-r--r--lib/vrf.c44
-rw-r--r--lib/vty.c43
-rw-r--r--ospf6d/ospf6_network.c7
-rw-r--r--pimd/pim_igmp.c7
-rw-r--r--pimd/pim_msdp_packet.c4
-rw-r--r--pimd/pim_msdp_socket.c50
-rw-r--r--pimd/pim_sock.c6
-rw-r--r--pimd/pim_ssmpingd.c6
-rw-r--r--pimd/pim_time.c24
-rw-r--r--pimd/pim_zlookup.c6
-rw-r--r--ripd/rip_interface.c6
-rw-r--r--ripd/ripd.c13
-rw-r--r--ripngd/ripng_interface.c6
-rw-r--r--ripngd/ripngd.c19
-rw-r--r--watchfrr/watchfrr.c55
-rw-r--r--zebra/if_ioctl.c4
-rw-r--r--zebra/ioctl.c26
-rw-r--r--zebra/ioctl_solaris.c10
-rw-r--r--zebra/ipforward_solaris.c8
-rw-r--r--zebra/kernel_netlink.c49
-rw-r--r--zebra/rtadv.c8
-rw-r--r--zebra/zebra_mpls_openbsd.c16
-rw-r--r--zebra/zebra_netns_id.c19
41 files changed, 318 insertions, 301 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index f17d83905..b7c01e73d 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -729,7 +729,7 @@ interface_recalculate(struct interface *ifp)
rc = setsockopt(protocol_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP,
(char*)&mreq, sizeof(mreq));
if(rc < 0) {
- flog_err(LIB_ERR_SOCKET,
+ flog_err_sys(LIB_ERR_SOCKET,
"setsockopt(IPV6_JOIN_GROUP) on interface '%s': %s",
ifp->name, safe_strerror(errno));
/* This is probably due to a missing link-local address,
@@ -793,7 +793,7 @@ interface_reset(struct interface *ifp)
rc = setsockopt(protocol_socket, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
(char*)&mreq, sizeof(mreq));
if(rc < 0)
- flog_err(LIB_ERR_SOCKET,
+ flog_err_sys(LIB_ERR_SOCKET,
"setsockopt(IPV6_LEAVE_GROUP) on interface '%s': %s",
ifp->name, safe_strerror(errno));
}
diff --git a/babeld/babel_main.c b/babeld/babel_main.c
index 89617c0dc..31a3fb5b4 100644
--- a/babeld/babel_main.c
+++ b/babeld/babel_main.c
@@ -225,7 +225,7 @@ babel_init_random(void)
rc = read_random_bytes(&seed, sizeof(seed));
if(rc < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL, "read(random): %s",
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "read(random): %s",
safe_strerror(errno));
seed = 42;
}
@@ -246,13 +246,13 @@ babel_replace_by_null(int fd)
fd_null = open("/dev/null", O_RDONLY);
if(fd_null < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL, "open(null): %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "open(null): %s", safe_strerror(errno));
exit(1);
}
rc = dup2(fd_null, fd);
if(rc < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL, "dup2(null, 0): %s",
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "dup2(null, 0): %s",
safe_strerror(errno));
exit(1);
}
@@ -272,11 +272,11 @@ babel_load_state_file(void)
fd = open(state_file, O_RDONLY);
if(fd < 0 && errno != ENOENT)
- flog_err(LIB_ERR_SYSTEM_CALL, "open(babel-state: %s)",
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "open(babel-state: %s)",
safe_strerror(errno));
rc = unlink(state_file);
if(fd >= 0 && rc < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL, "unlink(babel-state): %s",
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "unlink(babel-state): %s",
safe_strerror(errno));
/* If we couldn't unlink it, it's probably stale. */
goto fini;
@@ -288,7 +288,7 @@ babel_load_state_file(void)
long t;
rc = read(fd, buf, 99);
if(rc < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL, "read(babel-state): %s",
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "read(babel-state): %s",
safe_strerror(errno));
} else {
buf[rc] = '\0';
@@ -353,7 +353,7 @@ babel_save_state_file(void)
debugf(BABEL_DEBUG_COMMON, "Save state file.");
fd = open(state_file, O_WRONLY | O_TRUNC | O_CREAT, 0644);
if(fd < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL, "creat(babel-state): %s",
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "creat(babel-state): %s",
safe_strerror(errno));
unlink(state_file);
} else {
diff --git a/babeld/babeld.c b/babeld/babeld.c
index b05f26919..54692cdf2 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -145,7 +145,7 @@ babel_create_routing_process (void)
/* Make socket for Babel protocol. */
protocol_socket = babel_socket(protocol_port);
if (protocol_socket < 0) {
- flog_err(LIB_ERR_SOCKET, "Couldn't create link local socket: %s",
+ flog_err_sys(LIB_ERR_SOCKET, "Couldn't create link local socket: %s",
safe_strerror(errno));
goto fail;
}
@@ -179,7 +179,7 @@ babel_read_protocol (struct thread *thread)
(struct sockaddr*)&sin6, sizeof(sin6));
if(rc < 0) {
if(errno != EAGAIN && errno != EINTR) {
- flog_err(LIB_ERR_SOCKET, "recv: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "recv: %s", safe_strerror(errno));
}
} else {
FOR_ALL_INTERFACES(vrf, ifp) {
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index d90e6983a..14d692ebf 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -1294,9 +1294,9 @@ static int bgp_connect_success(struct peer *peer)
}
if (bgp_getsockname(peer) < 0) {
- flog_err(LIB_ERR_SOCKET,
- "%s: bgp_getsockname(): failed for peer %s, fd %d",
- __FUNCTION__, peer->host, peer->fd);
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: bgp_getsockname(): failed for peer %s, fd %d",
+ __FUNCTION__, peer->host, peer->fd);
bgp_notify_send(peer, BGP_NOTIFY_FSM_ERR,
0); /* internal error */
bgp_writes_on(peer);
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index db50ae828..666cc5bb8 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -296,8 +296,8 @@ static int bgp_accept(struct thread *thread)
/* Register accept thread. */
accept_sock = THREAD_FD(thread);
if (accept_sock < 0) {
- flog_err(LIB_ERR_SOCKET, "accept_sock is nevative value %d",
- accept_sock);
+ flog_err_sys(LIB_ERR_SOCKET, "accept_sock is nevative value %d",
+ accept_sock);
return -1;
}
listener->thread = NULL;
@@ -308,9 +308,9 @@ static int bgp_accept(struct thread *thread)
/* Accept client connection. */
bgp_sock = sockunion_accept(accept_sock, &su);
if (bgp_sock < 0) {
- flog_err(LIB_ERR_SOCKET,
- "[Error] BGP socket accept failed (%s)",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "[Error] BGP socket accept failed (%s)",
+ safe_strerror(errno));
return -1;
}
set_nonblocking(bgp_sock);
@@ -681,13 +681,14 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen,
__func__);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET, "bind: %s", safe_strerror(en));
+ flog_err_sys(LIB_ERR_SOCKET, "bind: %s", safe_strerror(en));
return ret;
}
ret = listen(sock, SOMAXCONN);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET, "listen: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "listen: %s",
+ safe_strerror(errno));
return ret;
}
@@ -730,7 +731,8 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)
if (bgpd_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
if (ret != 0) {
- flog_err(LIB_ERR_SOCKET, "getaddrinfo: %s", gai_strerror(ret));
+ flog_err_sys(LIB_ERR_SOCKET, "getaddrinfo: %s",
+ gai_strerror(ret));
return -1;
}
@@ -750,8 +752,8 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)
if (bgpd_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
if (sock < 0) {
- flog_err(LIB_ERR_SOCKET, "socket: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "socket: %s",
+ safe_strerror(errno));
continue;
}
@@ -772,8 +774,8 @@ int bgp_socket(struct bgp *bgp, unsigned short port, const char *address)
LIB_ERR_SOCKET,
"%s: no usable addresses please check other programs usage of specified port %d",
__func__, port);
- flog_err(LIB_ERR_SOCKET, "%s: Program cannot continue",
- __func__);
+ flog_err_sys(LIB_ERR_SOCKET, "%s: Program cannot continue",
+ __func__);
exit(-1);
}
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 3c49b9692..bb474b9e2 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1304,9 +1304,9 @@ static int bgp_open_receive(struct peer *peer, bgp_size_t size)
/* Get sockname. */
if ((ret = bgp_getsockname(peer)) < 0) {
- flog_err(LIB_ERR_SOCKET,
- "%s: bgp_getsockname() failed for peer: %s",
- __FUNCTION__, peer->host);
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: bgp_getsockname() failed for peer: %s",
+ __FUNCTION__, peer->host);
return BGP_Stop;
}
diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c
index 0706ed8bc..189d85f4b 100644
--- a/eigrpd/eigrp_network.c
+++ b/eigrpd/eigrp_network.c
@@ -73,8 +73,8 @@ int eigrp_sock_init(void)
flog_err(LIB_ERR_PRIVILEGES,
"eigrp_sock_init: could not lower privs, %s",
safe_strerror(errno));
- flog_err(LIB_ERR_SOCKET, "eigrp_read_sock_init: socket: %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET, "eigrp_read_sock_init: socket: %s",
+ safe_strerror(save_errno));
exit(1);
}
diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c
index 29525173e..91c0046bb 100644
--- a/eigrpd/eigrpd.c
+++ b/eigrpd/eigrpd.c
@@ -162,8 +162,9 @@ static struct eigrp *eigrp_new(const char *AS)
eigrp->networks = eigrp_topology_new();
if ((eigrp_socket = eigrp_sock_init()) < 0) {
- flog_err(LIB_ERR_SOCKET,
- "eigrp_new: fatal error: eigrp_sock_init was unable to open a socket");
+ flog_err_sys(
+ LIB_ERR_SOCKET,
+ "eigrp_new: fatal error: eigrp_sock_init was unable to open a socket");
exit(1);
}
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index 494d1bacd..e830263de 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -484,9 +484,9 @@ start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync)
nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
if (nullfd == -1) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: failed to open /dev/null: %s", __func__,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: failed to open /dev/null: %s", __func__,
+ safe_strerror(errno));
} else {
dup2(nullfd, 0);
dup2(nullfd, 1);
diff --git a/lib/buffer.c b/lib/buffer.c
index c292e4341..0292c85da 100644
--- a/lib/buffer.c
+++ b/lib/buffer.c
@@ -343,11 +343,12 @@ buffer_status_t buffer_flush_window(struct buffer *b, int fd, int width,
iov_alloc * sizeof(*iov));
} else {
/* This should absolutely never occur. */
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: corruption detected: iov_small overflowed; "
- "head %p, tail %p, head->next %p",
- __func__, (void *)b->head,
- (void *)b->tail, (void *)b->head->next);
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "%s: corruption detected: iov_small overflowed; "
+ "head %p, tail %p, head->next %p",
+ __func__, (void *)b->head,
+ (void *)b->tail, (void *)b->head->next);
iov = XMALLOC(MTYPE_TMP,
iov_alloc * sizeof(*iov));
memcpy(iov, small_iov, sizeof(small_iov));
diff --git a/lib/command.c b/lib/command.c
index 5e1589280..1df644210 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -2417,8 +2417,8 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel)
cwd[MAXPATHLEN] = '\0';
if (getcwd(cwd, MAXPATHLEN) == NULL) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "config_log_file: Unable to alloc mem!");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "config_log_file: Unable to alloc mem!");
return CMD_WARNING_CONFIG_FAILED;
}
diff --git a/lib/libfrr.c b/lib/libfrr.c
index b7d4b192d..821c57f37 100644
--- a/lib/libfrr.c
+++ b/lib/libfrr.c
@@ -829,9 +829,9 @@ static void frr_terminal_close(int isexit)
nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
if (nullfd == -1) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: failed to open /dev/null: %s", __func__,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: failed to open /dev/null: %s", __func__,
+ safe_strerror(errno));
} else {
dup2(nullfd, 0);
dup2(nullfd, 1);
@@ -902,9 +902,9 @@ void frr_run(struct thread_master *master)
} else if (di->daemon_mode) {
int nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
if (nullfd == -1) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: failed to open /dev/null: %s", __func__,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: failed to open /dev/null: %s",
+ __func__, safe_strerror(errno));
} else {
dup2(nullfd, 0);
dup2(nullfd, 1);
diff --git a/lib/log.c b/lib/log.c
index ceff7b5f6..e011a78f1 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -633,16 +633,17 @@ void zlog_backtrace(int priority)
size = backtrace(array, array_size(array));
if (size <= 0 || (size_t)size > array_size(array)) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Cannot get backtrace, returned invalid # of frames %d "
- "(valid range is between 1 and %lu)",
- size, (unsigned long)(array_size(array)));
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "Cannot get backtrace, returned invalid # of frames %d "
+ "(valid range is between 1 and %lu)",
+ size, (unsigned long)(array_size(array)));
return;
}
zlog(priority, "Backtrace for %d stack frames:", size);
if (!(strings = backtrace_symbols(array, size))) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Cannot get backtrace symbols (out of memory?)");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Cannot get backtrace symbols (out of memory?)");
for (i = 0; i < size; i++)
zlog(priority, "[bt %d] %p", i, array[i]);
} else {
@@ -715,10 +716,10 @@ void _zlog_assert_failed(const char *assertion, const char *file,
void memory_oom(size_t size, const char *name)
{
- flog_err(LIB_ERR_SYSTEM_CALL,
- "out of memory: failed to allocate %zu bytes for %s"
- "object",
- size, name);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "out of memory: failed to allocate %zu bytes for %s"
+ "object",
+ size, name);
zlog_backtrace(LOG_ERR);
abort();
}
@@ -867,9 +868,10 @@ int zlog_rotate(void)
save_errno = errno;
umask(oldumask);
if (zl->fp == NULL) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Log rotate failed: cannot open file %s for append: %s",
- zl->filename, safe_strerror(save_errno));
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "Log rotate failed: cannot open file %s for append: %s",
+ zl->filename, safe_strerror(save_errno));
ret = -1;
} else {
logfile_fd = fileno(zl->fp);
diff --git a/lib/log.h b/lib/log.h
index a7d39b264..980f3ddf4 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -88,6 +88,8 @@ extern void zlog_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
/* For logs which have error codes associated with them */
#define flog_err(ferr_id, format, ...) \
zlog_err("[EC %d] " format, ferr_id, ##__VA_ARGS__)
+#define flog_err_sys(ferr_id, format, ...) \
+ flog_err(ferr_id, format, ##__VA_ARGS__)
extern void zlog_thread_info(int log_level);
diff --git a/lib/netns_linux.c b/lib/netns_linux.c
index 61ae45008..b8eaa72c2 100644
--- a/lib/netns_linux.c
+++ b/lib/netns_linux.c
@@ -219,9 +219,9 @@ static int ns_enable_internal(struct ns *ns, void (*func)(ns_id_t, void *))
}
if (!ns_is_enabled(ns)) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Can not enable NS %u: %s!", ns->ns_id,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Can not enable NS %u: %s!", ns->ns_id,
+ safe_strerror(errno));
return 0;
}
diff --git a/lib/pid_output.c b/lib/pid_output.c
index 5132e2f12..c6120de86 100644
--- a/lib/pid_output.c
+++ b/lib/pid_output.c
@@ -42,9 +42,9 @@ pid_t pid_output(const char *path)
oldumask = umask(0777 & ~PIDFILE_MASK);
fd = open(path, O_RDWR | O_CREAT, PIDFILE_MASK);
if (fd < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Can't create pid lock file %s (%s), exiting", path,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Can't create pid lock file %s (%s), exiting",
+ path, safe_strerror(errno));
umask(oldumask);
exit(1);
} else {
@@ -59,23 +59,25 @@ pid_t pid_output(const char *path)
lock.l_whence = SEEK_SET;
if (fcntl(fd, F_SETLK, &lock) < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Could not lock pid_file %s (%s), exiting",
- path, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Could not lock pid_file %s (%s), exiting",
+ path, safe_strerror(errno));
exit(1);
}
sprintf(buf, "%d\n", (int)pid);
pidsize = strlen(buf);
if ((tmp = write(fd, buf, pidsize)) != (int)pidsize)
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Could not write pid %d to pid_file %s, rc was %d: %s",
- (int)pid, path, tmp, safe_strerror(errno));
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "Could not write pid %d to pid_file %s, rc was %d: %s",
+ (int)pid, path, tmp, safe_strerror(errno));
else if (ftruncate(fd, pidsize) < 0)
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Could not truncate pid_file %s to %u bytes: %s",
- path, (unsigned int)pidsize,
- safe_strerror(errno));
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "Could not truncate pid_file %s to %u bytes: %s",
+ path, (unsigned int)pidsize,
+ safe_strerror(errno));
}
return pid;
}
diff --git a/lib/sigevent.c b/lib/sigevent.c
index be904e982..034602793 100644
--- a/lib/sigevent.c
+++ b/lib/sigevent.c
@@ -84,8 +84,8 @@ int quagga_sigevent_process(void)
sigdelset(&newmask, SIGKILL);
if ((sigprocmask(SIG_BLOCK, &newmask, &oldmask)) < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "quagga_signal_timer: couldnt block signals!");
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "quagga_signal_timer: couldnt block signals!");
return -1;
}
#endif /* SIGEVENT_BLOCK_SIGNALS */
diff --git a/lib/sockopt.c b/lib/sockopt.c
index c19e84d12..0edba0618 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -62,9 +62,9 @@ int getsockopt_so_sendbuf(const int sock)
int ret = getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (char *)&optval,
&optlen);
if (ret < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "fd %d: can't getsockopt SO_SNDBUF: %d (%s)", sock,
- errno, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "fd %d: can't getsockopt SO_SNDBUF: %d (%s)", sock,
+ errno, safe_strerror(errno));
return ret;
}
return optval;
@@ -672,9 +672,10 @@ int sockopt_tcp_signature(int sock, union sockunion *su, const char *password)
if (ENOENT == errno)
ret = 0;
else
- flog_err(LIB_ERR_SYSTEM_CALL,
- "sockopt_tcp_signature: setsockopt(%d): %s",
- sock, safe_strerror(errno));
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "sockopt_tcp_signature: setsockopt(%d): %s",
+ sock, safe_strerror(errno));
}
return ret;
#else /* HAVE_TCP_MD5SIG */
diff --git a/lib/vrf.c b/lib/vrf.c
index 8744f6335..9a5414a44 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -545,9 +545,8 @@ int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id,
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0)
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)",
+ __func__, vrf_id, safe_strerror(errno));
if (ret > 0 && interfacename && vrf_default_accepts_vrf(type)) {
zlog_err("VRF socket not used since net.ipv4.%s_l3mdev_accept != 0",
@@ -560,9 +559,9 @@ int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id,
save_errno = errno;
ret2 = vrf_switchback_to_initial();
if (ret2 < 0)
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switchback from VRF %u (%s)", __func__,
- vrf_id, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = save_errno;
if (ret <= 0)
return ret;
@@ -912,16 +911,15 @@ int vrf_getaddrinfo(const char *node, const char *service,
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0)
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)",
+ __func__, vrf_id, safe_strerror(errno));
ret = getaddrinfo(node, service, hints, res);
save_errno = errno;
ret2 = vrf_switchback_to_initial();
if (ret2 < 0)
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switchback from VRF %u (%s)", __func__,
- vrf_id, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = save_errno;
return ret;
}
@@ -932,18 +930,17 @@ int vrf_ioctl(vrf_id_t vrf_id, int d, unsigned long request, char *params)
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)",
+ __func__, vrf_id, safe_strerror(errno));
return 0;
}
rc = ioctl(d, request, params);
saved_errno = errno;
ret = vrf_switchback_to_initial();
if (ret < 0)
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switchback from VRF %u (%s)", __func__,
- vrf_id, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = saved_errno;
return rc;
}
@@ -955,16 +952,15 @@ int vrf_sockunion_socket(const union sockunion *su, vrf_id_t vrf_id,
ret = vrf_switch_to_netns(vrf_id);
if (ret < 0)
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switch to VRF %u (%s)", __func__, vrf_id,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: Can't switch to VRF %u (%s)",
+ __func__, vrf_id, safe_strerror(errno));
ret = sockunion_socket(su);
save_errno = errno;
ret2 = vrf_switchback_to_initial();
if (ret2 < 0)
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't switchback from VRF %u (%s)", __func__,
- vrf_id, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Can't switchback from VRF %u (%s)", __func__,
+ vrf_id, safe_strerror(errno));
errno = save_errno;
if (ret <= 0)
diff --git a/lib/vty.c b/lib/vty.c
index df425aaef..748c14f67 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -1973,8 +1973,8 @@ static void vty_serv_sock_addrinfo(const char *hostname, unsigned short port)
ret = getaddrinfo(hostname, port_str, &req, &ainfo);
if (ret != 0) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "getaddrinfo failed: %s", gai_strerror(ret));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "getaddrinfo failed: %s",
+ gai_strerror(ret));
exit(1);
}
@@ -2034,9 +2034,9 @@ static void vty_serv_un(const char *path)
/* Make UNIX domain socket. */
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
- flog_err(LIB_ERR_SOCKET,
- "Cannot create unix stream socket: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Cannot create unix stream socket: %s",
+ safe_strerror(errno));
return;
}
@@ -2054,18 +2054,16 @@ static void vty_serv_un(const char *path)
ret = bind(sock, (struct sockaddr *)&serv, len);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "Cannot bind path %s: %s",
- path, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Cannot bind path %s: %s", path,
+ safe_strerror(errno));
close(sock); /* Avoid sd leak. */
return;
}
ret = listen(sock, 5);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "listen(fd %d) failed: %s", sock,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "listen(fd %d) failed: %s", sock,
+ safe_strerror(errno));
close(sock); /* Avoid sd leak. */
return;
}
@@ -2080,9 +2078,9 @@ static void vty_serv_un(const char *path)
if ((int)ids.gid_vty > 0) {
/* set group of socket */
if (chown(path, -1, ids.gid_vty)) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "vty_serv_un: could chown socket, %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "vty_serv_un: could chown socket, %s",
+ safe_strerror(errno));
}
}
@@ -2488,9 +2486,10 @@ bool vty_read_config(const char *config_file, char *config_default_dir)
if (config_file != NULL) {
if (!IS_DIRECTORY_SEP(config_file[0])) {
if (getcwd(cwd, MAXPATHLEN) == NULL) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Failure to determine Current Working Directory %d!",
- errno);
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "Failure to determine Current Working Directory %d!",
+ errno);
exit(1);
}
tmp = XMALLOC(MTYPE_TMP,
@@ -3074,14 +3073,14 @@ static void vty_save_cwd(void)
* Hence not worrying about it too much.
*/
if (!chdir(SYSCONFDIR)) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Failure to chdir to %s, errno: %d",
- SYSCONFDIR, errno);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Failure to chdir to %s, errno: %d",
+ SYSCONFDIR, errno);
exit(-1);
}
if (getcwd(cwd, MAXPATHLEN) == NULL) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Failure to getcwd, errno: %d", errno);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Failure to getcwd, errno: %d", errno);
exit(-1);
}
}
diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c
index 8c2b68fe7..bf0387aab 100644
--- a/ospf6d/ospf6_network.c
+++ b/ospf6d/ospf6_network.c
@@ -124,9 +124,10 @@ int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option)
ret = setsockopt(ospf6_sock, IPPROTO_IPV6, option, &mreq6,
sizeof(mreq6));
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "Network: setsockopt (%d) on ifindex %d failed: %s",
- option, ifindex, safe_strerror(errno));
+ flog_err_sys(
+ LIB_ERR_SOCKET,
+ "Network: setsockopt (%d) on ifindex %d failed: %s",
+ option, ifindex, safe_strerror(errno));
return ret;
}
diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c
index c137fc1f6..270f1e3f2 100644
--- a/pimd/pim_igmp.c
+++ b/pimd/pim_igmp.c
@@ -97,9 +97,10 @@ static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp,
}
if (!join) {
- flog_err(LIB_ERR_SOCKET,
- "IGMP socket fd=%d could not join any group on interface address %s",
- fd, inet_ntoa(ifaddr));
+ flog_err_sys(
+ LIB_ERR_SOCKET,
+ "IGMP socket fd=%d could not join any group on interface address %s",
+ fd, inet_ntoa(ifaddr));
close(fd);
fd = -1;
}
diff --git a/pimd/pim_msdp_packet.c b/pimd/pim_msdp_packet.c
index 2b3f45c70..65232aafa 100644
--- a/pimd/pim_msdp_packet.c
+++ b/pimd/pim_msdp_packet.c
@@ -147,8 +147,8 @@ static void pim_msdp_connect_check(struct pim_msdp_peer *mp)
/* If getsockopt is fail, this is fatal error. */
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "can't get sockopt for nonblocking connect");
+ flog_err_sys(LIB_ERR_SOCKET,
+ "can't get sockopt for nonblocking connect");
pim_msdp_peer_reset_tcp_conn(mp, "connect-failed");
return;
}
diff --git a/pimd/pim_msdp_socket.c b/pimd/pim_msdp_socket.c
index 6f334ca75..b0e7b39d7 100644
--- a/pimd/pim_msdp_socket.c
+++ b/pimd/pim_msdp_socket.c
@@ -43,17 +43,18 @@ static void pim_msdp_update_sock_send_buffer_size(int fd)
socklen_t optlen = sizeof(optval);
if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &optval, &optlen) < 0) {
- flog_err(LIB_ERR_SOCKET, "getsockopt of SO_SNDBUF failed %s\n",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "getsockopt of SO_SNDBUF failed %s\n",
+ safe_strerror(errno));
return;
}
if (optval < size) {
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size))
< 0) {
- flog_err(LIB_ERR_SOCKET,
- "Couldn't increase send buffer: %s\n",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Couldn't increase send buffer: %s\n",
+ safe_strerror(errno));
}
}
}
@@ -84,8 +85,8 @@ static int pim_msdp_sock_accept(struct thread *thread)
/* accept client connection. */
msdp_sock = sockunion_accept(accept_sock, &su);
if (msdp_sock < 0) {
- flog_err(LIB_ERR_SOCKET, "pim_msdp_sock_accept failed (%s)",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "pim_msdp_sock_accept failed (%s)",
+ safe_strerror(errno));
return -1;
}
@@ -140,7 +141,8 @@ int pim_msdp_sock_listen(struct pim_instance *pim)
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
- flog_err(LIB_ERR_SOCKET, "socket: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "socket: %s",
+ safe_strerror(errno));
return sock;
}
@@ -166,9 +168,9 @@ int pim_msdp_sock_listen(struct pim_instance *pim)
return -1;
}
if (pim_socket_bind(sock, ifp)) {
- flog_err(LIB_ERR_SOCKET,
- "%s: Unable to bind to socket: %s",
- __PRETTY_FUNCTION__, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Unable to bind to socket: %s",
+ __PRETTY_FUNCTION__, safe_strerror(errno));
close(sock);
return -1;
}
@@ -190,16 +192,17 @@ int pim_msdp_sock_listen(struct pim_instance *pim)
}
if (rc < 0) {
- flog_err(LIB_ERR_SOCKET, "pim_msdp_socket bind to port %d: %s",
- ntohs(sin.sin_port), safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "pim_msdp_socket bind to port %d: %s",
+ ntohs(sin.sin_port), safe_strerror(errno));
close(sock);
return rc;
}
rc = listen(sock, 3 /* backlog */);
if (rc < 0) {
- flog_err(LIB_ERR_SOCKET, "pim_msdp_socket listen: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "pim_msdp_socket listen: %s",
+ safe_strerror(errno));
close(sock);
return rc;
}
@@ -239,8 +242,9 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
/* Make socket for the peer. */
mp->fd = sockunion_socket(&mp->su_peer);
if (mp->fd < 0) {
- flog_err(LIB_ERR_SOCKET, "pim_msdp_socket socket failure: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "pim_msdp_socket socket failure: %s",
+ safe_strerror(errno));
return -1;
}
@@ -254,9 +258,9 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
return -1;
}
if (pim_socket_bind(mp->fd, ifp)) {
- flog_err(LIB_ERR_SOCKET,
- "%s: Unable to bind to socket: %s",
- __PRETTY_FUNCTION__, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Unable to bind to socket: %s",
+ __PRETTY_FUNCTION__, safe_strerror(errno));
close(mp->fd);
mp->fd = -1;
return -1;
@@ -273,9 +277,9 @@ int pim_msdp_sock_connect(struct pim_msdp_peer *mp)
/* source bind */
rc = sockunion_bind(mp->fd, &mp->su_local, 0, &mp->su_local);
if (rc < 0) {
- flog_err(LIB_ERR_SOCKET,
- "pim_msdp_socket connect bind failure: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "pim_msdp_socket connect bind failure: %s",
+ safe_strerror(errno));
close(mp->fd);
mp->fd = -1;
return rc;
diff --git a/pimd/pim_sock.c b/pimd/pim_sock.c
index 2a93b4ad7..976bf3d10 100644
--- a/pimd/pim_sock.c
+++ b/pimd/pim_sock.c
@@ -76,9 +76,9 @@ void pim_socket_ip_hdr(int fd)
__PRETTY_FUNCTION__, safe_strerror(errno));
if (setsockopt(fd, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)))
- flog_err(LIB_ERR_SOCKET,
- "%s: Could not turn on IP_HDRINCL option: %s",
- __PRETTY_FUNCTION__, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Could not turn on IP_HDRINCL option: %s",
+ __PRETTY_FUNCTION__, safe_strerror(errno));
if (pimd_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "%s: could not lower privs, %s",
diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c
index 6e8542793..be30d9c73 100644
--- a/pimd/pim_ssmpingd.c
+++ b/pimd/pim_ssmpingd.c
@@ -83,9 +83,9 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0) {
- flog_err(LIB_ERR_SOCKET,
- "%s: could not create socket: errno=%d: %s",
- __PRETTY_FUNCTION__, errno, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: could not create socket: errno=%d: %s",
+ __PRETTY_FUNCTION__, errno, safe_strerror(errno));
return -1;
}
diff --git a/pimd/pim_time.c b/pimd/pim_time.c
index a15695c9e..029e55116 100644
--- a/pimd/pim_time.c
+++ b/pimd/pim_time.c
@@ -35,9 +35,9 @@ static int gettime_monotonic(struct timeval *tv)
result = gettimeofday(tv, 0);
if (result) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: gettimeofday() failure: errno=%d: %s",
- __PRETTY_FUNCTION__, errno, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: gettimeofday() failure: errno=%d: %s",
+ __PRETTY_FUNCTION__, errno, safe_strerror(errno));
}
return result;
@@ -52,9 +52,9 @@ int64_t pim_time_monotonic_sec()
struct timeval now_tv;
if (gettime_monotonic(&now_tv)) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: gettime_monotonic() failure: errno=%d: %s",
- __PRETTY_FUNCTION__, errno, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: gettime_monotonic() failure: errno=%d: %s",
+ __PRETTY_FUNCTION__, errno, safe_strerror(errno));
return -1;
}
@@ -71,9 +71,9 @@ int64_t pim_time_monotonic_dsec()
int64_t now_dsec;
if (gettime_monotonic(&now_tv)) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: gettime_monotonic() failure: errno=%d: %s",
- __PRETTY_FUNCTION__, errno, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: gettime_monotonic() failure: errno=%d: %s",
+ __PRETTY_FUNCTION__, errno, safe_strerror(errno));
return -1;
}
@@ -89,9 +89,9 @@ int64_t pim_time_monotonic_usec(void)
int64_t now_dsec;
if (gettime_monotonic(&now_tv)) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: gettime_monotonic() failure: errno=%d: %s",
- __PRETTY_FUNCTION__, errno, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: gettime_monotonic() failure: errno=%d: %s",
+ __PRETTY_FUNCTION__, errno, safe_strerror(errno));
return -1;
}
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 68e50d4b0..baa07a8ec 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -345,9 +345,9 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,
return -2;
}
if (ret == 0) {
- flog_err(LIB_ERR_SOCKET,
- "%s: connection closed on zclient lookup socket",
- __PRETTY_FUNCTION__);
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: connection closed on zclient lookup socket",
+ __PRETTY_FUNCTION__);
zclient_lookup_failed(zlookup);
return -3;
}
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 5568ba334..364e23c5e 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -865,9 +865,9 @@ static int rip_interface_wakeup(struct thread *t)
/* Join to multicast group. */
if (rip_multicast_join(ifp, rip->sock) < 0) {
- flog_err(LIB_ERR_SOCKET,
- "multicast join failed, interface %s not running",
- ifp->name);
+ flog_err_sys(LIB_ERR_SOCKET,
+ "multicast join failed, interface %s not running",
+ ifp->name);
return 0;
}
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 2ba11a8ae..274b9540b 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -1341,8 +1341,8 @@ static int rip_create_socket(void)
/* Make datagram socket. */
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock < 0) {
- flog_err(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
+ safe_strerror(errno));
exit(1);
}
@@ -1369,10 +1369,11 @@ static int rip_create_socket(void)
flog_err(LIB_ERR_PRIVILEGES,
"rip_create_socket: could not lower privs");
- flog_err(LIB_ERR_SOCKET,
- "%s: Can't bind socket %d to %s port %d: %s",
- __func__, sock, inet_ntoa(addr.sin_addr),
- (int)ntohs(addr.sin_port), safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s: Can't bind socket %d to %s port %d: %s",
+ __func__, sock, inet_ntoa(addr.sin_addr),
+ (int)ntohs(addr.sin_port),
+ safe_strerror(save_errno));
close(sock);
return ret;
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 5a5123bc2..006389302 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -647,9 +647,9 @@ static int ripng_interface_wakeup(struct thread *t)
/* Join to multicast group. */
if (ripng_multicast_join(ifp) < 0) {
- flog_err(LIB_ERR_SOCKET,
- "multicast join failed, interface %s not running",
- ifp->name);
+ flog_err_sys(LIB_ERR_SOCKET,
+ "multicast join failed, interface %s not running",
+ ifp->name);
return 0;
}
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index e29d6ae5c..80e0047ff 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -95,7 +95,7 @@ static int ripng_make_socket(void)
sock = socket(AF_INET6, SOCK_DGRAM, 0);
if (sock < 0) {
- flog_err(LIB_ERR_SOCKET, "Can't make ripng socket");
+ flog_err_sys(LIB_ERR_SOCKET, "Can't make ripng socket");
return sock;
}
@@ -131,8 +131,8 @@ static int ripng_make_socket(void)
ret = bind(sock, (struct sockaddr *)&ripaddr, sizeof(ripaddr));
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET, "Can't bind ripng socket: %s.",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Can't bind ripng socket: %s.",
+ safe_strerror(errno));
if (ripngd_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES,
"ripng_make_socket: could not lower privs");
@@ -207,13 +207,14 @@ int ripng_send_packet(caddr_t buf, int bufsize, struct sockaddr_in6 *to,
if (ret < 0) {
if (to)
- flog_err(LIB_ERR_SOCKET,
- "RIPng send fail on %s to %s: %s", ifp->name,
- inet6_ntoa(to->sin6_addr),
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "RIPng send fail on %s to %s: %s",
+ ifp->name, inet6_ntoa(to->sin6_addr),
+ safe_strerror(errno));
else
- flog_err(LIB_ERR_SOCKET, "RIPng send fail on %s: %s",
- ifp->name, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "RIPng send fail on %s: %s", ifp->name,
+ safe_strerror(errno));
}
return ret;
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c
index 0e917c397..c6e750597 100644
--- a/watchfrr/watchfrr.c
+++ b/watchfrr/watchfrr.c
@@ -249,9 +249,9 @@ static pid_t run_background(char *shell_cmd)
switch (child = fork()) {
case -1:
- flog_err(LIB_ERR_SYSTEM_CALL,
- "fork failed, cannot run command [%s]: %s", shell_cmd,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "fork failed, cannot run command [%s]: %s",
+ shell_cmd, safe_strerror(errno));
return -1;
case 0:
/* Child process. */
@@ -265,16 +265,16 @@ static pid_t run_background(char *shell_cmd)
char dashc[] = "-c";
char *const argv[4] = {shell, dashc, shell_cmd, NULL};
execv("/bin/sh", argv);
- flog_err(LIB_ERR_SYSTEM_CALL,
- "execv(/bin/sh -c '%s') failed: %s", shell_cmd,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "execv(/bin/sh -c '%s') failed: %s",
+ shell_cmd, safe_strerror(errno));
_exit(127);
}
default:
/* Parent process: we will reap the child later. */
- flog_err(LIB_ERR_SYSTEM_CALL,
- "Forked background command [pid %d]: %s", (int)child,
- shell_cmd);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "Forked background command [pid %d]: %s",
+ (int)child, shell_cmd);
return child;
}
}
@@ -331,8 +331,8 @@ static void sigchild(void)
switch (child = waitpid(-1, &status, WNOHANG)) {
case -1:
- flog_err(LIB_ERR_SYSTEM_CALL,
- "waitpid failed: %s", safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "waitpid failed: %s",
+ safe_strerror(errno));
return;
case 0:
zlog_warn("SIGCHLD received, but waitpid did not reap a child");
@@ -355,9 +355,10 @@ static void sigchild(void)
* completed. */
gettimeofday(&restart->time, NULL);
} else {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "waitpid returned status for an unknown child process %d",
- (int)child);
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "waitpid returned status for an unknown child process %d",
+ (int)child);
name = "(unknown)";
what = "background";
}
@@ -376,9 +377,10 @@ static void sigchild(void)
zlog_debug("%s %s process %d exited normally", what,
name, (int)child);
} else
- flog_err(LIB_ERR_SYSTEM_CALL,
- "cannot interpret %s %s process %d wait status 0x%x",
- what, name, (int)child, status);
+ flog_err_sys(
+ LIB_ERR_SYSTEM_CALL,
+ "cannot interpret %s %s process %d wait status 0x%x",
+ what, name, (int)child, status);
phase_check();
}
@@ -693,24 +695,23 @@ static int try_connect(struct daemon *dmn)
of creating a socket. */
if (access(addr.sun_path, W_OK) < 0) {
if (errno != ENOENT)
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s: access to socket %s denied: %s",
- dmn->name, addr.sun_path,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s: access to socket %s denied: %s",
+ dmn->name, addr.sun_path,
+ safe_strerror(errno));
return -1;
}
if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- flog_err(LIB_ERR_SOCKET,
- "%s(%s): cannot make socket: %s", __func__,
- addr.sun_path, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s(%s): cannot make socket: %s",
+ __func__, addr.sun_path, safe_strerror(errno));
return -1;
}
if (set_nonblocking(sock) < 0 || set_cloexec(sock) < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "%s(%s): set_nonblocking/cloexec(%d) failed",
- __func__, addr.sun_path, sock);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "%s(%s): set_nonblocking/cloexec(%d) failed",
+ __func__, addr.sun_path, sock);
close(sock);
return -1;
}
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index 3e7a87d0a..d17a9cf49 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -176,8 +176,8 @@ static int if_getaddrs(void)
ret = getifaddrs(&ifap);
if (ret != 0) {
- flog_err(LIB_ERR_SYSTEM_CALL, "getifaddrs(): %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "getifaddrs(): %s",
+ safe_strerror(errno));
return -1;
}
diff --git a/zebra/ioctl.c b/zebra/ioctl.c
index 842b96d75..4804d42fd 100644
--- a/zebra/ioctl.c
+++ b/zebra/ioctl.c
@@ -63,8 +63,8 @@ int if_ioctl(unsigned long request, caddr_t buffer)
if (zserv_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
- flog_err(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
+ safe_strerror(save_errno));
exit(1);
}
if ((ret = ioctl(sock, request, buffer)) < 0)
@@ -95,8 +95,8 @@ int vrf_if_ioctl(unsigned long request, caddr_t buffer, vrf_id_t vrf_id)
if (zserv_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
- flog_err(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
+ safe_strerror(save_errno));
exit(1);
}
ret = vrf_ioctl(vrf_id, sock, request, buffer);
@@ -128,9 +128,9 @@ static int if_ioctl_ipv6(unsigned long request, caddr_t buffer)
if (zserv_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
- flog_err(LIB_ERR_SOCKET,
- "Cannot create IPv6 datagram socket: %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Cannot create IPv6 datagram socket: %s",
+ safe_strerror(save_errno));
exit(1);
}
@@ -415,9 +415,9 @@ void if_get_flags(struct interface *ifp)
ret = vrf_if_ioctl(SIOCGIFFLAGS, (caddr_t)&ifreq, ifp->vrf_id);
if (ret < 0) {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "vrf_if_ioctl(SIOCGIFFLAGS) failed: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "vrf_if_ioctl(SIOCGIFFLAGS) failed: %s",
+ safe_strerror(errno));
return;
}
#ifdef HAVE_BSD_LINK_DETECT /* Detect BSD link-state at start-up */
@@ -434,9 +434,9 @@ void if_get_flags(struct interface *ifp)
/* Seems not all interfaces implement this ioctl */
if (if_ioctl(SIOCGIFMEDIA, (caddr_t)&ifmr) < 0)
- flog_err(LIB_ERR_SYSTEM_CALL,
- "if_ioctl(SIOCGIFMEDIA) failed: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "if_ioctl(SIOCGIFMEDIA) failed: %s",
+ safe_strerror(errno));
else if (ifmr.ifm_status & IFM_AVALID) /* Link state is valid */
{
if (ifmr.ifm_status & IFM_ACTIVE)
diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c
index 09e9213cc..1ba37f2db 100644
--- a/zebra/ioctl_solaris.c
+++ b/zebra/ioctl_solaris.c
@@ -66,8 +66,8 @@ int if_ioctl(unsigned long request, caddr_t buffer)
int save_errno = errno;
if (zserv_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
- flog_err(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Cannot create UDP socket: %s",
+ safe_strerror(save_errno));
exit(1);
}
@@ -101,9 +101,9 @@ int if_ioctl_ipv6(unsigned long request, caddr_t buffer)
int save_errno = errno;
if (zserv_privs.change(ZPRIVS_LOWER))
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
- flog_err(LIB_ERR_SOCKET,
- "Cannot create IPv6 datagram socket: %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Cannot create IPv6 datagram socket: %s",
+ safe_strerror(save_errno));
exit(1);
}
diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c
index 43b1fac5f..c44a1fb9c 100644
--- a/zebra/ipforward_solaris.c
+++ b/zebra/ipforward_solaris.c
@@ -70,10 +70,10 @@ static int solaris_nd(const int cmd, const char *parameter, const int value)
else if (cmd == ND_GET)
snprintf(nd_buf, ND_BUFFER_SIZE, "%s", parameter);
else {
- flog_err(LIB_ERR_SYSTEM_CALL,
- "internal error - inappropriate command given to "
- "solaris_nd()%s:%d",
- __FILE__, __LINE__);
+ flog_err_sys(LIB_ERR_SYSTEM_CALL,
+ "internal error - inappropriate command given to "
+ "solaris_nd()%s:%d",
+ __FILE__, __LINE__);
return -1;
}
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index e9f440832..57a7f5273 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -163,9 +163,9 @@ static int netlink_recvbuf(struct nlsock *nl, uint32_t newsize)
ret = getsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF, &oldsize, &oldlen);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "Can't get %s receive buffer size: %s", nl->name,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't get %s receive buffer size: %s", nl->name,
+ safe_strerror(errno));
return -1;
}
@@ -182,17 +182,17 @@ static int netlink_recvbuf(struct nlsock *nl, uint32_t newsize)
ret = setsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF,
&nl_rcvbufsize, sizeof(nl_rcvbufsize));
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "Can't set %s receive buffer size: %s", nl->name,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't set %s receive buffer size: %s", nl->name,
+ safe_strerror(errno));
return -1;
}
ret = getsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF, &newsize, &newlen);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "Can't get %s receive buffer size: %s", nl->name,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't get %s receive buffer size: %s", nl->name,
+ safe_strerror(errno));
return -1;
}
@@ -218,8 +218,8 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
sock = ns_socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE, ns_id);
if (sock < 0) {
- flog_err(LIB_ERR_SOCKET, "Can't open %s socket: %s", nl->name,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Can't open %s socket: %s",
+ nl->name, safe_strerror(errno));
return -1;
}
@@ -234,9 +234,9 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "Can't bind %s socket to group 0x%x: %s", nl->name,
- snl.nl_groups, safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "Can't bind %s socket to group 0x%x: %s", nl->name,
+ snl.nl_groups, safe_strerror(save_errno));
close(sock);
return -1;
}
@@ -245,8 +245,8 @@ static int netlink_socket(struct nlsock *nl, unsigned long groups,
namelen = sizeof snl;
ret = getsockname(sock, (struct sockaddr *)&snl, (socklen_t *)&namelen);
if (ret < 0 || namelen != sizeof snl) {
- flog_err(LIB_ERR_SOCKET, "Can't get %s socket name: %s",
- nl->name, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Can't get %s socket name: %s",
+ nl->name, safe_strerror(errno));
close(sock);
return -1;
}
@@ -720,7 +720,7 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
}
if (status == 0) {
- flog_err(LIB_ERR_SOCKET, "%s EOF", nl->name);
+ flog_err_sys(LIB_ERR_SOCKET, "%s EOF", nl->name);
return -1;
}
@@ -970,8 +970,8 @@ int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
}
if (status < 0) {
- flog_err(LIB_ERR_SOCKET, "netlink_talk sendmsg() error: %s",
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET, "netlink_talk sendmsg() error: %s",
+ safe_strerror(save_errno));
return -1;
}
@@ -994,7 +994,8 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n)
/* Check netlink socket. */
if (nl->sock < 0) {
- flog_err(LIB_ERR_SOCKET, "%s socket isn't active.", nl->name);
+ flog_err_sys(LIB_ERR_SOCKET, "%s socket isn't active.",
+ nl->name);
return -1;
}
@@ -1020,8 +1021,8 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n)
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET, "%s sendto failed: %s", nl->name,
- safe_strerror(save_errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s sendto failed: %s", nl->name,
+ safe_strerror(save_errno));
return -1;
}
@@ -1095,8 +1096,8 @@ void kernel_init(struct zebra_ns *zns)
/* Register kernel socket. */
if (fcntl(zns->netlink.sock, F_SETFL, O_NONBLOCK) < 0)
- flog_err(LIB_ERR_SOCKET, "Can't set %s socket flags: %s",
- zns->netlink.name, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "Can't set %s socket flags: %s",
+ zns->netlink.name, safe_strerror(errno));
if (fcntl(zns->netlink_cmd.sock, F_SETFL, O_NONBLOCK) < 0)
zlog_err("Can't set %s socket error: %s(%d)",
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index c76a0df26..c8c66853a 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -374,10 +374,10 @@ static void rtadv_send_packet(int sock, struct interface *ifp)
ret = sendmsg(sock, &msg, 0);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "%s(%u): Tx RA failed, socket %u error %d (%s)",
- ifp->name, ifp->ifindex, sock, errno,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "%s(%u): Tx RA failed, socket %u error %d (%s)",
+ ifp->name, ifp->ifindex, sock, errno,
+ safe_strerror(errno));
} else
zif->ra_sent++;
}
diff --git a/zebra/zebra_mpls_openbsd.c b/zebra/zebra_mpls_openbsd.c
index 159106313..04c42f1ee 100644
--- a/zebra/zebra_mpls_openbsd.c
+++ b/zebra/zebra_mpls_openbsd.c
@@ -124,8 +124,8 @@ static int kernel_send_rtmsg_v4(int action, mpls_label_t in_label,
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
if (ret == -1)
- flog_err(LIB_ERR_SOCKET, "%s: %s", __func__,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: %s", __func__,
+ safe_strerror(errno));
return ret;
}
@@ -233,8 +233,8 @@ static int kernel_send_rtmsg_v6(int action, mpls_label_t in_label,
flog_err(LIB_ERR_PRIVILEGES, "Can't lower privileges");
if (ret == -1)
- flog_err(LIB_ERR_SOCKET, "%s: %s", __func__,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "%s: %s", __func__,
+ safe_strerror(errno));
return ret;
}
@@ -401,8 +401,8 @@ static int kmpw_install(struct zebra_pw *pw)
strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)&imr;
if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) {
- flog_err(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s",
+ safe_strerror(errno));
return -1;
}
@@ -419,8 +419,8 @@ static int kmpw_uninstall(struct zebra_pw *pw)
strlcpy(ifr.ifr_name, pw->ifname, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)&imr;
if (ioctl(kr_state.ioctl_fd, SIOCSETMPWCFG, &ifr) == -1) {
- flog_err(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s",
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SYSTEM_CALL, "ioctl SIOCSETMPWCFG: %s",
+ safe_strerror(errno));
return -1;
}
diff --git a/zebra/zebra_netns_id.c b/zebra/zebra_netns_id.c
index 119bff0b7..a3278c478 100644
--- a/zebra/zebra_netns_id.c
+++ b/zebra/zebra_netns_id.c
@@ -88,8 +88,8 @@ static int send_receive(int sock, struct nlmsghdr *nlh, unsigned int seq,
ret = sendto(sock, (const void *)nlh, (size_t)nlh->nlmsg_len, 0,
(struct sockaddr *)&snl, (socklen_t)sizeof(snl));
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET, "netlink( %u) sendmsg() error: %s",
- sock, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "netlink( %u) sendmsg() error: %s",
+ sock, safe_strerror(errno));
return -1;
}
@@ -109,8 +109,9 @@ static int send_receive(int sock, struct nlmsghdr *nlh, unsigned int seq,
};
ret = recvmsg(sock, &msg, 0);
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "netlink recvmsg: error %d (errno %u)", ret, errno);
+ flog_err_sys(LIB_ERR_SOCKET,
+ "netlink recvmsg: error %d (errno %u)", ret,
+ errno);
return -1;
}
if (msg.msg_flags & MSG_TRUNC) {
@@ -175,8 +176,8 @@ ns_id_t zebra_ns_id_get(const char *netnspath)
/* netlink socket */
sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (sock < 0) {
- flog_err(LIB_ERR_SOCKET, "netlink( %u) socket() error: %s",
- sock, safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET, "netlink( %u) socket() error: %s",
+ sock, safe_strerror(errno));
close(fd);
return NS_UNKNOWN;
}
@@ -186,9 +187,9 @@ ns_id_t zebra_ns_id_get(const char *netnspath)
snl.nl_pid = 0; /* AUTO PID */
ret = bind(sock, (struct sockaddr *)&snl, sizeof(snl));
if (ret < 0) {
- flog_err(LIB_ERR_SOCKET,
- "netlink( %u) socket() bind error: %s", sock,
- safe_strerror(errno));
+ flog_err_sys(LIB_ERR_SOCKET,
+ "netlink( %u) socket() bind error: %s", sock,
+ safe_strerror(errno));
close(sock);
close(fd);
return NS_UNKNOWN;