]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
RPKI: improved rpki_get_status()
authorPavel Tvrdík <pawel.tvrdik@gmail.com>
Tue, 27 Oct 2015 16:42:13 +0000 (17:42 +0100)
committerPavel Tvrdík <pawel.tvrdik@gmail.com>
Tue, 27 Oct 2015 16:42:13 +0000 (17:42 +0100)
proto/rpki/rpki.c
proto/rpki/rtrlib-mockup.h

index 2243c7ea146b626e6606747e2c388ca3b0783a35..d353ff90dcf6eadf48dc783affc49211bbd52cd2 100644 (file)
@@ -824,7 +824,9 @@ rpki_get_status(struct proto *P, byte *buf)
 
   uint established_connections = 0;
   uint cache_servers = 0;
+  uint synchronizing = 0;
 
+  pthread_mutex_lock(&p->rtr_conf->mutex);
   for (i = 0; i < p->rtr_conf->len; i++)
   {
     for (j = 0; j < p->rtr_conf->groups[i].sockets_len; j++)
@@ -833,22 +835,27 @@ rpki_get_status(struct proto *P, byte *buf)
       switch (p->rtr_conf->groups[i].sockets[j]->state)
       {
        case RTR_ESTABLISHED:
+         established_connections++;
+         break;
        case RTR_RESET:
        case RTR_SYNC:
-         established_connections++;
+       case RTR_FAST_RECONNECT:
+       case RTR_CONNECTING:
+         synchronizing++;
          break;
       }
     }
   }
+  pthread_mutex_unlock(&p->rtr_conf->mutex);
 
-  if (established_connections == 1)
-    bsprintf(buf, "Keep synchronized with 1 cache server");
-  else if (established_connections > 1)
-    bsprintf(buf, "Keep synchronized with %u cache servers", established_connections);
+  if (established_connections > 0)
+    bsprintf(buf, "Keep synchronized with %u cache server%s", established_connections, (established_connections > 1) ? "s" : "");
+  else if (synchronizing > 0)
+    bsprintf(buf, "Synchronizing with %u cache server%s", synchronizing, (synchronizing > 1) ? "s" : "");
   else if (cache_servers == 0)
     bsprintf(buf, "No cache server is configured");
   else if (cache_servers == 1)
-    bsprintf(buf, "Cannot connect to cache server");
+    bsprintf(buf, "Cannot connect to cache server");
   else
     bsprintf(buf, "Cannot connect to any cache servers");
 }
index 88c7dbcac341b8bee6a93be74a1d6a81f6aba213..9998cb21ca5664fb1ab21b6b8654b5f5bb1b9b82 100644 (file)
@@ -195,10 +195,11 @@ struct rtr_mgr_group {
 struct rtr_mgr_config {
     struct rtr_mgr_group *groups;
     unsigned int len;
-    /* some items deleted for mockuping */
+    pthread_mutex_t mutex;
+    void *status_fp; /* voided for mockuping */
+    void *status_fp_data;
 };
 
-
 /**
  * @brief Version of the IP protocol.
  */