bgpd: consolidate start timer backoff via a 'BGP_Stop_with_error' FSM event
* Exponential increase/back-off on the peer start timer is replicated in
a few places. Consolidate by adding a "BGP_Stop_with_error" event
so places outside FSM can just raise that event.
* bgpd.h: Add BGP_Stop_with_error
* bgp_fsm.c: (bgp_event_str[]) Add text for BGP_Stop_with_error.
FSM table: Handle BGP_Stop_with_error, identical to bgp_stop
in nearly all cases.
* bgp_packet.c: (bgp_write,bgp_write_notify) can just raise new event now.
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index f42e544..51b006a 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -766,15 +766,9 @@
break;
case BGP_MSG_NOTIFY:
peer->notify_out++;
- /* Double start timer. */
- peer->v_start *= 2;
-
- /* Overflow check. */
- if (peer->v_start >= (60 * 2))
- peer->v_start = (60 * 2);
/* Flush any existing events */
- BGP_EVENT_ADD (peer, BGP_Stop);
+ BGP_EVENT_ADD (peer, BGP_Stop_with_error);
goto done;
case BGP_MSG_KEEPALIVE:
@@ -846,14 +840,7 @@
/* Type should be notify. */
peer->notify_out++;
- /* Double start timer. */
- peer->v_start *= 2;
-
- /* Overflow check. */
- if (peer->v_start >= (60 * 2))
- peer->v_start = (60 * 2);
-
- BGP_EVENT_ADD (peer, BGP_Stop);
+ BGP_EVENT_ADD (peer, BGP_Stop_with_error);
return 0;
}