lib/zclient: Consolidate error reporting for zclient_read_header

All functions that call zclient_read_header immediately turn around
and check to ensure that the version and marker fields are correct
Move this code into zclient_read_header

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit a9d4cb33faa6af622240190a80f41c4672374925)
This commit is contained in:
Donald Sharp 2015-09-17 10:54:25 -04:00
parent bb882a8651
commit 195dd232eb
2 changed files with 7 additions and 7 deletions

View File

@ -347,6 +347,13 @@ zclient_read_header (struct stream *s, int sock, u_int16_t *size, u_char *marker
*vrf_id = stream_getw (s);
*cmd = stream_getw (s);
if (*version != ZSERV_VERSION || *marker != ZEBRA_HEADER_MARKER)
{
zlog_err("%s: socket %d version mismatch, marker %d, version %d",
__func__, sock, *marker, *version);
return -1;
}
if (*size && stream_read (s, sock, *size) != *size)
return -1;

View File

@ -189,13 +189,6 @@ static int zclient_read_nexthop(struct zclient *zlookup,
zclient_lookup_failed(zlookup);
return -2;
}
if (version != ZSERV_VERSION || marker != ZEBRA_HEADER_MARKER) {
zlog_err("%s: socket %d version mismatch, marker %d, version %d",
__func__, zlookup->sock, marker, version);
zclient_lookup_failed(zlookup);
return -4;
}
}
raddr.s_addr = stream_get_ipv4(s);