+2004-11-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
+
+ * global: Replace strerror with safe_strerror. And vtysh/vtysh.c
+ needs to include "log.h" to pick up the declaration.
+
2004-11-19 Hasso Tepper <hasso at quagga.net>
* configure.ac: Avoid regeneration of doc/quagga.info for now.
bgp_sock = sockunion_accept (accept_sock, &su);
if (bgp_sock < 0)
{
- zlog_err ("[Error] BGP socket accept failed (%s)", strerror (errno));
+ zlog_err ("[Error] BGP socket accept failed (%s)", safe_strerror (errno));
return -1;
}
sock = socket (ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);
if (sock < 0)
{
- zlog_err ("socket: %s", strerror (errno));
+ zlog_err ("socket: %s", safe_strerror (errno));
continue;
}
if (ret < 0)
{
- zlog_err ("bind: %s", strerror (en));
+ zlog_err ("bind: %s", safe_strerror (en));
close(sock);
continue;
}
ret = listen (sock, 3);
if (ret < 0)
{
- zlog_err ("listen: %s", strerror (errno));
+ zlog_err ("listen: %s", safe_strerror (errno));
close (sock);
continue;
}
sock = socket (AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
- zlog_err ("socket: %s", strerror (errno));
+ zlog_err ("socket: %s", safe_strerror (errno));
return sock;
}
if (ret < 0)
{
- zlog_err ("bind: %s", strerror (en));
+ zlog_err ("bind: %s", safe_strerror (en));
close (sock);
return ret;
}
ret = listen (sock, 3);
if (ret < 0)
{
- zlog_err ("listen: %s", strerror (errno));
+ zlog_err ("listen: %s", safe_strerror (errno));
close (sock);
return ret;
}
{
if (BGP_DEBUG (events, EVENTS))
plog_info (peer->log, "%s [Event] Connect failed (%s)",
- peer->host, strerror (errno));
+ peer->host, safe_strerror (errno));
BGP_EVENT_ADD (peer, TCP_connection_open_failed);
}
}
return -1;
plog_err (peer->log, "%s [Error] bgp_read_packet error: %s",
- peer->host, strerror (errno));
+ peer->host, safe_strerror (errno));
BGP_EVENT_ADD (peer, TCP_fatal_error);
return -1;
}
if (setsockopt (fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq,
sizeof (struct packet_mreq)))
{
- zlog_warn ("isis_multicast_join(): setsockopt(): %s", strerror (errno));
+ zlog_warn ("isis_multicast_join(): setsockopt(): %s", safe_strerror (errno));
return ISIS_WARNING;
}
if (fd < 0)
{
zlog_warn ("open_packet_socket(): socket() failed %s",
- strerror (errno));
+ safe_strerror (errno));
return ISIS_WARNING;
}
if (bind (fd, (struct sockaddr *) (&s_addr),
sizeof (struct sockaddr_ll)) < 0)
{
- zlog_warn ("open_packet_socket(): bind() failed: %s", strerror (errno));
+ zlog_warn ("open_packet_socket(): bind() failed: %s", safe_strerror (errno));
return ISIS_WARNING;
}
if (fd < 0)
{
zlog_warn ("open_bpf_dev(): failed to create bpf socket: %s",
- strerror (errno));
+ safe_strerror (errno));
return ISIS_WARNING;
}
if (ioctl (fd, BIOCSETIF, (caddr_t) & ifr) < 0)
{
zlog_warn ("open_bpf_dev(): failed to bind to interface: %s",
- strerror (errno));
+ safe_strerror (errno));
return ISIS_WARNING;
}
if (ioctl (fd, BIOCSETF, (caddr_t) & bpf_prog) < 0)
{
zlog_warn ("open_bpf_dev(): failed to install filter: %s",
- strerror (errno));
+ safe_strerror (errno));
return ISIS_WARNING;
}
int retval = ISIS_OK;
if (isisd_privs.change (ZPRIVS_RAISE))
- zlog_err ("%s: could not raise privs, %s", __func__, strerror (errno));
+ zlog_err ("%s: could not raise privs, %s", __func__, safe_strerror (errno));
#ifdef GNU_LINUX
retval = open_packet_socket (circuit);
end:
if (isisd_privs.change (ZPRIVS_LOWER))
- zlog_err ("%s: could not lower privs, %s", __func__, strerror (errno));
+ zlog_err ("%s: could not lower privs, %s", __func__, safe_strerror (errno));
return retval;
}
if (bytesread < 0)
{
zlog_warn ("isis_recv_packet_bcast(): fd %d, recvfrom (): %s",
- circuit->fd, strerror (errno));
+ circuit->fd, safe_strerror (errno));
zlog_warn ("circuit is %s", circuit->interface->name);
zlog_warn ("circuit fd %d", circuit->fd);
zlog_warn ("bytesread %d", bytesread);
if (ioctl (circuit->fd, FIONREAD, (caddr_t) & bytestoread) < 0)
{
- zlog_warn ("ioctl() FIONREAD failed: %s", strerror (errno));
+ zlog_warn ("ioctl() FIONREAD failed: %s", safe_strerror (errno));
}
if (bytestoread)
if (bytesread < 0)
{
zlog_warn ("isis_recv_pdu_bcast(): read() failed: %s",
- strerror (errno));
+ safe_strerror (errno));
return ISIS_WARNING;
}
ETHER_ADDR_LEN);
if (ioctl (circuit->fd, BIOCFLUSH, &one) < 0)
- zlog_warn ("Flushing failed: %s", strerror (errno));
+ zlog_warn ("Flushing failed: %s", safe_strerror (errno));
return ISIS_OK;
}
if (bytesread < 0)
{
- zlog_warn ("isis_recv_pdu_p2p(): read () failed: %s", strerror (errno));
+ zlog_warn ("isis_recv_pdu_p2p(): read () failed: %s", safe_strerror (errno));
return ISIS_WARNING;
}
if (errno == EINTR)
continue;
- zlog_warn ("select() error: %s", strerror (errno));
+ zlog_warn ("select() error: %s", safe_strerror (errno));
return NULL;
}
vty_sock = sockunion_accept (accept_sock, &su);
if (vty_sock < 0)
{
- zlog_warn ("can't accept vty socket : %s", strerror (errno));
+ zlog_warn ("can't accept vty socket : %s", safe_strerror (errno));
return -1;
}
(char *) &on, sizeof (on));
if (ret < 0)
zlog (NULL, LOG_INFO, "can't set sockopt to vty_sock : %s",
- strerror (errno));
+ safe_strerror (errno));
vty = vty_create (vty_sock, &su);
if (sock < 0)
{
- zlog_warn ("can't accept vty socket : %s", strerror (errno));
+ zlog_warn ("can't accept vty socket : %s", safe_strerror (errno));
return -1;
}
{
if ((errno != EAGAIN) && (errno != EINTR))
zlog_warn("buffer_flush_available write error on fd %d: %s",
- fd,strerror(errno));
+ fd,safe_strerror(errno));
return 1;
}
if (chmod (config_file, CONFIGFILE_MASK) != 0)
{
vty_out (vty, "Can't chmod configuration file %s: %s (%d).%s",
- config_file, strerror(errno), errno, VTY_NEWLINE);
+ config_file, safe_strerror(errno), errno, VTY_NEWLINE);
return CMD_WARNING;
}
zerror (const char *fname, int type, size_t size)
{
zlog_err ("%s : can't allocate memory for `%s' size %d: %s\n",
- fname, lookup (mstr, type), (int) size, strerror(errno));
+ fname, lookup (mstr, type), (int) size, safe_strerror(errno));
log_memstats(LOG_WARNING);
abort();
}
if (fd < 0)
{
zlog_err( "Can't creat pid lock file %s (%s), exit",
- path, strerror(errno));
+ path, safe_strerror(errno));
umask(oldumask);
exit (-1);
}
if ( cap_get_flag (zprivs_state.caps, zprivs_state.syscaps_p[i],
CAP_EFFECTIVE, &val) )
zlog_warn ("zprivs_state_caps: could not cap_get_flag, %s",
- strerror (errno) );
+ safe_strerror (errno) );
if (val == CAP_SET)
return ZPRIVS_RAISED;
}
if ( setgroups (1, &zprivs_state.vtygrp) )
{
fprintf (stderr, "privs_init: could not setgroups, %s\n",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
}
if ( setregid (zprivs_state.zgid, zprivs_state.zgid) )
{
fprintf (stderr, "zprivs_init: could not setregid, %s\n",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
}
if ( prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1 )
{
fprintf (stderr, "privs_init: could not set PR_SET_KEEPCAPS, %s\n",
- strerror (errno) );
+ safe_strerror (errno) );
exit(1);
}
if ( !(zprivs_state.caps = cap_init()) )
{
fprintf (stderr, "privs_init: failed to cap_init, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
if ( setreuid (zprivs_state.zuid, zprivs_state.zuid) )
{
fprintf (stderr, "zprivs_init (cap): could not setreuid, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
}
if ( cap_clear (zprivs_state.caps) )
{
fprintf (stderr, "privs_init: failed to cap_clear, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
if ( setreuid (-1, zprivs_state.zuid) )
{
fprintf (stderr, "privs_init (uid): could not setreuid, %s\n",
- strerror (errno));
+ safe_strerror (errno));
exit (1);
}
}
if ( cap_set_proc (zprivs_state.caps) )
{
zlog_err ("privs_terminate: cap_set_proc failed, %s",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
if ( setreuid (zprivs_state.zuid, zprivs_state.zuid) )
{
zlog_err ("privs_terminate: could not setreuid, %s",
- strerror (errno) );
+ safe_strerror (errno) );
exit (1);
}
}
if (len < 0)
{
- zlog_warn ("Can't read all SMUX packet: %s", strerror (errno));
+ zlog_warn ("Can't read all SMUX packet: %s", safe_strerror (errno));
close (sock);
smux_sock = -1;
smux_event (SMUX_CONNECT, 0);
ret = smux_open (smux_sock);
if (ret < 0)
{
- zlog_warn ("SMUX open message send failed: %s", strerror (errno));
+ zlog_warn ("SMUX open message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
if (++fail < SMUX_MAX_FAILURE)
ret = smux_register (smux_sock);
if (ret < 0)
{
- zlog_warn ("SMUX register message send failed: %s", strerror (errno));
+ zlog_warn ("SMUX register message send failed: %s", safe_strerror (errno));
close (smux_sock);
smux_sock = -1;
if (++fail < SMUX_MAX_FAILURE)
#ifdef IPV6_RECVPKTINFO /*2292bis-01*/
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val));
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_RECVPKTINFO : %s", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_RECVPKTINFO : %s", safe_strerror (errno));
#else /*RFC2292*/
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &val, sizeof(val));
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_PKTINFO : %s", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_PKTINFO : %s", safe_strerror (errno));
#endif /* INIA_IPV6 */
return ret;
}
sock = socket (su->sa.sa_family, SOCK_STREAM, 0);
if (sock < 0)
{
- zlog (NULL, LOG_WARNING, "Can't make socket : %s", strerror (errno));
+ zlog (NULL, LOG_WARNING, "Can't make socket : %s", safe_strerror (errno));
return -1;
}
if (errno != EINPROGRESS)
{
zlog_info ("can't connect to %s fd %d : %s",
- sockunion_log (&su), fd, strerror (errno));
+ sockunion_log (&su), fd, safe_strerror (errno));
return connect_error;
}
}
ret = bind (sock, (struct sockaddr *)su, size);
if (ret < 0)
- zlog (NULL, LOG_WARNING, "can't bind socket : %s", strerror (errno));
+ zlog (NULL, LOG_WARNING, "can't bind socket : %s", safe_strerror (errno));
return ret;
}
if (ret < 0)
{
zlog_warn ("Can't get local address and port by getsockname: %s",
- strerror (errno));
+ safe_strerror (errno));
return NULL;
}
if (ret < 0)
{
zlog (NULL, LOG_WARNING, "Can't get remote address and port: %s",
- strerror (errno));
+ safe_strerror (errno));
return NULL;
}
continue;
}
- zlog_warn ("select() error: %s", strerror (errno));
+ zlog_warn ("select() error: %s", safe_strerror (errno));
return NULL;
}
vty_sock = sockunion_accept (accept_sock, &su);
if (vty_sock < 0)
{
- zlog_warn ("can't accept vty socket : %s", strerror (errno));
+ zlog_warn ("can't accept vty socket : %s", safe_strerror (errno));
return -1;
}
(char *) &on, sizeof (on));
if (ret < 0)
zlog (NULL, LOG_INFO, "can't set sockopt to vty_sock : %s",
- strerror (errno));
+ safe_strerror (errno));
vty = vty_create (vty_sock, &su);
naddr=NULL;
break;
case 0:
- zlog_err("error translating address %s: %s",addr,strerror(errno));
+ zlog_err("error translating address %s: %s",addr,safe_strerror(errno));
naddr=NULL;
}
if ( chown (path, -1, ids.gid_vty) )
{
zlog_err ("vty_serv_un: could chown socket, %s",
- strerror (errno) );
+ safe_strerror (errno) );
}
}
if (sock < 0)
{
- zlog_warn ("can't accept vty socket : %s", strerror (errno));
+ zlog_warn ("can't accept vty socket : %s", safe_strerror (errno));
return -1;
}
|| (fcntl (sock, F_SETFL, flags|O_NONBLOCK) == -1) )
{
zlog_warn ("vtysh_accept: could not set vty socket to non-blocking,"
- " %s, closing", strerror (errno));
+ " %s, closing", safe_strerror (errno));
close (sock);
return -1;
}
if (gettimeofday (&now, (struct timezone *)NULL) < 0)
zlog_warn ("LSA: gettimeofday failed, may fail LSA AGEs: %s",
- strerror (errno));
+ safe_strerror (errno));
lsa->birth.tv_sec = now.tv_sec - ntohs (lsa->header->age);
lsa->birth.tv_usec = now.tv_usec;
/* current time */
if (gettimeofday (&now, (struct timezone *)NULL) < 0)
zlog_warn ("LSA: gettimeofday failed, may fail LSA AGEs: %s",
- strerror (errno));
+ safe_strerror (errno));
/* calculate age */
ulage = now.tv_sec - lsa->birth.tv_sec;
u_int on = 0;
if (setsockopt (ospf6_sock, SOL_SOCKET, SO_REUSEADDR, &on,
sizeof (u_int)) < 0)
- zlog_warn ("Network: set SO_REUSEADDR failed: %s", strerror (errno));
+ zlog_warn ("Network: set SO_REUSEADDR failed: %s", safe_strerror (errno));
}
/* setsockopt MulticastLoop to off */
if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
&off, sizeof (u_int)) < 0)
zlog_warn ("Network: reset IPV6_MULTICAST_LOOP failed: %s",
- strerror (errno));
+ safe_strerror (errno));
}
void
#ifndef DISABLE_IPV6_CHECKSUM
if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_CHECKSUM,
&offset, sizeof (offset)) < 0)
- zlog_warn ("Network: set IPV6_CHECKSUM failed: %s", strerror (errno));
+ zlog_warn ("Network: set IPV6_CHECKSUM failed: %s", safe_strerror (errno));
#else
zlog_warn ("Network: Don't set IPV6_CHECKSUM");
#endif /* DISABLE_IPV6_CHECKSUM */
if (retval < 0)
zlog_err ("Network: Join AllSPFRouters on ifindex %d failed: %s",
- ifindex, strerror (errno));
+ ifindex, safe_strerror (errno));
#if 0
else
zlog_info ("Network: Join AllSPFRouters on ifindex %d", ifindex);
if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
&mreq6, sizeof (mreq6)) < 0)
zlog_warn ("Network: Leave AllSPFRouters on ifindex %d Failed: %s",
- ifindex, strerror (errno));
+ ifindex, safe_strerror (errno));
#if 0
else
zlog_info ("Network: Leave AllSPFRouters on ifindex %d", ifindex);
if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
&mreq6, sizeof (mreq6)) < 0)
zlog_warn ("Network: Join AllDRouters on ifindex %d Failed: %s",
- ifindex, strerror (errno));
+ ifindex, safe_strerror (errno));
#if 0
else
zlog_info ("Network: Join AllDRouters on ifindex %d", ifindex);
retval = sendmsg (ospf6_sock, &smsghdr, 0);
if (retval != iov_totallen (message))
zlog_warn ("sendmsg failed: ifindex: %d: %s (%d)",
- *ifindex, strerror (errno), errno);
+ *ifindex, safe_strerror (errno), errno);
return retval;
}
retval = recvmsg (ospf6_sock, &rmsghdr, 0);
if (retval < 0)
- zlog_warn ("recvmsg failed: %s", strerror (errno));
+ zlog_warn ("recvmsg failed: %s", safe_strerror (errno));
else if (retval == iov_totallen (message))
zlog_warn ("recvmsg read full buffer size: %d", retval);
if (ret < 0)
zlog_err ("zapi_ipv6_route() %s failed: %s",
- (type == REM ? "delete" : "add"), strerror (errno));
+ (type == REM ? "delete" : "add"), safe_strerror (errno));
XFREE (MTYPE_OSPF6_OTHER, nexthops);
XFREE (MTYPE_OSPF6_OTHER, ifindexes);
ret = listen (async_server_sock, BACKLOG);
if (ret < 0)
{
- fprintf (stderr, "ospf_apiclient_connect: listen: %s\n", strerror (errno));
+ fprintf (stderr, "ospf_apiclient_connect: listen: %s\n", safe_strerror (errno));
close (async_server_sock);
return NULL;
}
if (rlen < 0)
{
- zlog_warn ("msg_read: readn %s", strerror (errno));
+ zlog_warn ("msg_read: readn %s", safe_strerror (errno));
return NULL;
}
else if (rlen == 0)
rlen = readn (fd, buf, bodylen);
if (rlen < 0)
{
- zlog_warn ("msg_read: readn %s", strerror (errno));
+ zlog_warn ("msg_read: readn %s", safe_strerror (errno));
return NULL;
}
else if (rlen == 0)
wlen = writen (fd, buf, l);
if (wlen < 0)
{
- zlog_warn ("msg_write: writen %s", strerror (errno));
+ zlog_warn ("msg_write: writen %s", safe_strerror (errno));
return -1;
}
else if (wlen == 0)
if (rc < 0)
{
zlog_warn ("ospf_apiserver_serv_sock_family: listen: %s",
- strerror (errno));
+ safe_strerror (errno));
close (accept_sock); /* Close socket */
return rc;
}
new_sync_sock = sockunion_accept (accept_sock, &su);
if (new_sync_sock < 0)
{
- zlog_warn ("ospf_apiserver_accept: accept: %s", strerror (errno));
+ zlog_warn ("ospf_apiserver_accept: accept: %s", safe_strerror (errno));
return -1;
}
ret = getpeername (new_sync_sock, (struct sockaddr *)&peer_sync, &peerlen);
if (ret < 0)
{
- zlog_warn ("ospf_apiserver_accept: getpeername: %s", strerror (errno));
+ zlog_warn ("ospf_apiserver_accept: getpeername: %s", safe_strerror (errno));
close (new_sync_sock);
return -1;
}
new_async_sock = socket (AF_INET, SOCK_STREAM, 0);
if (new_async_sock < 0)
{
- zlog_warn ("ospf_apiserver_accept: socket: %s", strerror (errno));
+ zlog_warn ("ospf_apiserver_accept: socket: %s", safe_strerror (errno));
close (new_sync_sock);
return -1;
}
if (ret < 0)
{
- zlog_warn ("ospf_apiserver_accept: connect: %s", strerror (errno));
+ zlog_warn ("ospf_apiserver_accept: connect: %s", safe_strerror (errno));
close (new_sync_sock);
close (new_async_sock);
return -1;
ret = shutdown (new_async_sock, SHUT_RD);
if (ret < 0)
{
- zlog_warn ("ospf_apiserver_accept: shutdown: %s", strerror (errno));
+ zlog_warn ("ospf_apiserver_accept: shutdown: %s", safe_strerror (errno));
close (new_sync_sock);
close (new_async_sock);
return -1;
ifindex);
if (ret < 0)
zlog_warn ("can't setsockopt IP_ADD_MEMBERSHIP (AllSPFRouters): %s",
- strerror (errno));
+ safe_strerror (errno));
else
zlog_info ("interface %s join AllSPFRouters Multicast group.",
inet_ntoa (p->u.prefix4));
ifindex);
if (ret < 0)
zlog_warn("can't setsockopt IP_DROP_MEMBERSHIP (AllSPFRouters): %s",
- strerror (errno));
+ safe_strerror (errno));
else
zlog_info ("interface %s leave AllSPFRouters Multicast group.",
inet_ntoa (p->u.prefix4));
ifindex);
if (ret < 0)
zlog_warn ("can't setsockopt IP_ADD_MEMBERSHIP (AllDRouters): %s",
- strerror (errno));
+ safe_strerror (errno));
else
zlog_info ("interface %s join AllDRouters Multicast group.",
inet_ntoa (p->u.prefix4));
ifindex);
if (ret < 0)
zlog_warn ("can't setsockopt IP_DROP_MEMBERSHIP (AllDRouters): %s",
- strerror (errno));
+ safe_strerror (errno));
else
zlog_info ("interface %s leave AllDRouters Multicast group.",
inet_ntoa (p->u.prefix4));
/* Prevent receiving self-origined multicast packets. */
ret = setsockopt (top->fd, IPPROTO_IP, IP_MULTICAST_LOOP, (void *)&val, len);
if (ret < 0)
- zlog_warn ("can't setsockopt IP_MULTICAST_LOOP(0): %s", strerror (errno));
+ zlog_warn ("can't setsockopt IP_MULTICAST_LOOP(0): %s", safe_strerror (errno));
/* Explicitly set multicast ttl to 1 -- endo. */
val = 1;
ret = setsockopt (top->fd, IPPROTO_IP, IP_MULTICAST_TTL, (void *)&val, len);
if (ret < 0)
- zlog_warn ("can't setsockopt IP_MULTICAST_TTL(1): %s", strerror (errno));
+ zlog_warn ("can't setsockopt IP_MULTICAST_TTL(1): %s", safe_strerror (errno));
ret = setsockopt_multicast_ipv4 (top->fd, IP_MULTICAST_IF,
p->u.prefix4, 0, ifindex);
if (ret < 0)
- zlog_warn ("can't setsockopt IP_MULTICAST_IF: %s", strerror (errno));
+ zlog_warn ("can't setsockopt IP_MULTICAST_IF: %s", safe_strerror (errno));
return ret;
}
if ( ospfd_privs.change (ZPRIVS_RAISE) )
zlog_err ("ospf_sock_init: could not raise privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
ospf_sock = socket (AF_INET, SOCK_RAW, IPPROTO_OSPFIGP);
if (ospf_sock < 0)
{
if ( ospfd_privs.change (ZPRIVS_LOWER) )
zlog_err ("ospf_sock_init: could not lower privs, %s",
- strerror (errno) );
- zlog_err ("ospf_read_sock_init: socket: %s", strerror (errno));
+ safe_strerror (errno) );
+ zlog_err ("ospf_read_sock_init: socket: %s", safe_strerror (errno));
exit(-1);
}
{
if ( ospfd_privs.change (ZPRIVS_LOWER) )
zlog_err ("ospf_sock_init: could not lower privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
zlog_warn ("Can't set IP_HDRINCL option");
}
#elif defined (IPTOS_PREC_INTERNETCONTROL)
{
if ( ospfd_privs.change (ZPRIVS_LOWER) )
zlog_err ("ospf_sock_init: could not lower privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
zlog_warn ("can't set sockopt IP_TOS %d to socket %d", tos, ospf_sock);
close (ospf_sock); /* Prevent sd leak. */
return ret;
if (ospfd_privs.change (ZPRIVS_LOWER))
{
zlog_err ("ospf_sock_init: could not lower privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
}
return ospf_sock;
sizeof (struct ospf_opaque_functab))) == NULL)
{
zlog_warn ("ospf_register_opaque_functab: XMALLOC: %s",
- strerror (errno));
+ safe_strerror (errno));
goto out;
}
if ((oipt = XCALLOC (MTYPE_OPAQUE_INFO_PER_TYPE,
sizeof (struct opaque_info_per_type))) == NULL)
{
- zlog_warn ("register_opaque_info_per_type: XMALLOC: %s", strerror (errno));
+ zlog_warn ("register_opaque_info_per_type: XMALLOC: %s", safe_strerror (errno));
goto out;
}
if ((oipi = XCALLOC (MTYPE_OPAQUE_INFO_PER_ID,
sizeof (struct opaque_info_per_id))) == NULL)
{
- zlog_warn ("register_opaque_info_per_id: XMALLOC: %s", strerror (errno));
+ zlog_warn ("register_opaque_info_per_id: XMALLOC: %s", safe_strerror (errno));
goto out;
}
oipi->opaque_id = GET_OPAQUE_ID (ntohl (new->data->id.s_addr));
iph->ip_id,
iph->ip_off,
iph->ip_len,
- strerror (errno));
+ safe_strerror (errno));
if (IS_DEBUG_OSPF_PACKET (type - 1, SEND))
{
if (ret < 0)
zlog_warn ("*** sendmsg in ospf_write to %s failed with %s",
- inet_ntoa (iph.ip_dst), strerror (errno));
+ inet_ntoa (iph.ip_dst), safe_strerror (errno));
/* Show debug sending packet. */
if (IS_DEBUG_OSPF_PACKET (type - 1, SEND))
if ((new = XMALLOC (MTYPE_OSPF_MPLS_TE_LINKPARAMS,
sizeof (struct mpls_te_link))) == NULL)
{
- zlog_warn ("ospf_mpls_te_new_if: XMALLOC: %s", strerror (errno));
+ zlog_warn ("ospf_mpls_te_new_if: XMALLOC: %s", safe_strerror (errno));
goto out;
}
memset (new, 0, sizeof (struct mpls_te_link));
ntohf (&lp->max_bw.value, &f1);
if (sscanf (argv[0], "%g", &f2) != 1)
{
- vty_out (vty, "mpls_te_link_maxbw: fscanf: %s%s", strerror (errno), VTY_NEWLINE);
+ vty_out (vty, "mpls_te_link_maxbw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
return CMD_WARNING;
}
ntohf (&lp->max_rsv_bw.value, &f1);
if (sscanf (argv[0], "%g", &f2) != 1)
{
- vty_out (vty, "mpls_te_link_max_rsv_bw: fscanf: %s%s", strerror (errno), VTY_NEWLINE);
+ vty_out (vty, "mpls_te_link_max_rsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
return CMD_WARNING;
}
/* We don't have to consider about range check here. */
if (sscanf (argv[0], "%d", &priority) != 1)
{
- vty_out (vty, "mpls_te_link_unrsv_bw: fscanf: %s%s", strerror (errno), VTY_NEWLINE);
+ vty_out (vty, "mpls_te_link_unrsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
return CMD_WARNING;
}
ntohf (&lp->unrsv_bw.value [priority], &f1);
if (sscanf (argv[1], "%g", &f2) != 1)
{
- vty_out (vty, "mpls_te_link_unrsv_bw: fscanf: %s%s", strerror (errno), VTY_NEWLINE);
+ vty_out (vty, "mpls_te_link_unrsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
return CMD_WARNING;
}
if (sscanf (argv[0], "0x%lx", &value) != 1)
{
- vty_out (vty, "mpls_te_link_rsc_clsclr: fscanf: %s%s", strerror (errno), VTY_NEWLINE);
+ vty_out (vty, "mpls_te_link_rsc_clsclr: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
return CMD_WARNING;
}
if (ret < 0)
zlog (NULL, LOG_INFO, "can't setsockopt IP_ADD_MEMBERSHIP %s",
- strerror (errno));
+ safe_strerror (errno));
return ret;
}
sock,inet_ntoa(from.sin_addr),
(int)ntohs(from.sin_port),
connected->ifp->name,
- strerror (errno));
+ safe_strerror (errno));
}
if (ripd_privs.change (ZPRIVS_LOWER))
if (send_sock < 0)
{
zlog_warn("rip_send_packet could not create socket %s",
- strerror(errno));
+ safe_strerror(errno));
return -1;
}
sockopt_broadcast (send_sock);
ntohs (sin.sin_port));
if (ret < 0)
- zlog_warn ("can't send packet : %s", strerror (errno));
+ zlog_warn ("can't send packet : %s", safe_strerror (errno));
if (!to)
close(send_sock);
ret = setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &val, sizeof(val));
if (ret < 0)
- zlog_warn ("Can't setsockopt IP_PKTINFO : %s", strerror (errno));
+ zlog_warn ("Can't setsockopt IP_PKTINFO : %s", safe_strerror (errno));
return ret;
}
ret = rip_recvmsg (sock, buf, RIP_PACKET_MAXSIZ, &from, (int *)&ifindex);
if (ret < 0)
{
- zlog_warn ("Can't read RIP packet: %s", strerror (errno));
+ zlog_warn ("Can't read RIP packet: %s", safe_strerror (errno));
return ret;
}
(struct sockaddr *) &from, &fromlen);
if (len < 0)
{
- zlog_info ("recvfrom failed: %s", strerror (errno));
+ zlog_info ("recvfrom failed: %s", safe_strerror (errno));
return len;
}
}
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", safe_strerror (errno));
if (IS_RIPNG_DEBUG_EVENT)
zlog_info ("RIPng %s join to all-rip-routers multicast group", ifp->name);
ret = setsockopt (ripng->sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
(char *) &mreq, sizeof (mreq));
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s\n", safe_strerror (errno));
if (IS_RIPNG_DEBUG_EVENT)
zlog_info ("RIPng %s leave from all-rip-routers multicast group",
ret = bind (sock, (struct sockaddr *) &ripaddr, sizeof (ripaddr));
if (ret < 0)
{
- zlog (NULL, LOG_ERR, "Can't bind ripng socket: %s.", strerror (errno));
+ zlog (NULL, LOG_ERR, "Can't bind ripng socket: %s.", safe_strerror (errno));
if (ripngd_privs.change (ZPRIVS_LOWER))
zlog_err ("ripng_make_socket: could not lower privs");
return ret;
if (ret < 0) {
if (to)
zlog_err ("RIPng send fail on %s to %s: %s", ifp->name,
- inet6_ntop (&to->sin6_addr), strerror (errno));
+ inet6_ntop (&to->sin6_addr), safe_strerror (errno));
else
- zlog_err ("RIPng send fail on %s: %s", ifp->name, strerror (errno));
+ zlog_err ("RIPng send fail on %s: %s", ifp->name, safe_strerror (errno));
}
return ret;
&hoplimit);
if (len < 0)
{
- zlog_warn ("RIPng recvfrom failed: %s.", strerror (errno));
+ zlog_warn ("RIPng recvfrom failed: %s.", safe_strerror (errno));
return len;
}
#include "command.h"
#include "memory.h"
#include "vtysh/vtysh.h"
+#include "log.h"
/* Struct VTY. */
struct vty *vty;
if (chmod (integrate_default, CONFIGFILE_MASK) != 0)
{
fprintf (stdout,"%% Can't chmod configuration file %s: %s (%d)\n",
- integrate_default, strerror(errno), errno);
+ integrate_default, safe_strerror(errno), errno);
return CMD_WARNING;
}
if (pid < 0)
{
/* Failure of fork(). */
- fprintf (stderr, "Can't fork: %s\n", strerror (errno));
+ fprintf (stderr, "Can't fork: %s\n", safe_strerror (errno));
exit (1);
}
else if (pid == 0)
}
/* When execlp suceed, this part is not executed. */
- fprintf (stderr, "Can't execute %s: %s\n", command, strerror (errno));
+ fprintf (stderr, "Can't execute %s: %s\n", command, safe_strerror (errno));
exit (1);
}
else
if (ret < 0 && errno != ENOENT)
{
fprintf (stderr, "vtysh_connect(%s): stat = %s\n",
- path, strerror(errno));
+ path, safe_strerror(errno));
exit(1);
}
{
#ifdef DEBUG
fprintf(stderr, "vtysh_connect(%s): socket = %s\n", path,
- strerror(errno));
+ safe_strerror(errno));
#endif /* DEBUG */
return -1;
}
{
#ifdef DEBUG
fprintf(stderr, "vtysh_connect(%s): connect = %s\n", path,
- strerror(errno));
+ safe_strerror(errno));
#endif /* DEBUG */
close (sock);
return -1;
sock = socket (AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
- zlog_warn ("Can't make AF_INET socket stream: %s", strerror (errno));
+ zlog_warn ("Can't make AF_INET socket stream: %s", safe_strerror (errno));
return -1;
}
if (ret < 0)
{
- zlog_warn ("SIOCGIFCONF: %s", strerror(errno));
+ zlog_warn ("SIOCGIFCONF: %s", safe_strerror(errno));
goto end;
}
/* Repeatedly get info til buffer fails to grow. */
ret = getifaddrs (&ifap);
if (ret != 0)
{
- zlog_err ("getifaddrs(): %s", strerror (errno));
+ zlog_err ("getifaddrs(): %s", safe_strerror (errno));
return -1;
}
{
if (errno != EADDRNOTAVAIL)
{
- zlog_warn ("SIOCGIFADDR fail: %s", strerror (errno));
+ zlog_warn ("SIOCGIFADDR fail: %s", safe_strerror (errno));
return ret;
}
return 0;
{
if (errno != EADDRNOTAVAIL)
{
- zlog_warn ("SIOCGIFNETMASK fail: %s", strerror (errno));
+ zlog_warn ("SIOCGIFNETMASK fail: %s", safe_strerror (errno));
return ret;
}
return 0;
{
if (errno != EADDRNOTAVAIL)
{
- zlog_warn ("SIOCGIFDSTADDR fail: %s", strerror (errno));
+ zlog_warn ("SIOCGIFDSTADDR fail: %s", safe_strerror (errno));
return ret;
}
return 0;
{
if (errno != EADDRNOTAVAIL)
{
- zlog_warn ("SIOCGIFBRDADDR fail: %s", strerror (errno));
+ zlog_warn ("SIOCGIFBRDADDR fail: %s", safe_strerror (errno));
return ret;
}
return 0;
if (sock < 0)
{
zlog_warn ("Can't make %s socket stream: %s",
- (af == AF_INET ? "AF_INET" : "AF_INET6"), strerror (errno));
+ (af == AF_INET ? "AF_INET" : "AF_INET6"), safe_strerror (errno));
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
if (ret < 0)
{
zlog_warn ("interface_list_ioctl: SIOCGLIFNUM failed %s",
- strerror (errno));
+ safe_strerror (errno));
close (sock);
return -1;
}
if (errno == EINVAL)
goto calculate_lifc_len; /* deliberately hold privileges */
- zlog_warn ("SIOCGLIFCONF: %s", strerror (errno));
+ zlog_warn ("SIOCGLIFCONF: %s", safe_strerror (errno));
if (zserv_privs.change(ZPRIVS_LOWER))
zlog (NULL, LOG_ERR, "Can't lower privileges");
if (ret < 0)
{
zlog_warn ("SIOCGLIFDSTADDR (%s) fail: %s",
- ifp->name, strerror (errno));
+ ifp->name, safe_strerror (errno));
return ret;
}
memcpy (&dest, &lifreq.lifr_dstaddr, ADDRLEN (addr));
if (errno != EADDRNOTAVAIL)
{
zlog_warn ("SIOCGLIFNETMASK (%s) fail: %s", ifp->name,
- strerror (errno));
+ safe_strerror (errno));
return ret;
}
return 0;
if (errno != EADDRNOTAVAIL)
{
zlog_warn ("SIOCGLIFBRDADDR (%s) fail: %s",
- ifp->name, strerror (errno));
+ ifp->name, safe_strerror (errno));
return ret;
}
return 0;
if (ret < 0)
{
zlog_warn ("SIOCGLIFSUBNET (%s) fail: %s",
- ifp->name, strerror (errno));
+ ifp->name, safe_strerror (errno));
}
else
{
if (fp == NULL)
{
zlog_warn ("Can't open proc file %s: %s",
- _PATH_PROC_NET_DEV, strerror (errno));
+ _PATH_PROC_NET_DEV, safe_strerror (errno));
return -1;
}
if (fp == NULL)
{
zlog_warn ("Can't open proc file %s: %s",
- _PATH_PROC_NET_DEV, strerror (errno));
+ _PATH_PROC_NET_DEV, safe_strerror (errno));
return -1;
}
if (fp == NULL)
{
zlog_warn ("Can't open proc file %s: %s",
- _PATH_PROC_NET_IF_INET6, strerror (errno));
+ _PATH_PROC_NET_IF_INET6, safe_strerror (errno));
return -1;
}
/* Query buffer size. */
if (sysctl (mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0)
{
- zlog_warn ("sysctl() error by %s", strerror (errno));
+ zlog_warn ("sysctl() error by %s", safe_strerror (errno));
return -1;
}
/* Fetch interface informations into allocated buffer. */
if (sysctl (mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0)
{
- zlog (NULL, LOG_WARNING, "sysctl error by %s", strerror (errno));
+ zlog (NULL, LOG_WARNING, "sysctl error by %s", safe_strerror (errno));
return -1;
}
/* Query buffer size. */
if (sysctl (mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0)
{
- zlog (NULL, LOG_WARNING, "sysctl() error by %s", strerror (errno));
+ zlog (NULL, LOG_WARNING, "sysctl() error by %s", safe_strerror (errno));
return;
}
/* Fetch interface informations into allocated buffer. */
if (sysctl (mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0)
{
- zlog (NULL, LOG_WARNING, "sysctl error by %s", strerror (errno));
+ zlog (NULL, LOG_WARNING, "sysctl error by %s", safe_strerror (errno));
return;
}
if (ret < 0)
{
zlog_warn ("Can't set interface's address: %s",
- strerror(errno));
+ safe_strerror(errno));
continue;
}
if (ret < 0)
{
zlog_warn ("Can't set interface's address: %s",
- strerror(errno));
+ safe_strerror(errno));
continue;
}
SET_FLAG (ifc->conf, ZEBRA_IFC_REAL);
if (ret < 0)
{
vty_out (vty, "%% Can't set interface IP address: %s.%s",
- strerror(errno), VTY_NEWLINE);
+ safe_strerror(errno), VTY_NEWLINE);
return CMD_WARNING;
}
if (ret < 0)
{
vty_out (vty, "%% Can't unset interface IP address: %s.%s",
- strerror(errno), VTY_NEWLINE);
+ safe_strerror(errno), VTY_NEWLINE);
return CMD_WARNING;
}
if (ret < 0)
{
vty_out (vty, "%% Can't set interface IP address: %s.%s",
- strerror(errno), VTY_NEWLINE);
+ safe_strerror(errno), VTY_NEWLINE);
return CMD_WARNING;
}
if (ret < 0)
{
vty_out (vty, "%% Can't unset interface IP address: %s.%s",
- strerror(errno), VTY_NEWLINE);
+ safe_strerror(errno), VTY_NEWLINE);
return CMD_WARNING;
}
if (ret < 0)
zlog_info ("can't set interface flags on %s: %s", ifp->name,
- strerror (errno));
+ safe_strerror (errno));
else
ret = 0;
FILE *fp;
if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno) );
+ zlog_err ("Can't raise privileges, %s", safe_strerror (errno) );
fp = fopen (proc_ipv4_forwarding, "w");
if (fp == NULL) {
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return -1;
}
fclose (fp);
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return ipforward ();
}
FILE *fp;
if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno));
+ zlog_err ("Can't raise privileges, %s", safe_strerror (errno));
fp = fopen (proc_ipv4_forwarding, "w");
if (fp == NULL) {
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return -1;
}
fclose (fp);
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return ipforward ();
}
FILE *fp;
if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno));
+ zlog_err ("Can't raise privileges, %s", safe_strerror (errno));
fp = fopen (proc_ipv6_forwarding, "w");
if (fp == NULL) {
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return -1;
}
fclose (fp);
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return ipforward_ipv6 ();
}
FILE *fp;
if ( zserv_privs.change(ZPRIVS_RAISE) )
- zlog_err ("Can't raise privileges, %s", strerror (errno));
+ zlog_err ("Can't raise privileges, %s", safe_strerror (errno));
fp = fopen (proc_ipv6_forwarding, "w");
if (fp == NULL) {
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return -1;
}
fclose (fp);
if ( zserv_privs.change(ZPRIVS_LOWER) )
- zlog_err ("Can't lower privileges, %s", strerror (errno));
+ zlog_err ("Can't lower privileges, %s", safe_strerror (errno));
return ipforward_ipv6 ();
}
zlog_err ("solaris_nd: Can't raise privileges");
if ((fd = open (device, O_RDWR)) < 0)
{
- zlog_warn("failed to open device %s - %s", device, strerror(errno));
+ zlog_warn("failed to open device %s - %s", device, safe_strerror(errno));
if ( zserv_privs.change (ZPRIVS_LOWER) )
zlog_err ("solaris_nd: Can't lower privileges");
return -1;
if ( zserv_privs.change (ZPRIVS_LOWER) )
zlog_err ("solaris_nd: Can't lower privileges");
close (fd);
- zlog_warn("ioctl I_STR failed on device %s - %s", device,strerror(errno));
+ zlog_warn("ioctl I_STR failed on device %s - %s", device,safe_strerror(errno));
return -1;
}
close(fd);
if (errno)
{
zlog_warn("failed to convert returned value to integer - %s",
- strerror(errno));
+ safe_strerror(errno));
retval = -1;
}
}
zlog_warn ("IRDP: %s can't setsockopt %s: %s",
add_leave == IP_ADD_MEMBERSHIP? "join group":"leave group",
inet_2a(group, b1),
- strerror (errno));
+ safe_strerror (errno));
return ret;
}
if ( zserv_privs.change (ZPRIVS_RAISE) )
zlog_err ("irdp_sock_init: could not raise privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
irdp_sock = socket (AF_INET, SOCK_RAW, IPPROTO_ICMP);
if ( zserv_privs.change (ZPRIVS_LOWER) )
zlog_err ("irdp_sock_init: could not lower privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
if (irdp_sock < 0) {
- zlog_warn ("IRDP: can't create irdp socket %s", strerror(errno));
+ zlog_warn ("IRDP: can't create irdp socket %s", safe_strerror(errno));
return irdp_sock;
};
ret = setsockopt (irdp_sock, IPPROTO_IP, IP_TTL,
(void *) &i, sizeof (i));
if (ret < 0) {
- zlog_warn ("IRDP: can't do irdp sockopt %s", strerror(errno));
+ zlog_warn ("IRDP: can't do irdp sockopt %s", safe_strerror(errno));
return ret;
};
ret = setsockopt_ifindex (AF_INET, irdp_sock, 1);
if (ret < 0) {
- zlog_warn ("IRDP: can't do irdp sockopt %s", strerror(errno));
+ zlog_warn ("IRDP: can't do irdp sockopt %s", safe_strerror(errno));
return ret;
};
ret = recvmsg (sock, &msg, 0);
if (ret < 0) {
- zlog_warn("IRDP: recvmsg: read error %s", strerror(errno));
+ zlog_warn("IRDP: recvmsg: read error %s", safe_strerror(errno));
return ret;
}
on = 1;
if (setsockopt(irdp_sock, IPPROTO_IP, IP_HDRINCL,
(char *) &on, sizeof(on)) < 0)
- zlog_warn("sendto %s", strerror (errno));
+ zlog_warn("sendto %s", safe_strerror (errno));
if(dst == INADDR_BROADCAST ) {
on = 1;
if (setsockopt(irdp_sock, SOL_SOCKET, SO_BROADCAST,
(char *) &on, sizeof(on)) < 0)
- zlog_warn("sendto %s", strerror (errno));
+ zlog_warn("sendto %s", safe_strerror (errno));
}
if(dst != INADDR_BROADCAST) {
on = 0;
if( setsockopt(irdp_sock,IPPROTO_IP, IP_MULTICAST_LOOP,
(char *)&on,sizeof(on)) < 0)
- zlog_warn("sendto %s", strerror (errno));
+ zlog_warn("sendto %s", safe_strerror (errno));
}
bzero(&sockdst,sizeof(sockdst));
sockopt_iphdrincl_swab_htosys (ip);
if (sendmsg(irdp_sock, msg, 0) < 0) {
- zlog_warn("sendto %s", strerror (errno));
+ zlog_warn("sendto %s", safe_strerror (errno));
}
/* printf("TX on %s idx %d\n", ifp->name, ifp->ifindex); */
}
if (errno == ENETUNREACH)
return ZEBRA_ERR_RTUNREACH;
- zlog_warn ("write : %s (%d)", strerror (errno), errno);
+ zlog_warn ("write : %s (%d)", safe_strerror (errno), errno);
return -1;
}
return 0;
if (nbytes <= 0)
{
if (nbytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN)
- zlog_warn ("routing socket error: %s", strerror (errno));
+ zlog_warn ("routing socket error: %s", safe_strerror (errno));
return 0;
}
}
close (sock);
- zlog_warn ("write : %s (%d)", strerror (errno), errno);
+ zlog_warn ("write : %s (%d)", safe_strerror (errno), errno);
return 1;
}
close (sock);
}
close (sock);
- zlog_warn ("write : %s (%d)", strerror (errno), errno);
+ zlog_warn ("write : %s (%d)", safe_strerror (errno), errno);
return ret;
}
close (sock);
if (ret < 0)
{
zlog_warn ("can't %s ipv6 route: %s\n", type == SIOCADDRT ? "add" : "delete",
- strerror(errno));
+ safe_strerror(errno));
ret = errno;
close (sock);
return ret;
{
zlog_warn ("can't %s ipv6 route: %s\n",
cmd == SIOCADDRT ? "add" : "delete",
- strerror(errno));
+ safe_strerror(errno));
ret = errno;
close (sock);
return ret;
if (sock < 0)
{
zlog (NULL, LOG_ERR, "Can't open %s socket: %s", nl->name,
- strerror (errno));
+ safe_strerror (errno));
return -1;
}
if (ret < 0)
{
zlog (NULL, LOG_ERR, "Can't set %s socket flags: %s", nl->name,
- strerror (errno));
+ safe_strerror (errno));
close (sock);
return -1;
}
if (ret < 0)
{
zlog (NULL, LOG_ERR, "Can't get %s receive buffer size: %s", nl->name,
- strerror (errno));
+ safe_strerror (errno));
close (sock);
return -1;
}
if (ret < 0)
{
zlog (NULL, LOG_ERR, "Can't set %s receive buffer size: %s", nl->name,
- strerror (errno));
+ safe_strerror (errno));
close (sock);
return -1;
}
if (ret < 0)
{
zlog (NULL, LOG_ERR, "Can't get %s receive buffer size: %s", nl->name,
- strerror (errno));
+ safe_strerror (errno));
close (sock);
return -1;
}
if (ret < 0)
{
zlog (NULL, LOG_ERR, "Can't bind %s socket to group 0x%x: %s",
- nl->name, snl.nl_groups, strerror (errno));
+ nl->name, snl.nl_groups, safe_strerror (errno));
close (sock);
return -1;
}
if (ret < 0 || namelen != sizeof snl)
{
zlog (NULL, LOG_ERR, "Can't get %s socket name: %s", nl->name,
- strerror (errno));
+ safe_strerror (errno));
close (sock);
return -1;
}
if ((*flags = fcntl (nl->sock, F_GETFL, 0)) < 0)
{
zlog (NULL, LOG_ERR, "%s:%i F_GETFL error: %s",
- __FUNCTION__, __LINE__, strerror (errno));
+ __FUNCTION__, __LINE__, safe_strerror (errno));
return -1;
}
*flags &= ~O_NONBLOCK;
if (fcntl (nl->sock, F_SETFL, *flags) < 0)
{
zlog (NULL, LOG_ERR, "%s:%i F_SETFL error: %s",
- __FUNCTION__, __LINE__, strerror (errno));
+ __FUNCTION__, __LINE__, safe_strerror (errno));
return -1;
}
return 0;
if (fcntl (nl->sock, F_SETFL, *flags) < 0)
{
zlog (NULL, LOG_ERR, "%s:%i F_SETFL error: %s",
- __FUNCTION__, __LINE__, strerror (errno));
+ __FUNCTION__, __LINE__, safe_strerror (errno));
return -1;
}
return 0;
if (ret < 0)
{
zlog (NULL, LOG_ERR, "%s sendto failed: %s", nl->name,
- strerror (errno));
+ safe_strerror (errno));
return -1;
}
zlog (NULL, loglvl, "%s error: %s, type=%s(%u), "
"seq=%u, pid=%d",
- nl->name, strerror (-errnum),
+ nl->name, safe_strerror (-errnum),
lookup (nlmsg_str, msg_type),
msg_type, err->msg.nlmsg_seq, err->msg.nlmsg_pid);
}
if (status < 0)
{
zlog (NULL, LOG_ERR, "netlink_talk sendmsg() error: %s",
- strerror (errno));
+ safe_strerror (errno));
return -1;
}
if (ret < 0)
{
zlog_err ("rtadv_send_packet: sendmsg %d (%s)\n",
- errno, strerror(errno));
+ errno, safe_strerror(errno));
}
}
if (len < 0)
{
- zlog_warn ("router solicitation recv failed: %s.", strerror (errno));
+ zlog_warn ("router solicitation recv failed: %s.", safe_strerror (errno));
return len;
}
if ( zserv_privs.change (ZPRIVS_RAISE) )
zlog_err ("rtadv_make_socket: could not raise privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
sock = socket (AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
if ( zserv_privs.change (ZPRIVS_LOWER) )
zlog_err ("rtadv_make_socket: could not lower privs, %s",
- strerror (errno) );
+ safe_strerror (errno) );
/* When we can't make ICMPV6 socket simply back. Router
advertisement feature will not be supported. */
sizeof (struct icmp6_filter));
if (ret < 0)
{
- zlog_info ("ICMP6_FILTER set fail: %s", strerror (errno));
+ zlog_info ("ICMP6_FILTER set fail: %s", safe_strerror (errno));
return ret;
}
ret = setsockopt (sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
(char *) &mreq, sizeof mreq);
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_JOIN_GROUP: %s", safe_strerror (errno));
zlog_info ("rtadv: %s join to all-routers multicast group", ifp->name);
ret = setsockopt (sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
(char *) &mreq, sizeof mreq);
if (ret < 0)
- zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s", strerror (errno));
+ zlog_warn ("can't setsockopt IPV6_LEAVE_GROUP: %s", safe_strerror (errno));
zlog_info ("rtadv: %s leave from all-routers multicast group", ifp->name);
if ((dev = open (_PATH_GETMSG_ROUTE, O_RDWR)) == -1) {
zlog_warn ("can't open %s: %s", _PATH_GETMSG_ROUTE,
- strerror (errno));
+ safe_strerror (errno));
return;
}
flags = 0;
if (putmsg (dev, &msgdata, NULL, flags) == -1) {
- zlog_warn ("putmsg failed: %s", strerror (errno));
+ zlog_warn ("putmsg failed: %s", safe_strerror (errno));
goto exit;
}
retval = getmsg (dev, &msgdata, NULL, &flags);
if (retval == -1) {
- zlog_warn ("getmsg(ctl) failed: %s", strerror (errno));
+ zlog_warn ("getmsg(ctl) failed: %s", safe_strerror (errno));
goto exit;
}
if (msgdata.len >= sizeof (struct T_error_ack) &&
TLIerr->PRIM_type == T_ERROR_ACK) {
zlog_warn ("getmsg(ctl) returned T_ERROR_ACK: %s",
- strerror ((TLIerr->TLI_error == TSYSERR)
+ safe_strerror ((TLIerr->TLI_error == TSYSERR)
? TLIerr->UNIX_error : EPROTO));
break;
}
if (retval == -1) {
zlog_warn ("getmsg(data) failed: %s",
- strerror (errno));
+ safe_strerror (errno));
goto exit;
}
fp = fopen (_PATH_PROCNET_ROUTE, "r");
if (fp == NULL)
{
- zlog_warn ("Can't open %s : %s\n", _PATH_PROCNET_ROUTE, strerror (errno));
+ zlog_warn ("Can't open %s : %s\n", _PATH_PROCNET_ROUTE, safe_strerror (errno));
return -1;
}
if (fp == NULL)
{
zlog_warn ("Can't open %s : %s", _PATH_PROCNET_ROUTE6,
- strerror (errno));
+ safe_strerror (errno));
return -1;
}
/* Get buffer size. */
if (sysctl (mib, MIBSIZ, NULL, &bufsiz, NULL, 0) < 0)
{
- zlog_warn ("sysctl fail: %s", strerror (errno));
+ zlog_warn ("sysctl fail: %s", safe_strerror (errno));
return -1;
}
/* Read routing table information by calling sysctl(). */
if (sysctl (mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0)
{
- zlog_warn ("sysctl() fail by %s", strerror (errno));
+ zlog_warn ("sysctl() fail by %s", safe_strerror (errno));
return -1;
}
if (client_sock < 0)
{
- zlog_warn ("Can't accept zebra socket: %s", strerror (errno));
+ zlog_warn ("Can't accept zebra socket: %s", safe_strerror (errno));
return -1;
}
if (accept_sock < 0)
{
- zlog_warn ("Can't bind to socket: %s", strerror (errno));
+ zlog_warn ("Can't bind to socket: %s", safe_strerror (errno));
zlog_warn ("zebra can't provice full functionality due to above error");
return;
}
sizeof (struct sockaddr_in));
if (ret < 0)
{
- zlog_warn ("Can't bind to socket: %s", strerror (errno));
+ zlog_warn ("Can't bind to socket: %s", safe_strerror (errno));
zlog_warn ("zebra can't provice full functionality due to above error");
close (accept_sock); /* Avoid sd leak. */
return;
ret = listen (accept_sock, 1);
if (ret < 0)
{
- zlog_warn ("Can't listen to socket: %s", strerror (errno));
+ zlog_warn ("Can't listen to socket: %s", safe_strerror (errno));
zlog_warn ("zebra can't provice full functionality due to above error");
close (accept_sock); /* Avoid sd leak. */
return;