Skip to content
Snippets Groups Projects
Commit 1f3d4368 authored by Daniel Czerwonk's avatar Daniel Czerwonk Committed by takt
Browse files

sane default for ClientOptions (#195)

* sane default for ClientOptions, otherwise max paths for non add path is 0

* applied new default to BMP test

* added regression test
parent 4342a2ce
No related branches found
No related tags found
No related merge requests found
...@@ -330,12 +330,14 @@ func TestProcessPeerUpNotification(t *testing.T) { ...@@ -330,12 +330,14 @@ func TestProcessPeerUpNotification(t *testing.T) {
safi: 1, safi: 1,
adjRIBIn: adjRIBIn.New(filter.NewAcceptAllFilter(), &routingtable.ContributingASNs{}, 169090600, 0, false), adjRIBIn: adjRIBIn.New(filter.NewAcceptAllFilter(), &routingtable.ContributingASNs{}, 169090600, 0, false),
importFilter: filter.NewAcceptAllFilter(), importFilter: filter.NewAcceptAllFilter(),
addPathTX: routingtable.ClientOptions{BestOnly: true},
}, },
ipv6Unicast: &fsmAddressFamily{ ipv6Unicast: &fsmAddressFamily{
afi: 2, afi: 2,
safi: 1, safi: 1,
adjRIBIn: adjRIBIn.New(filter.NewAcceptAllFilter(), &routingtable.ContributingASNs{}, 169090600, 0, false), adjRIBIn: adjRIBIn.New(filter.NewAcceptAllFilter(), &routingtable.ContributingASNs{}, 169090600, 0, false),
importFilter: filter.NewAcceptAllFilter(), importFilter: filter.NewAcceptAllFilter(),
addPathTX: routingtable.ClientOptions{BestOnly: true},
}, },
}, },
}, },
......
...@@ -45,6 +45,9 @@ func newFSMAddressFamily(afi uint16, safi uint8, family *peerAddressFamily, fsm ...@@ -45,6 +45,9 @@ func newFSMAddressFamily(afi uint16, safi uint8, family *peerAddressFamily, fsm
rib: family.rib, rib: family.rib,
importFilter: family.importFilter, importFilter: family.importFilter,
exportFilter: family.exportFilter, exportFilter: family.exportFilter,
addPathTX: routingtable.ClientOptions{
BestOnly: true,
},
} }
} }
......
package server package server
import ( import (
"github.com/bio-routing/bio-rd/routingtable"
"net" "net"
"testing" "testing"
...@@ -211,3 +212,82 @@ func TestProcessMultiProtocolCapability(t *testing.T) { ...@@ -211,3 +212,82 @@ func TestProcessMultiProtocolCapability(t *testing.T) {
}) })
} }
} }
func TestProcessAddPathCapabilityTX(t *testing.T) {
tests := []struct {
name string
peer *peer
caps []packet.AddPathCapability
expected routingtable.ClientOptions
}{
{
name: "Add-Path enabled and cap received",
peer: &peer{
ipv4: &peerAddressFamily{
addPathSend: routingtable.ClientOptions{MaxPaths: 3},
},
},
caps: []packet.AddPathCapability{
{
AFI: packet.IPv4AFI,
SAFI: packet.UnicastSAFI,
SendReceive: packet.AddPathReceive,
},
},
expected: routingtable.ClientOptions{MaxPaths: 3},
},
{
name: "Add-Path enabled and cap not received",
peer: &peer{
ipv4: &peerAddressFamily{
addPathSend: routingtable.ClientOptions{MaxPaths: 3},
},
},
caps: []packet.AddPathCapability{},
expected: routingtable.ClientOptions{BestOnly: true},
},
{
name: "Add-Path disabled and cap received",
peer: &peer{
ipv4: &peerAddressFamily{
addPathSend: routingtable.ClientOptions{BestOnly: true},
},
},
caps: []packet.AddPathCapability{
{
AFI: packet.IPv4AFI,
SAFI: packet.UnicastSAFI,
SendReceive: packet.AddPathReceive,
},
},
expected: routingtable.ClientOptions{BestOnly: true},
},
{
name: "Add-Path disabled and cap not received",
peer: &peer{
ipv4: &peerAddressFamily{
addPathSend: routingtable.ClientOptions{BestOnly: true},
},
},
caps: []packet.AddPathCapability{},
expected: routingtable.ClientOptions{BestOnly: true},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
fsm := newFSM(test.peer)
fsm.con = &btesting.MockConn{}
s := &openSentState{
fsm: fsm,
}
for _, cap := range test.caps {
s.processAddPathCapability(cap)
}
assert.Equal(t, test.expected, fsm.ipv4Unicast.addPathTX)
})
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment