summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_dump.c2
-rw-r--r--bgpd/bgp_fsm.c16
-rw-r--r--bgpd/bgp_main.c2
-rw-r--r--bgpd/bgp_network.c34
-rw-r--r--bgpd/bgp_route.c2
-rw-r--r--bgpd/bgp_vty.c7
-rw-r--r--bgpd/bgpd.c5
7 files changed, 31 insertions, 37 deletions
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index 4bd48e4e..3bc318a5 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -127,7 +127,7 @@ bgp_dump_open_file (struct bgp_dump *bgp_dump)
if (bgp_dump->fp == NULL)
{
- zlog_warn ("bgp_dump_open_file: %s: %s", realpath, safe_strerror (errno));
+ zlog_warn("bgp_dump_open_file: %s: %s", realpath, errtoa(errno, 0).str);
umask(oldumask);
return NULL;
}
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 87e13ecb..9c323ffd 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -594,7 +594,7 @@ extern void
bgp_fsm_io_fatal_error(bgp_connection connection, int err)
{
plog_err (connection->log, "%s [Error] bgp IO error: %s",
- connection->host, safe_strerror(err)) ;
+ connection->host, errtoa(err, 0).str) ;
assert(err != EFAULT) ;
@@ -639,7 +639,7 @@ bgp_fsm_io_error(bgp_connection connection, int err)
plog_debug(connection->log,
"%s [Event] BGP connection closed fd %d (%s)",
connection->host, qps_file_fd(connection->qf),
- safe_strerror(err)) ;
+ errtoa(err, 0).str) ;
} ;
bgp_fsm_throw(connection, bgp_session_eTCP_dropped, NULL, err,
@@ -1711,21 +1711,19 @@ static bgp_fsm_action(bgp_fsm_accept)
*/
static bgp_fsm_action(bgp_fsm_send_open)
{
- char buf_l[SU_ADDRSTRLEN] ;
- char buf_r[SU_ADDRSTRLEN] ;
- const char* how ;
-
if (BGP_DEBUG (normal, NORMAL))
{
+ const char* how ;
+
if (connection->ordinal == bgp_connection_primary)
how = "connect" ;
else
how = "accept" ;
zlog_debug("%s open %s(), local address %s",
- sockunion2str(connection->su_remote, buf_r, sizeof(buf_r)),
- how,
- sockunion2str(connection->su_local, buf_l, sizeof(buf_l))) ;
+ sutoa(connection->su_remote).str,
+ how,
+ sutoa(connection->su_local).str) ;
} ;
bgp_connection_read_enable(connection) ;
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 32cbf91b..434cfcfb 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -626,7 +626,7 @@ main (int argc, char **argv)
/* Turn into daemon if daemon_mode is set. */
if (daemon_mode && daemon (0, 0) < 0)
{
- zlog_err("BGPd daemon failed: %s", safe_strerror(errno));
+ zlog_err("BGPd daemon failed: %s", errtoa(errno, 0).str);
return (1);
}
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index d969a69b..856447d7 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -222,7 +222,7 @@ bgp_open_listener_on(const char* address, unsigned short port)
ainfo->ai_protocol);
if (sock_fd < 0)
{
- zlog_err ("socket: %s", safe_strerror (errno));
+ zlog_err ("socket: %s", errtoa(errno, 0).str);
continue;
}
@@ -254,7 +254,7 @@ bgp_open_listener_on(const char* address, unsigned short port)
if (address && ((ret = inet_aton(address, &sin.sin_addr)) < 1))
{
zlog_err("bgp_socket: could not parse ip address %s: %s",
- address, safe_strerror (errno));
+ address, errtoa(errno, 0).str);
return ret;
}
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
@@ -264,7 +264,7 @@ bgp_open_listener_on(const char* address, unsigned short port)
sock_fd = socket (AF_INET, SOCK_STREAM, 0);
if (sock_fd < 0)
{
- zlog_err ("socket: %s", safe_strerror (errno));
+ zlog_err ("socket: %s", errtoa(errno, 0).str);
return sock_fd;
}
@@ -355,21 +355,21 @@ bgp_init_listener(int sock_fd, struct sockaddr *sa, socklen_t salen)
if (bgpd_privs.change(ZPRIVS_RAISE))
{
err = errno ;
- zlog_err("%s: could not raise privs: %s", __func__, safe_strerror(errno));
+ zlog_err("%s: could not raise privs: %s", __func__, errtoa(errno, 0).str);
} ;
ret = bind(sock_fd, sa, salen) ;
if (ret < 0)
{
err = errno ;
- zlog_err ("%s: bind: %s", __func__, safe_strerror(err));
+ zlog_err ("%s: bind: %s", __func__, errtoa(err, 0).str);
} ;
if (bgpd_privs.change(ZPRIVS_LOWER))
{
if (err == 0)
err = errno ;
- zlog_err("%s: could not lower privs: %s", __func__, safe_strerror(errno));
+ zlog_err("%s: could not lower privs: %s", __func__, errtoa(errno, 0).str);
} ;
if (err == 0)
@@ -378,7 +378,7 @@ bgp_init_listener(int sock_fd, struct sockaddr *sa, socklen_t salen)
if (ret < 0)
{
err = errno ;
- zlog_err ("%s: listen: %s", __func__, safe_strerror(err)) ;
+ zlog_err ("%s: listen: %s", __func__, errtoa(err, 0).str) ;
}
} ;
@@ -516,7 +516,6 @@ bgp_accept_action(qps_file qf, void* file_info)
int sock_fd ;
int err ;
int family ;
- char buf[SU_ADDRSTRLEN] ;
/* Accept client connection. */
sock_fd = sockunion_accept(qps_file_fd(qf), &su_remote) ;
@@ -524,13 +523,12 @@ bgp_accept_action(qps_file qf, void* file_info)
{
err = errno ;
if (sock_fd == -1)
- zlog_err("[Error] BGP socket accept failed (%s)", safe_strerror(err)) ;
+ zlog_err("[Error] BGP socket accept failed (%s)", errtoa(err, 0).str) ;
return ; /* have no connection to report this to */
} ;
if (BGP_DEBUG(events, EVENTS))
- zlog_debug("[Event] BGP connection from host %s",
- sockunion2str(&su_remote, buf, sizeof(buf))) ;
+ zlog_debug("[Event] BGP connection from host %s", sutoa(&su_remote).str) ;
/* See if we are ready to accept connections from the connecting party */
connection = bgp_peer_index_seek_accept(&su_remote, &exists) ;
@@ -540,7 +538,7 @@ bgp_accept_action(qps_file qf, void* file_info)
zlog_debug(exists
? "[Event] BGP accept IP address %s is not accepting"
: "[Event] BGP accept IP address %s is not configured",
- sockunion2str(&su_remote, buf, sizeof(buf))) ;
+ sutoa(&su_remote).str) ;
close(sock_fd) ;
return ; /* quietly reject connection */
/* TODO: RFC recommends sending a NOTIFICATION when refusing accept() */
@@ -843,7 +841,7 @@ bgp_bind_ifname(bgp_connection connection, int sock_fd)
if (bgpd_privs.change (ZPRIVS_RAISE))
{
err = errno ;
- zlog_err ("bgp_bind: could not raise privs: %s", safe_strerror(errno));
+ zlog_err ("bgp_bind: could not raise privs: %s", errtoa(errno, 0).str);
} ;
ret = setsockopt (sock_fd, SOL_SOCKET, SO_BINDTODEVICE,
@@ -855,13 +853,13 @@ bgp_bind_ifname(bgp_connection connection, int sock_fd)
{
if (err == 0)
err = errno ;
- zlog_err ("bgp_bind: could not lower privs: %s", safe_strerror(errno));
+ zlog_err ("bgp_bind: could not lower privs: %s", errtoa(errno, 0).str);
} ;
if (err != 0)
{
zlog (connection->log, LOG_INFO, "bind to interface %s failed (%s)",
- connection->session->ifname, safe_strerror(err));
+ connection->session->ifname, errtoa(err, 0).str) ;
return err ;
}
#endif /* SO_BINDTODEVICE */
@@ -994,7 +992,7 @@ bgp_md5_set_socket(int sock_fd, union sockunion *su, const char *password)
if (bgpd_privs.change(ZPRIVS_RAISE))
{
err = errno ;
- zlog_err("%s: could not raise privs: %s", __func__, safe_strerror(errno));
+ zlog_err("%s: could not raise privs: %s", __func__, errtoa(errno, 0).str);
} ;
ret = sockopt_tcp_signature(sock_fd, su, password) ;
@@ -1006,12 +1004,12 @@ bgp_md5_set_socket(int sock_fd, union sockunion *su, const char *password)
{
if (err == 0)
err = errno ;
- zlog_err("%s: could not lower privs: %s", __func__, safe_strerror(errno));
+ zlog_err("%s: could not lower privs: %s", __func__, errtoa(errno, 0).str);
} ;
if (err != 0)
zlog (NULL, LOG_WARNING, "cannot set TCP_MD5SIG option on socket %d: %s",
- sock_fd, safe_strerror(err)) ;
+ sock_fd, errtoa(err, 0).str) ;
return err ;
} ;
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 5ca43c72..875ff648 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -6809,7 +6809,7 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
if (! first)
vty_out (vty, " Advertised to non peer-group peers:%s ",
VTY_NEWLINE);
- vty_out (vty, " %s", sockunion2str (&peer->su, buf, sizeof(buf)));
+ vty_out (vty, " %s", sutoa(&peer->su).str);
first = 1;
}
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 5e0374c1..1afc9f94 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -7527,8 +7527,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
if (p->update_if)
vty_out (vty, "%s", p->update_if);
else if (p->update_source)
- vty_out (vty, "%s",
- sockunion2str (p->update_source, buf, sizeof(buf)));
+ vty_out (vty, "%s", sutoa(p->update_source).str);
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -7578,7 +7577,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
if (p->su_local)
{
vty_out (vty, "Local host: %s, Local port: %d%s",
- sockunion2str (p->su_local, buf, sizeof(buf)),
+ sutoa(p->su_local).str,
ntohs (p->su_local->sin.sin_port),
VTY_NEWLINE);
}
@@ -7587,7 +7586,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
if (p->su_remote)
{
vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
- sockunion2str (p->su_remote, buf, sizeof(buf)),
+ sutoa(p->su_remote).str,
ntohs (p->su_remote->sin.sin_port),
VTY_NEWLINE);
}
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index b1ea09dc..1176d2d0 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -4066,7 +4066,6 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
{
struct bgp_filter *filter;
struct peer *g_peer = NULL;
- char buf[SU_ADDRSTRLEN];
char *addr;
filter = &peer->filter[afi][safi];
@@ -4166,8 +4165,8 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
|| sockunion_cmp (g_peer->update_source,
peer->update_source) != 0)
vty_out (vty, " neighbor %s update-source %s%s", addr,
- sockunion2str (peer->update_source, buf, sizeof(buf)),
- VTY_NEWLINE);
+ sutoa(peer->update_source).str,
+ VTY_NEWLINE);
/* advertisement-interval */
if (CHECK_FLAG (peer->config, PEER_CONFIG_ROUTEADV))