summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c107
1 files changed, 56 insertions, 51 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index c5a48c178a..340eb0db33 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -221,9 +221,9 @@ int zclient_socket_connect(struct zclient *zclient)
ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);
if (ret < 0) {
if (zclient_debug)
- zlog_warn("%s connect failure: %d(%s)",
- __PRETTY_FUNCTION__, errno,
- safe_strerror(errno));
+ zlog_debug("%s connect failure: %d(%s)",
+ __PRETTY_FUNCTION__, errno,
+ safe_strerror(errno));
close(sock);
return -1;
}
@@ -249,7 +249,8 @@ static int zclient_flush_data(struct thread *thread)
return -1;
switch (buffer_flush_available(zclient->wb, zclient->sock)) {
case BUFFER_ERROR:
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_SOCKET,
"%s: buffer_flush_available failed on zclient fd %d, closing",
__func__, zclient->sock);
return zclient_failed(zclient);
@@ -273,8 +274,9 @@ int zclient_send_message(struct zclient *zclient)
STREAM_DATA(zclient->obuf),
stream_get_endp(zclient->obuf))) {
case BUFFER_ERROR:
- zlog_warn("%s: buffer_write failed to zclient fd %d, closing",
- __func__, zclient->sock);
+ flog_err(LIB_ERR_ZAPI_SOCKET,
+ "%s: buffer_write failed to zclient fd %d, closing",
+ __func__, zclient->sock);
return zclient_failed(zclient);
break;
case BUFFER_EMPTY:
@@ -575,8 +577,8 @@ int zclient_start(struct zclient *zclient)
}
if (set_nonblocking(zclient->sock) < 0)
- zlog_warn("%s: set_nonblocking(%d) failed", __func__,
- zclient->sock);
+ flog_err(LIB_ERR_ZAPI_SOCKET, "%s: set_nonblocking(%d) failed",
+ __func__, zclient->sock);
/* Clear fail count. */
zclient->fail = 0;
@@ -771,9 +773,9 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
char buf[PREFIX2STR_BUFFER];
prefix2str(&api->prefix, buf, sizeof(buf));
- zlog_warn(
- "%s: prefix %s: can't encode %u nexthops "
- "(maximum is %u)",
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
+ "%s: prefix %s: can't encode %u nexthops (maximum is %u)",
__func__, buf, api->nexthop_num, MULTIPATH_NUM);
return -1;
}
@@ -808,11 +810,6 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
16);
stream_putl(s, api_nh->ifindex);
break;
- default:
- zlog_warn(
- "%s: Specified Nexthop type %d does not exist",
- __PRETTY_FUNCTION__, api_nh->type);
- return -1;
}
/* MPLS labels for BGP-LU or Segment Routing */
@@ -871,8 +868,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
/* Type, flags, message. */
STREAM_GETC(s, api->type);
if (api->type > ZEBRA_ROUTE_MAX) {
- zlog_warn("%s: Specified route type: %d is not a legal value\n",
- __PRETTY_FUNCTION__, api->type);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: Specified route type: %d is not a legal value\n",
+ __PRETTY_FUNCTION__, api->type);
return -1;
}
@@ -887,7 +885,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
switch (api->prefix.family) {
case AF_INET:
if (api->prefix.prefixlen > IPV4_MAX_PREFIXLEN) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: V4 prefixlen is %d which should not be more than 32",
__PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1;
@@ -895,15 +894,17 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
break;
case AF_INET6:
if (api->prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: v6 prefixlen is %d which should not be more than 128",
__PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1;
}
break;
default:
- zlog_warn("%s: Specified family %d is not v4 or v6",
- __PRETTY_FUNCTION__, api->prefix.family);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: Specified family %d is not v4 or v6",
+ __PRETTY_FUNCTION__, api->prefix.family);
return -1;
}
STREAM_GET(&api->prefix.u.prefix, s, PSIZE(api->prefix.prefixlen));
@@ -912,7 +913,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
api->src_prefix.family = AF_INET6;
STREAM_GETC(s, api->src_prefix.prefixlen);
if (api->src_prefix.prefixlen > IPV6_MAX_PREFIXLEN) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: SRC Prefix prefixlen received: %d is too large",
__PRETTY_FUNCTION__, api->src_prefix.prefixlen);
return -1;
@@ -922,7 +924,8 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
if (api->prefix.family != AF_INET6
|| api->src_prefix.prefixlen == 0) {
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: SRC prefix specified in some manner that makes no sense",
__PRETTY_FUNCTION__);
return -1;
@@ -933,8 +936,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
STREAM_GETW(s, api->nexthop_num);
if (api->nexthop_num > MULTIPATH_NUM) {
- zlog_warn("%s: invalid number of nexthops (%u)",
- __func__, api->nexthop_num);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: invalid number of nexthops (%u)",
+ __func__, api->nexthop_num);
return -1;
}
@@ -966,11 +970,6 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GET(&api_nh->gate.ipv6, s, 16);
STREAM_GETL(s, api_nh->ifindex);
break;
- default:
- zlog_warn(
- "%s: Specified nexthop type %d does not exist",
- __PRETTY_FUNCTION__, api_nh->type);
- return -1;
}
/* MPLS labels for BGP-LU or Segment Routing */
@@ -978,9 +977,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETC(s, api_nh->label_num);
if (api_nh->label_num > MPLS_MAX_LABELS) {
- zlog_warn(
- "%s: invalid number of MPLS "
- "labels (%u)",
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
+ "%s: invalid number of MPLS labels (%u)",
__func__, api_nh->label_num);
return -1;
}
@@ -1239,8 +1238,9 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
}
STREAM_GETC(s, nhr->nexthops[i].label_num);
if (nhr->nexthops[i].label_num > MPLS_MAX_LABELS) {
- zlog_warn("%s: invalid number of MPLS labels (%u)",
- __func__, nhr->nexthops[i].label_num);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "%s: invalid number of MPLS labels (%u)",
+ __func__, nhr->nexthops[i].label_num);
return false;
}
if (nhr->nexthops[i].label_num)
@@ -1424,8 +1424,9 @@ struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
/* Lookup this by interface index. */
ifp = if_lookup_by_name(ifname_tmp, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_STATE: Cannot find IF %s in VRF %d",
- ifname_tmp, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_STATE: Cannot find IF %s in VRF %d",
+ ifname_tmp, vrf_id);
return NULL;
}
@@ -1633,9 +1634,10 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
/* Lookup index. */
ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d",
- (type == ZEBRA_INTERFACE_ADDRESS_ADD) ? "ADD" : "DEL",
- ifindex, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d",
+ (type == ZEBRA_INTERFACE_ADDRESS_ADD) ? "ADD" : "DEL",
+ ifindex, vrf_id);
return NULL;
}
@@ -1670,9 +1672,9 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
/* carp interfaces on OpenBSD with 0.0.0.0/0 as
* "peer" */
char buf[PREFIX_STRLEN];
- zlog_warn(
- "warning: interface %s address %s "
- "with peer flag set, but no peer address!",
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
+ "warning: interface %s address %s with peer flag set, but no peer address!",
ifp->name,
prefix2str(ifc->address, buf,
sizeof buf));
@@ -1725,10 +1727,11 @@ zebra_interface_nbr_address_read(int type, struct stream *s, vrf_id_t vrf_id)
/* Lookup index. */
ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_NBR_%s: Cannot find IF %u in VRF %d",
- (type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) ? "ADD"
- : "DELETE",
- ifindex, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_NBR_%s: Cannot find IF %u in VRF %d",
+ (type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) ? "ADD"
+ : "DELETE",
+ ifindex, vrf_id);
return NULL;
}
@@ -1774,8 +1777,9 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,
/* Lookup interface. */
ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) {
- zlog_warn("INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
- ifindex, vrf_id);
+ flog_err(LIB_ERR_ZAPI_ENCODE,
+ "INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
+ ifindex, vrf_id);
return NULL;
}
@@ -2410,7 +2414,8 @@ static int zclient_read(struct thread *thread)
/* Length check. */
if (length > STREAM_SIZE(zclient->ibuf)) {
struct stream *ns;
- zlog_warn(
+ flog_err(
+ LIB_ERR_ZAPI_ENCODE,
"%s: message size %u exceeds buffer size %lu, expanding...",
__func__, length,
(unsigned long)STREAM_SIZE(zclient->ibuf));