lib: Update zclient.c warn code

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-08-20 09:13:23 -04:00 committed by Quentin Young
parent 29c7044c63
commit decbd92979
2 changed files with 66 additions and 69 deletions

View File

@ -62,7 +62,7 @@ static struct log_ref ferr_lib_err[] = {
.code = LIB_ERR_ZAPI_ENCODE, .code = LIB_ERR_ZAPI_ENCODE,
.title = "ZAPI Error", .title = "ZAPI Error",
.description = "The ZAPI subsystem has detected an encoding issue, between zebra and a client protocol", .description = "The ZAPI subsystem has detected an encoding issue, between zebra and a client protocol",
.suggestion = "Restart FRR" .suggestion = "Gather data and open an Issue, also Restart FRR"
}, },
{ {
.code = LIB_ERR_ZAPI_SOCKET, .code = LIB_ERR_ZAPI_SOCKET,

View File

@ -221,9 +221,9 @@ int zclient_socket_connect(struct zclient *zclient)
ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len); ret = connect(sock, (struct sockaddr *)&zclient_addr, zclient_addr_len);
if (ret < 0) { if (ret < 0) {
if (zclient_debug) if (zclient_debug)
zlog_warn("%s connect failure: %d(%s)", zlog_debug("%s connect failure: %d(%s)",
__PRETTY_FUNCTION__, errno, __PRETTY_FUNCTION__, errno,
safe_strerror(errno)); safe_strerror(errno));
close(sock); close(sock);
return -1; return -1;
} }
@ -249,9 +249,9 @@ static int zclient_flush_data(struct thread *thread)
return -1; return -1;
switch (buffer_flush_available(zclient->wb, zclient->sock)) { switch (buffer_flush_available(zclient->wb, zclient->sock)) {
case BUFFER_ERROR: case BUFFER_ERROR:
zlog_warn( flog_err(LIB_ERR_ZAPI_SOCKET,
"%s: buffer_flush_available failed on zclient fd %d, closing", "%s: buffer_flush_available failed on zclient fd %d, closing",
__func__, zclient->sock); __func__, zclient->sock);
return zclient_failed(zclient); return zclient_failed(zclient);
break; break;
case BUFFER_PENDING: case BUFFER_PENDING:
@ -273,8 +273,9 @@ int zclient_send_message(struct zclient *zclient)
STREAM_DATA(zclient->obuf), STREAM_DATA(zclient->obuf),
stream_get_endp(zclient->obuf))) { stream_get_endp(zclient->obuf))) {
case BUFFER_ERROR: case BUFFER_ERROR:
zlog_warn("%s: buffer_write failed to zclient fd %d, closing", flog_err(LIB_ERR_ZAPI_SOCKET,
__func__, zclient->sock); "%s: buffer_write failed to zclient fd %d, closing",
__func__, zclient->sock);
return zclient_failed(zclient); return zclient_failed(zclient);
break; break;
case BUFFER_EMPTY: case BUFFER_EMPTY:
@ -575,8 +576,9 @@ int zclient_start(struct zclient *zclient)
} }
if (set_nonblocking(zclient->sock) < 0) if (set_nonblocking(zclient->sock) < 0)
zlog_warn("%s: set_nonblocking(%d) failed", __func__, flog_err(LIB_ERR_ZAPI_SOCKET,
zclient->sock); "%s: set_nonblocking(%d) failed", __func__,
zclient->sock);
/* Clear fail count. */ /* Clear fail count. */
zclient->fail = 0; zclient->fail = 0;
@ -771,10 +773,9 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
char buf[PREFIX2STR_BUFFER]; char buf[PREFIX2STR_BUFFER];
prefix2str(&api->prefix, buf, sizeof(buf)); prefix2str(&api->prefix, buf, sizeof(buf));
zlog_warn( flog_err(LIB_ERR_ZAPI_ENCODE,
"%s: prefix %s: can't encode %u nexthops " "%s: prefix %s: can't encode %u nexthops (maximum is %u)",
"(maximum is %u)", __func__, buf, api->nexthop_num, MULTIPATH_NUM);
__func__, buf, api->nexthop_num, MULTIPATH_NUM);
return -1; return -1;
} }
@ -808,11 +809,6 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
16); 16);
stream_putl(s, api_nh->ifindex); stream_putl(s, api_nh->ifindex);
break; 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 */ /* MPLS labels for BGP-LU or Segment Routing */
@ -871,8 +867,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
/* Type, flags, message. */ /* Type, flags, message. */
STREAM_GETC(s, api->type); STREAM_GETC(s, api->type);
if (api->type > ZEBRA_ROUTE_MAX) { if (api->type > ZEBRA_ROUTE_MAX) {
zlog_warn("%s: Specified route type: %d is not a legal value\n", flog_err(LIB_ERR_ZAPI_ENCODE,
__PRETTY_FUNCTION__, api->type); "%s: Specified route type: %d is not a legal value\n",
__PRETTY_FUNCTION__, api->type);
return -1; return -1;
} }
@ -887,23 +884,24 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
switch (api->prefix.family) { switch (api->prefix.family) {
case AF_INET: case AF_INET:
if (api->prefix.prefixlen > IPV4_MAX_PREFIXLEN) { 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", "%s: V4 prefixlen is %d which should not be more than 32",
__PRETTY_FUNCTION__, api->prefix.prefixlen); __PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1; return -1;
} }
break; break;
case AF_INET6: case AF_INET6:
if (api->prefix.prefixlen > IPV6_MAX_PREFIXLEN) { 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", "%s: v6 prefixlen is %d which should not be more than 128",
__PRETTY_FUNCTION__, api->prefix.prefixlen); __PRETTY_FUNCTION__, api->prefix.prefixlen);
return -1; return -1;
} }
break; break;
default: default:
zlog_warn("%s: Specified family %d is not v4 or v6", flog_err(LIB_ERR_ZAPI_ENCODE,
__PRETTY_FUNCTION__, api->prefix.family); "%s: Specified family %d is not v4 or v6",
__PRETTY_FUNCTION__, api->prefix.family);
return -1; return -1;
} }
STREAM_GET(&api->prefix.u.prefix, s, PSIZE(api->prefix.prefixlen)); STREAM_GET(&api->prefix.u.prefix, s, PSIZE(api->prefix.prefixlen));
@ -912,9 +910,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
api->src_prefix.family = AF_INET6; api->src_prefix.family = AF_INET6;
STREAM_GETC(s, api->src_prefix.prefixlen); STREAM_GETC(s, api->src_prefix.prefixlen);
if (api->src_prefix.prefixlen > IPV6_MAX_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", "%s: SRC Prefix prefixlen received: %d is too large",
__PRETTY_FUNCTION__, api->src_prefix.prefixlen); __PRETTY_FUNCTION__, api->src_prefix.prefixlen);
return -1; return -1;
} }
STREAM_GET(&api->src_prefix.prefix, s, STREAM_GET(&api->src_prefix.prefix, s,
@ -922,9 +920,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
if (api->prefix.family != AF_INET6 if (api->prefix.family != AF_INET6
|| api->src_prefix.prefixlen == 0) { || api->src_prefix.prefixlen == 0) {
zlog_warn( flog_err(LIB_ERR_ZAPI_ENCODE,
"%s: SRC prefix specified in some manner that makes no sense", "%s: SRC prefix specified in some manner that makes no sense",
__PRETTY_FUNCTION__); __PRETTY_FUNCTION__);
return -1; return -1;
} }
} }
@ -933,8 +931,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) { if (CHECK_FLAG(api->message, ZAPI_MESSAGE_NEXTHOP)) {
STREAM_GETW(s, api->nexthop_num); STREAM_GETW(s, api->nexthop_num);
if (api->nexthop_num > MULTIPATH_NUM) { if (api->nexthop_num > MULTIPATH_NUM) {
zlog_warn("%s: invalid number of nexthops (%u)", flog_err(LIB_ERR_ZAPI_ENCODE,
__func__, api->nexthop_num); "%s: invalid number of nexthops (%u)",
__func__, api->nexthop_num);
return -1; return -1;
} }
@ -966,11 +965,6 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GET(&api_nh->gate.ipv6, s, 16); STREAM_GET(&api_nh->gate.ipv6, s, 16);
STREAM_GETL(s, api_nh->ifindex); STREAM_GETL(s, api_nh->ifindex);
break; 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 */ /* MPLS labels for BGP-LU or Segment Routing */
@ -978,10 +972,9 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETC(s, api_nh->label_num); STREAM_GETC(s, api_nh->label_num);
if (api_nh->label_num > MPLS_MAX_LABELS) { if (api_nh->label_num > MPLS_MAX_LABELS) {
zlog_warn( flog_err(LIB_ERR_ZAPI_ENCODE,
"%s: invalid number of MPLS " "%s: invalid number of MPLS labels (%u)",
"labels (%u)", __func__, api_nh->label_num);
__func__, api_nh->label_num);
return -1; return -1;
} }
@ -1239,8 +1232,9 @@ bool zapi_nexthop_update_decode(struct stream *s, struct zapi_route *nhr)
} }
STREAM_GETC(s, nhr->nexthops[i].label_num); STREAM_GETC(s, nhr->nexthops[i].label_num);
if (nhr->nexthops[i].label_num > MPLS_MAX_LABELS) { if (nhr->nexthops[i].label_num > MPLS_MAX_LABELS) {
zlog_warn("%s: invalid number of MPLS labels (%u)", flog_err(LIB_ERR_ZAPI_ENCODE,
__func__, nhr->nexthops[i].label_num); "%s: invalid number of MPLS labels (%u)",
__func__, nhr->nexthops[i].label_num);
return false; return false;
} }
if (nhr->nexthops[i].label_num) if (nhr->nexthops[i].label_num)
@ -1424,8 +1418,9 @@ struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
/* Lookup this by interface index. */ /* Lookup this by interface index. */
ifp = if_lookup_by_name(ifname_tmp, vrf_id); ifp = if_lookup_by_name(ifname_tmp, vrf_id);
if (ifp == NULL) { if (ifp == NULL) {
zlog_warn("INTERFACE_STATE: Cannot find IF %s in VRF %d", flog_err(LIB_ERR_ZAPI_ENCODE,
ifname_tmp, vrf_id); "INTERFACE_STATE: Cannot find IF %s in VRF %d",
ifname_tmp, vrf_id);
return NULL; return NULL;
} }
@ -1633,9 +1628,10 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
/* Lookup index. */ /* Lookup index. */
ifp = if_lookup_by_index(ifindex, vrf_id); ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) { if (ifp == NULL) {
zlog_warn("INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d", flog_err(LIB_ERR_ZAPI_ENCODE,
(type == ZEBRA_INTERFACE_ADDRESS_ADD) ? "ADD" : "DEL", "INTERFACE_ADDRESS_%s: Cannot find IF %u in VRF %d",
ifindex, vrf_id); (type == ZEBRA_INTERFACE_ADDRESS_ADD) ? "ADD" : "DEL",
ifindex, vrf_id);
return NULL; return NULL;
} }
@ -1670,12 +1666,11 @@ struct connected *zebra_interface_address_read(int type, struct stream *s,
/* carp interfaces on OpenBSD with 0.0.0.0/0 as /* carp interfaces on OpenBSD with 0.0.0.0/0 as
* "peer" */ * "peer" */
char buf[PREFIX_STRLEN]; char buf[PREFIX_STRLEN];
zlog_warn( flog_err(LIB_ERR_ZAPI_ENCODE,
"warning: interface %s address %s " "warning: interface %s address %s with peer flag set, but no peer address!",
"with peer flag set, but no peer address!", ifp->name,
ifp->name, prefix2str(ifc->address, buf,
prefix2str(ifc->address, buf, sizeof buf));
sizeof buf));
UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER); UNSET_FLAG(ifc->flags, ZEBRA_IFA_PEER);
} }
} }
@ -1725,9 +1720,10 @@ zebra_interface_nbr_address_read(int type, struct stream *s, vrf_id_t vrf_id)
/* Lookup index. */ /* Lookup index. */
ifp = if_lookup_by_index(ifindex, vrf_id); ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) { if (ifp == NULL) {
zlog_warn("INTERFACE_NBR_%s: Cannot find IF %u in VRF %d", flog_err(LIB_ERR_ZAPI_ENCODE,
(type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) ? "ADD" "INTERFACE_NBR_%s: Cannot find IF %u in VRF %d",
: "DELETE", (type == ZEBRA_INTERFACE_NBR_ADDRESS_ADD) ? "ADD"
: "DELETE",
ifindex, vrf_id); ifindex, vrf_id);
return NULL; return NULL;
} }
@ -1774,8 +1770,9 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,
/* Lookup interface. */ /* Lookup interface. */
ifp = if_lookup_by_index(ifindex, vrf_id); ifp = if_lookup_by_index(ifindex, vrf_id);
if (ifp == NULL) { if (ifp == NULL) {
zlog_warn("INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d", flog_err(LIB_ERR_ZAPI_ENCODE,
ifindex, vrf_id); "INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
ifindex, vrf_id);
return NULL; return NULL;
} }
@ -2410,10 +2407,10 @@ static int zclient_read(struct thread *thread)
/* Length check. */ /* Length check. */
if (length > STREAM_SIZE(zclient->ibuf)) { if (length > STREAM_SIZE(zclient->ibuf)) {
struct stream *ns; struct stream *ns;
zlog_warn( flog_err(LIB_ERR_ZAPI_ENCODE,
"%s: message size %u exceeds buffer size %lu, expanding...", "%s: message size %u exceeds buffer size %lu, expanding...",
__func__, length, __func__, length,
(unsigned long)STREAM_SIZE(zclient->ibuf)); (unsigned long)STREAM_SIZE(zclient->ibuf));
ns = stream_new(length); ns = stream_new(length);
stream_copy(ns, zclient->ibuf); stream_copy(ns, zclient->ibuf);
stream_free(zclient->ibuf); stream_free(zclient->ibuf);