Skip to content
Snippets Groups Projects
Commit 2c04f298 authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

preperations to split options

parent 6ad74e74
No related branches found
No related tags found
No related merge requests found
......@@ -113,6 +113,21 @@ func newFSM2(peer *peer) *FSM {
return f
}
func (fsm *FSM) addressFamily(afi uint16, safi uint8) *fsmAddressFamily {
if safi != packet.UnicastSAFI {
return nil
}
switch afi {
case packet.IPv4AFI:
return fsm.ipv4Unicast
case packet.IPv6AFI:
return fsm.ipv6Unicast
default:
return nil
}
}
func (fsm *FSM) start() {
ctx, cancel := context.WithCancel(context.Background())
fsm.connectionCancelFunc = cancel
......
......@@ -183,20 +183,25 @@ func (s *openSentState) processAddPathCapability(addPathCap packet.AddPathCapabi
return
}
f := s.fsm.addressFamily(addPathCap.AFI, addPathCap.SAFI)
if f == nil {
return
}
switch addPathCap.SendReceive {
case packet.AddPathReceive:
if !s.fsm.peer.addPathSend.BestOnly {
if !f.addPathSend.BestOnly {
s.fsm.options.AddPathRX = true
}
case packet.AddPathSend:
if s.fsm.peer.addPathRecv {
if f.addPathRecv {
s.fsm.options.AddPathRX = true
}
case packet.AddPathSendReceive:
if !s.fsm.peer.addPathSend.BestOnly {
if !f.addPathSend.BestOnly {
s.fsm.options.AddPathRX = true
}
if s.fsm.peer.addPathRecv {
if f.addPathRecv {
s.fsm.options.AddPathRX = true
}
}
......
......@@ -38,13 +38,13 @@ func TestBgpServerPeerSnapshot(t *testing.T) {
KeepAlive: time.Second * 30,
Passive: true,
RouterID: s.RouterID(),
AddPathSend: routingtable.ClientOptions{
MaxPaths: 10,
},
IPv4: &config.AddressFamilyConfig{
RIB: rib,
ImportFilter: filter.NewDrainFilter(),
ExportFilter: filter.NewAcceptAllFilter(),
AddPathSend: routingtable.ClientOptions{
MaxPaths: 10,
},
},
}
s.AddPeer(pc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment