]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Add counter of FSM established transitions
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 3 Dec 2019 17:24:01 +0000 (18:24 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 3 Dec 2019 17:24:01 +0000 (18:24 +0100)
The counter is persistent through protocol up/down/restart events.

proto/bgp/bgp.c
proto/bgp/bgp.h

index c2b3bd1899c415b40a40f227523844023860aa23..c3ae2ab1c0100491186743e95eac346d05abfb6c 100644 (file)
@@ -504,6 +504,8 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
   struct bgp_channel *c;
 
   BGP_TRACE(D_EVENTS, "BGP session established");
+  p->last_established = current_time();
+  p->fsm_established_transitions++;
 
   /* For multi-hop BGP sessions */
   if (ipa_zero(p->source_addr))
@@ -616,6 +618,7 @@ static void
 bgp_conn_leave_established_state(struct bgp_proto *p)
 {
   BGP_TRACE(D_EVENTS, "BGP session closed");
+  p->last_established = current_time();
   p->conn = NULL;
 
   if (p->p.proto_state == PS_UP)
@@ -2156,6 +2159,9 @@ bgp_show_proto_info(struct proto *P)
            tm_remains(p->conn->keepalive_timer), p->conn->keepalive_time);
   }
 
+  cli_msg(-1006, "    FSM established transitions: %u",
+         p->fsm_established_transitions);
+
   struct bgp_stats *s = &p->stats;
   cli_msg(-1006, "    Statistics:");
   cli_msg(-1006, "      rx-open %u  rx-update %u  rx-notify %u  rx-keepalive %u  rx-refresh %u",
index 0fcce87833a425f98c3f4b08090775123e94099c..1e89365b98967979266495d5bcbd4cc3b54c13b1 100644 (file)
@@ -267,6 +267,8 @@ struct bgp_proto {
   struct bgp_socket *sock;             /* Shared listening socket */
   struct bfd_request *bfd_req;         /* BFD request, if BFD is used */
   struct bgp_stats stats;              /* Packet statistics */
+  uint fsm_established_transitions;    /* Number of established transitions */
+  btime last_established;              /* Last time of enter/leave of established state */
   ip_addr source_addr;                 /* Local address used as an advertised next hop */
   ip_addr link_addr;                   /* Link-local version of source_addr */
   event *event;                                /* Event for respawning and shutting process */