0
In last week’s post, we looked at how snaproute’s implementation of BGP in Go moves into trying to connect to a new peer—we chased down the connectRetryTimer to see what it does, but we didn’t fully work through what the code does when actually moving to connect. To jump back into the code, this is where we stopped—
func (st *ConnectState) processEvent(event BGPFSMEvent, data interface{}) {
switch event {
....
case BGPEventConnRetryTimerExp:
st.fsm.StopConnToPeer()
st.fsm.StartConnectRetryTimer()
st.fsm.InitiateConnToPeer()
....
When the connectRetryTimer timer expires, it is not only restarted, but a new connection to the peer is attempted through st.fsm.InitiateConnToPeer(). This, then, is the next stop on the road to figuring out how this implementation of BGP brings up a peer. Before we get there, though, there’s an oddity here that needs to be addressed. If you look through the BGP FSM code, you will only find this call to initiate a connection to a peer in a few places. There is this call, and then one other call, here—
func (st *ConnectState) enter() {
....
st.fsm.AcceptPeerConn()
st.fsm.InitiateConnToPeer()
}
The rest of the instances of InitiateConnToPeer() are related to the definition of the function. Continue reading