mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 05:18:47 +00:00
lib: Convert sockunion.c to use flog_err
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
decbd92979
commit
1b5e2f895a
@ -50,7 +50,7 @@ static struct log_ref ferr_lib_err[] = {
|
|||||||
.code = LIB_ERR_SOCKET,
|
.code = LIB_ERR_SOCKET,
|
||||||
.title = "Socket Error",
|
.title = "Socket Error",
|
||||||
.description = "When attempting to access a socket a system error has occured and we were unable to properly complete the request",
|
.description = "When attempting to access a socket a system error has occured and we were unable to properly complete the request",
|
||||||
.suggestion = "Ensure that there are sufficient system resources available and ensure that the frr user has sufficient permisions to work",
|
.suggestion = "Ensure that there are sufficient system resources available and ensure that the frr user has sufficient permisions to work. If necessary open an Issue",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.code = LIB_ERR_ZAPI_MISSMATCH,
|
.code = LIB_ERR_ZAPI_MISSMATCH,
|
||||||
|
@ -140,7 +140,8 @@ int sockunion_socket(const union sockunion *su)
|
|||||||
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
|
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
|
||||||
if (sock < 0) {
|
if (sock < 0) {
|
||||||
char buf[SU_ADDRSTRLEN];
|
char buf[SU_ADDRSTRLEN];
|
||||||
zlog_warn("Can't make socket for %s : %s",
|
flog_err(LIB_ERR_SOCKET,
|
||||||
|
"Can't make socket for %s : %s",
|
||||||
sockunion_log(su, buf, SU_ADDRSTRLEN),
|
sockunion_log(su, buf, SU_ADDRSTRLEN),
|
||||||
safe_strerror(errno));
|
safe_strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
@ -235,7 +236,8 @@ int sockunion_stream_socket(union sockunion *su)
|
|||||||
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
|
sock = socket(su->sa.sa_family, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (sock < 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;
|
return sock;
|
||||||
}
|
}
|
||||||
@ -273,7 +275,8 @@ int sockunion_bind(int sock, union sockunion *su, unsigned short port,
|
|||||||
ret = bind(sock, (struct sockaddr *)su, size);
|
ret = bind(sock, (struct sockaddr *)su, size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
char buf[SU_ADDRSTRLEN];
|
char buf[SU_ADDRSTRLEN];
|
||||||
zlog_warn("can't bind socket for %s : %s",
|
flog_err(LIB_ERR_SOCKET,
|
||||||
|
"can't bind socket for %s : %s",
|
||||||
sockunion_log(su, buf, SU_ADDRSTRLEN),
|
sockunion_log(su, buf, SU_ADDRSTRLEN),
|
||||||
safe_strerror(errno));
|
safe_strerror(errno));
|
||||||
}
|
}
|
||||||
@ -289,7 +292,8 @@ int sockopt_reuseaddr(int sock)
|
|||||||
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
|
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
|
||||||
sizeof(on));
|
sizeof(on));
|
||||||
if (ret < 0) {
|
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 -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -304,7 +308,8 @@ int sockopt_reuseport(int sock)
|
|||||||
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void *)&on,
|
ret = setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void *)&on,
|
||||||
sizeof(on));
|
sizeof(on));
|
||||||
if (ret < 0) {
|
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 -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -325,7 +330,8 @@ int sockopt_ttl(int family, int sock, int ttl)
|
|||||||
ret = setsockopt(sock, IPPROTO_IP, IP_TTL, (void *)&ttl,
|
ret = setsockopt(sock, IPPROTO_IP, IP_TTL, (void *)&ttl,
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
if (ret < 0) {
|
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);
|
ttl, sock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -336,7 +342,7 @@ int sockopt_ttl(int family, int sock, int ttl)
|
|||||||
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
|
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
|
||||||
(void *)&ttl, sizeof(int));
|
(void *)&ttl, sizeof(int));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
zlog_warn(
|
flog_err(LIB_ERR_SOCKET,
|
||||||
"can't set sockopt IPV6_UNICAST_HOPS %d to socket %d",
|
"can't set sockopt IPV6_UNICAST_HOPS %d to socket %d",
|
||||||
ttl, sock);
|
ttl, sock);
|
||||||
return -1;
|
return -1;
|
||||||
@ -383,7 +389,7 @@ int sockopt_minttl(int family, int sock, int minttl)
|
|||||||
int ret = setsockopt(sock, IPPROTO_IP, IP_MINTTL, &minttl,
|
int ret = setsockopt(sock, IPPROTO_IP, IP_MINTTL, &minttl,
|
||||||
sizeof(minttl));
|
sizeof(minttl));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
zlog_warn(
|
flog_err(LIB_ERR_SOCKET,
|
||||||
"can't set sockopt IP_MINTTL to %d on socket %d: %s",
|
"can't set sockopt IP_MINTTL to %d on socket %d: %s",
|
||||||
minttl, sock, safe_strerror(errno));
|
minttl, sock, safe_strerror(errno));
|
||||||
return ret;
|
return ret;
|
||||||
@ -394,7 +400,7 @@ int sockopt_minttl(int family, int sock, int minttl)
|
|||||||
int ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MINHOPCOUNT,
|
int ret = setsockopt(sock, IPPROTO_IPV6, IPV6_MINHOPCOUNT,
|
||||||
&minttl, sizeof(minttl));
|
&minttl, sizeof(minttl));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
zlog_warn(
|
flog_err(LIB_ERR_SOCKET,
|
||||||
"can't set sockopt IPV6_MINHOPCOUNT to %d on socket %d: %s",
|
"can't set sockopt IPV6_MINHOPCOUNT to %d on socket %d: %s",
|
||||||
minttl, sock, safe_strerror(errno));
|
minttl, sock, safe_strerror(errno));
|
||||||
return ret;
|
return ret;
|
||||||
@ -414,7 +420,7 @@ int sockopt_v6only(int family, int sock)
|
|||||||
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on,
|
ret = setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on,
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
zlog_warn(
|
flog_err(LIB_ERR_SOCKET,
|
||||||
"can't set sockopt IPV6_V6ONLY "
|
"can't set sockopt IPV6_V6ONLY "
|
||||||
"to socket %d",
|
"to socket %d",
|
||||||
sock);
|
sock);
|
||||||
@ -532,7 +538,8 @@ union sockunion *sockunion_getsockname(int fd)
|
|||||||
|
|
||||||
ret = getsockname(fd, (struct sockaddr *)&name, &len);
|
ret = getsockname(fd, (struct sockaddr *)&name, &len);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
zlog_warn("Can't get local address and port by getsockname: %s",
|
flog_err(LIB_ERR_SOCKET,
|
||||||
|
"Can't get local address and port by getsockname: %s",
|
||||||
safe_strerror(errno));
|
safe_strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -568,7 +575,8 @@ union sockunion *sockunion_getpeername(int fd)
|
|||||||
len = sizeof name;
|
len = sizeof name;
|
||||||
ret = getpeername(fd, (struct sockaddr *)&name, &len);
|
ret = getpeername(fd, (struct sockaddr *)&name, &len);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
zlog_warn("Can't get remote address and port: %s",
|
flog_err(LIB_ERR_SOCKET,
|
||||||
|
"Can't get remote address and port: %s",
|
||||||
safe_strerror(errno));
|
safe_strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user