Russ

Author Archives: Russ

snaproute Go BGP Code Dive (6): Starting a Peer

In our last post on BGP code, we unraveled the call chain snaproute’s Go BGP implementation uses to bring a peer up. Let’s look at this call chain a bit more to see if we can figure out what it actually does—or rather, how it actually works. I’m going to skip the actual beginning of the FSM itself, and just move to the first state, looking at how the FSM is designed to move from state to state. The entire thing kicks off here—

func (st *IdleState) processEvent(event BGPFSMEvent, data interface{}) {
st.logger.Info(fmt.Sprintln("Neighbor:", st.fsm.pConf.NeighborAddress, "FSM:", st.fsm.id,
"State: Idle Event:", BGPEventTypeToStr[event]))
switch event {
case BGPEventManualStart, BGPEventAutoStart:
st.fsm.SetConnectRetryCounter(0)
st.fsm.StartConnectRetryTimer()
st.fsm.ChangeState(NewConnectState(st.fsm))
....
}

What we need to do is chase down each of these three calls to figure out what they actually do. The first is simple—it just sets a retry counter (connectRetryCounter) to 0, indicating we haven’t tried to restart this peer at all. In other words, this is the first attempt to move from idle to a full peering relationship. This counter is primarily used for telemetry, which means it’s a counter used to show you, Continue reading

DC Fabric Segment Routing Use Case (2)

In the first post we covered a bit of the basics around segment routing in the data center. Let’s return to the first use case to see if we can figure out how we’d actually implement the type of traffic steering needed to segregate mouse and elephant flows. Let’s return to our fabric and traffic flows and think about how we could shape traffic using segment routing.

benes-segment

There are two obvious ways to shape traffic in this way—

IGP-Prefix segments

The first way would be to impose a label stack that forces traffic along a path that touches, or passes through, each of the devices along the path. In this case, that would mean imposing a path on the traffic originating behind the ToR at A so it must pass through [F,G,D,E]. The flow of traffic through the data center will look something like—

  • Somehow classify the traffic as belonging to the flow that should be shaped to follow only the [F,G,D,E] path
  • Impose the path as a label stack, so the SR header (really just a label stack in this situation, remember?) will contain [F,G,D,E]
  • Forward the packet, with the label, to the next hop in the stack, Continue reading

snaproute Go BGP Code Dive (5): Starting a Peer

Last time we looked at the snaproute BGP code, we discovered the peer bringup process is a finite state machine. With this in mind, let’s try to unravel the state machine into a set of calls, beginning from our original starting point, a debug message that prints on the screen when a new peering relationship is established. The key word in the debug message was ConnEstablished, which led to:

func (fsm *FSM) ConnEstablished() {
fsm.logger.Info(fmt.Sprintln("Neighbor:", fsm.pConf.NeighborAddress, "FSM", fsm.id, "ConnEstablished - start"))
fsm.Manager.fsmEstablished(fsm.id, fsm.peerConn.conn)
fsm.logger.Info(fmt.Sprintln("Neighbor:", fsm.pConf.NeighborAddress, "FSM", fsm.id, "ConnEstablished - end"))
}

From here, we searched for calls to ConnEstablished, and found—

func (fsm *FSM) ChangeState(newState BaseStateIface) {
...
if oldState == BGPFSMEstablished && fsm.State.state() != BGPFSMEstablished {
fsm.ConnBroken()
} else if oldState != BGPFSMEstablished && fsm.State.state() == BGPFSMEstablished {
fsm.ConnEstablished()
}
}

Looking for ChangeState leads us to a lot of different calls, but only one that seems to relate to establishing a new peer, as evidenced by a state that relates to established in some way. This, in turn, leads to—

func (st *OpenConfirmState) processEvent(event BGPFSMEvent, data Continue reading