]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib/zclient: Consolidate error reporting for zclient_read_header
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 17 Sep 2015 14:54:25 +0000 (10:54 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 9 Jun 2016 14:33:27 +0000 (10:33 -0400)
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)

lib/zclient.c
pimd/pim_zlookup.c

index b6d3aa9fed4f625f6a896b23f33844c35c53907e..ef9516c912fc6df81e891550b8b7ff2f3b0a8da1 100644 (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;
 
index aa2f7eb4cf02fcbf295001b104229d28ac240c93..1f8cdfa07e6668623adf5ce4084942020eeaca82 100644 (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);