summaryrefslogtreecommitdiffstats
path: root/lib/sockunion.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-08-20 15:18:15 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-09-06 22:50:58 +0200
commit1b5e2f895a39925cfb6232c67758a0eb8beb4873 (patch)
treecbb67344b1073a4d55394010a82c6a449377b10b /lib/sockunion.c
parentlib: Update zclient.c warn code (diff)
downloadfrr-1b5e2f895a39925cfb6232c67758a0eb8beb4873.tar.xz
frr-1b5e2f895a39925cfb6232c67758a0eb8beb4873.zip
lib: Convert sockunion.c to use flog_err
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/sockunion.c')
-rw-r--r--lib/sockunion.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c
index bbbfbfc42..e1bbbaa0c 100644
--- a/lib/sockunion.c
+++ b/lib/sockunion.c
@@ -140,9 +140,10 @@ int sockunion_socket(const union sockunion *su)
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
if (sock < 0) {
char buf[SU_ADDRSTRLEN];
- zlog_warn("Can't make socket for %s : %s",
- sockunion_log(su, buf, SU_ADDRSTRLEN),
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't make socket for %s : %s",
+ sockunion_log(su, buf, SU_ADDRSTRLEN),
+ safe_strerror(errno));
return -1;
}
@@ -235,7 +236,8 @@ int sockunion_stream_socket(union sockunion *su)
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
if (sock < 0)
- zlog_warn("can't make socket sockunion_stream_socket");
+ flog_err(LIB_ERR_SOCKET,
+ "can't make socket sockunion_stream_socket");
return sock;
}
@@ -273,9 +275,10 @@ int sockunion_bind(int sock, union sockunion *su, unsigned short port,
ret = bind(sock, (struct sockaddr *)su, size);
if (ret < 0) {
char buf[SU_ADDRSTRLEN];
- zlog_warn("can't bind socket for %s : %s",
- sockunion_log(su, buf, SU_ADDRSTRLEN),
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't bind socket for %s : %s",
+ sockunion_log(su, buf, SU_ADDRSTRLEN),
+ safe_strerror(errno));
}
return ret;
@@ -289,7 +292,8 @@ int sockopt_reuseaddr(int sock)
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
sizeof(on));
if (ret < 0) {
- zlog_warn("can't set sockopt SO_REUSEADDR to socket %d", sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt SO_REUSEADDR to socket %d", sock);
return -1;
}
return 0;
@@ -304,7 +308,8 @@ int sockopt_reuseport(int sock)
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void *)&on,
sizeof(on));
if (ret < 0) {
- zlog_warn("can't set sockopt SO_REUSEPORT to socket %d", sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt SO_REUSEPORT to socket %d", sock);
return -1;
}
return 0;
@@ -325,7 +330,8 @@ int sockopt_ttl(int family, int sock, int ttl)
ret = setsockopt(sock, IPPROTO_IP, IP_TTL, (void *)&ttl,
sizeof(int));
if (ret < 0) {
- zlog_warn("can't set sockopt IP_TTL %d to socket %d",
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IP_TTL %d to socket %d",
ttl, sock);
return -1;
}
@@ -336,9 +342,9 @@ int sockopt_ttl(int family, int sock, int ttl)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
(void *)&ttl, sizeof(int));
if (ret < 0) {
- zlog_warn(
- "can't set sockopt IPV6_UNICAST_HOPS %d to socket %d",
- ttl, sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IPV6_UNICAST_HOPS %d to socket %d",
+ ttl, sock);
return -1;
}
return 0;
@@ -383,9 +389,9 @@ int sockopt_minttl(int family, int sock, int minttl)
int ret = setsockopt(sock, IPPROTO_IP, IP_MINTTL, &minttl,
sizeof(minttl));
if (ret < 0)
- zlog_warn(
- "can't set sockopt IP_MINTTL to %d on socket %d: %s",
- minttl, sock, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IP_MINTTL to %d on socket %d: %s",
+ minttl, sock, safe_strerror(errno));
return ret;
}
#endif /* IP_MINTTL */
@@ -394,9 +400,9 @@ int sockopt_minttl(int family, int sock, int minttl)
int ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MINHOPCOUNT,
&minttl, sizeof(minttl));
if (ret < 0)
- zlog_warn(
- "can't set sockopt IPV6_MINHOPCOUNT to %d on socket %d: %s",
- minttl, sock, safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IPV6_MINHOPCOUNT to %d on socket %d: %s",
+ minttl, sock, safe_strerror(errno));
return ret;
}
#endif
@@ -414,10 +420,10 @@ int sockopt_v6only(int family, int sock)
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on,
sizeof(int));
if (ret < 0) {
- zlog_warn(
- "can't set sockopt IPV6_V6ONLY "
- "to socket %d",
- sock);
+ flog_err(LIB_ERR_SOCKET,
+ "can't set sockopt IPV6_V6ONLY "
+ "to socket %d",
+ sock);
return -1;
}
return 0;
@@ -532,8 +538,9 @@ union sockunion *sockunion_getsockname(int fd)
ret = getsockname(fd, (struct sockaddr *)&name, &len);
if (ret < 0) {
- zlog_warn("Can't get local address and port by getsockname: %s",
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't get local address and port by getsockname: %s",
+ safe_strerror(errno));
return NULL;
}
@@ -568,8 +575,9 @@ union sockunion *sockunion_getpeername(int fd)
len = sizeof name;
ret = getpeername(fd, (struct sockaddr *)&name, &len);
if (ret < 0) {
- zlog_warn("Can't get remote address and port: %s",
- safe_strerror(errno));
+ flog_err(LIB_ERR_SOCKET,
+ "Can't get remote address and port: %s",
+ safe_strerror(errno));
return NULL;
}