]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Allow command zclient to find it's data
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 1 Jun 2016 01:27:48 +0000 (21:27 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 1 Jun 2016 11:07:04 +0000 (07:07 -0400)
pim has two zclient sockets to zebra.  One
is used exclusively to do mrib lookups.  The
other is to do the normal day to day communication
between pim and zebra.  With the change
to the zebra api to send up all data to all
sockets this caused the mrib lookup socket
to accumulate data in between mrib lookups.
So if at some point in time we get upcoming
data but no mrib lookups modify the code
to find the mrib lookup it is looking for.

Long term we need to figure something else out
but this change will get us moving forward again.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
pimd/pim_zlookup.c

index bec625ab56bbd88cbaec3bdc47bb517fe5be6e6c..aa2f7eb4cf02fcbf295001b104229d28ac240c93 100644 (file)
@@ -154,7 +154,7 @@ static int zclient_read_nexthop(struct zclient *zlookup,
   u_char marker;
   u_char version;
   vrf_id_t vrf_id;
-  uint16_t command;
+  uint16_t command = 0;
   struct in_addr raddr;
   uint8_t distance;
   uint32_t metric;
@@ -170,36 +170,33 @@ static int zclient_read_nexthop(struct zclient *zlookup,
   }
 
   s = zlookup->ibuf;
-  stream_reset(s);
 
-  err = zclient_read_header (s, zlookup->sock, &length, &marker, &version,
-                            &vrf_id, &command);
-  if (err < 0) {
-    zlog_err("%s %s: zclient_read_header() failed",
-            __FILE__, __PRETTY_FUNCTION__);
-    zclient_lookup_failed(zlookup);
-    return -1;
-  }
+  while (command != ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB)
+    {
+      stream_reset(s);
+      err = zclient_read_header (s, zlookup->sock, &length, &marker, &version,
+                                &vrf_id, &command);
+      if (err < 0) {
+       zlog_err("%s %s: zclient_read_header() failed",
+                __FILE__, __PRETTY_FUNCTION__);
+       zclient_lookup_failed(zlookup);
+       return -1;
+      }
 
-  if (length < MIN_LEN) {
-    zlog_err("%s %s: failure reading zclient lookup socket: len=%d < MIN_LEN=%d",
-            __FILE__, __PRETTY_FUNCTION__, length, MIN_LEN);
-    zclient_lookup_failed(zlookup);
-    return -2;
-  }
+      if (length < MIN_LEN) {
+       zlog_err("%s %s: failure reading zclient lookup socket: len=%d < MIN_LEN=%d",
+                __FILE__, __PRETTY_FUNCTION__, length, MIN_LEN);
+       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;
-  }
-    
-  if (command != ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB) {
-    zlog_err("%s: socket %d command mismatch: %d",
-            __func__, zlookup->sock, command);
-    return -5;
-  }
+      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);