From: Donald Sharp Date: Thu, 17 Sep 2015 14:54:25 +0000 (-0400) Subject: lib/zclient: Consolidate error reporting for zclient_read_header X-Git-Tag: frr-2.0-rc1~550^2~8 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=195dd232ebfd62cf6c461612d3ef7fb3d2a23b30;p=matthieu%2Ffrr.git 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 (cherry picked from commit a9d4cb33faa6af622240190a80f41c4672374925) --- diff --git a/lib/zclient.c b/lib/zclient.c index b6d3aa9fed..ef9516c912 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -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; diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index aa2f7eb4cf..1f8cdfa07e 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -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);