1
0
mirror of https://github.com/osrg/gobgp.git synced 2024-05-11 05:55:10 +00:00

server: exclude RTC for softreset if not specified

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori
2018-06-29 08:58:47 +09:00
parent f265c314af
commit db6683bfbf
2 changed files with 46 additions and 9 deletions

View File

@@ -1762,16 +1762,28 @@ func (s *BgpServer) Stop() error {
}, true)
}
func familiesForSoftreset(peer *Peer, family bgp.RouteFamily) []bgp.RouteFamily {
if family == bgp.RouteFamily(0) {
configured := peer.configuredRFlist()
families := make([]bgp.RouteFamily, 0, len(configured))
for _, f := range configured {
if f != bgp.RF_RTC_UC {
families = append(families, f)
}
}
return families
}
return []bgp.RouteFamily{family}
}
func (s *BgpServer) softResetIn(addr string, family bgp.RouteFamily) error {
peers, err := s.addrToPeers(addr)
if err != nil {
return err
}
for _, peer := range peers {
families := []bgp.RouteFamily{family}
if family == bgp.RouteFamily(0) {
families = peer.configuredRFlist()
}
families := familiesForSoftreset(peer, family)
pathList := make([]*table.Path, 0, peer.adjRibIn.Count(families))
for _, path := range peer.adjRibIn.PathList(families, false) {
// RFC4271 9.1.2 Phase 2: Route Selection
@@ -1807,11 +1819,7 @@ func (s *BgpServer) softResetOut(addr string, family bgp.RouteFamily, deferral b
if peer.fsm.state != bgp.BGP_FSM_ESTABLISHED {
continue
}
families := []bgp.RouteFamily{family}
if family == bgp.RouteFamily(0) {
families = peer.negotiatedRFList()
}
families := familiesForSoftreset(peer, family)
if deferral {
_, y := peer.fsm.rfMap[bgp.RF_RTC_UC]

View File

@@ -676,3 +676,32 @@ func TestGracefulRestartTimerExpired(t *testing.T) {
}
}
}
func TestFamiliesForSoftreset(t *testing.T) {
f := func(f bgp.RouteFamily) config.AfiSafi {
return config.AfiSafi{
State: config.AfiSafiState{
Family: f,
},
}
}
peer := &Peer{
fsm: &FSM{
pConf: &config.Neighbor{
AfiSafis: []config.AfiSafi{f(bgp.RF_RTC_UC), f(bgp.RF_IPv4_UC), f(bgp.RF_IPv6_UC)},
},
},
}
families := familiesForSoftreset(peer, bgp.RF_IPv4_UC)
assert.Equal(t, len(families), 1)
assert.Equal(t, families[0], bgp.RF_IPv4_UC)
families = familiesForSoftreset(peer, bgp.RF_RTC_UC)
assert.Equal(t, len(families), 1)
assert.Equal(t, families[0], bgp.RF_RTC_UC)
families = familiesForSoftreset(peer, bgp.RouteFamily(0))
assert.Equal(t, len(families), 2)
assert.NotContains(t, families, bgp.RF_RTC_UC)
}