snaproute Go BGP Code Dive (8): Moving to Open
Last week we left off with our BGP peer in connect state after looking through what this code, around line 261 of fsm.go in snaproute’s Go BGP implementation—
func (st *ConnectState) processEvent(event BGPFSMEvent, data interface{}) {
switch event {
....
case BGPEventConnRetryTimerExp:
st.fsm.StopConnToPeer()
st.fsm.StartConnectRetryTimer()
st.fsm.InitiateConnToPeer()
....
What we want to do this week is pick up our BGP peering process, and figure out what the code does next. In this particular case, the next step in the process is fairly simple to find, because it’s just another case in the switch statement in (st *ConnectState) processEvent
—
case BGPEventTcpCrAcked, BGPEventTcpConnConfirmed:
st.fsm.StopConnectRetryTimer()
st.fsm.SetPeerConn(data)
st.fsm.sendOpenMessage()
st.fsm.SetHoldTime(st.fsm.neighborConf.RunningConf.HoldTime,
st.fsm.neighborConf.RunningConf.KeepaliveTime)
st.fsm.StartHoldTimer()
st.BaseState.fsm.ChangeState(NewOpenSentState(st.BaseState.fsm))
....
This looks like the right place—we’re looking at events that occur while in the connect state, and the result seems to be sending an open message. Before we move down this path, however, I’d like to be certain I’m chasing the right call chain, or logical thread. How can I do this? This code is called when (st *ConnectState) processEvent
is called with an event Continue reading