diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-02-10 23:41:44 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-10 23:41:44 -0800 |
commit | 023a498e4a90982095c870c5491770bf4952fc2b (patch) | |
tree | 135c11a05d8ff106264d91f0965aa6d926ac861b /server/peer.go | |
parent | b19bbd415e8d33f01bcd407baece94ea1b81c957 (diff) |
server: support graceful-restart helper-speaker behavior
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/server/peer.go b/server/peer.go index da76bf93..ee9c8bdd 100644 --- a/server/peer.go +++ b/server/peer.go @@ -97,11 +97,45 @@ func (peer *Peer) isGracefulRestartEnabled() bool { return peer.fsm.pConf.GracefulRestart.State.Enabled } +func (peer *Peer) recvedAllEOR() bool { + for _, a := range peer.fsm.pConf.AfiSafis { + if s := a.MpGracefulRestart.State; s.Enabled && !s.EndOfRibReceived { + return false + } + } + return true +} + func (peer *Peer) configuredRFlist() []bgp.RouteFamily { rfs, _ := config.AfiSafis(peer.conf.AfiSafis).ToRfList() return rfs } +func (peer *Peer) forwardingPreservedFamilies() ([]bgp.RouteFamily, []bgp.RouteFamily) { + list := []bgp.RouteFamily{} + for _, a := range peer.fsm.pConf.AfiSafis { + if s := a.MpGracefulRestart.State; s.Enabled && s.Received { + f, _ := bgp.GetRouteFamily(string(a.AfiSafiName)) + list = append(list, f) + } + } + preserved := []bgp.RouteFamily{} + notPreserved := []bgp.RouteFamily{} + for _, f := range peer.configuredRFlist() { + p := true + for _, g := range list { + if f == g { + p = false + preserved = append(preserved, f) + } + } + if p { + notPreserved = append(notPreserved, f) + } + } + return preserved, notPreserved +} + func (peer *Peer) getAccepted(rfList []bgp.RouteFamily) []*table.Path { return peer.adjRibIn.PathList(rfList, true) } @@ -206,6 +240,10 @@ func (peer *Peer) startFSMHandler(incoming, stateCh chan *FsmMsg) { peer.fsm.h = NewFSMHandler(peer.fsm, incoming, stateCh, peer.outgoing) } +func (peer *Peer) StaleAll(rfList []bgp.RouteFamily) { + peer.adjRibIn.StaleAll(rfList) +} + func (peer *Peer) PassConn(conn *net.TCPConn) { select { case peer.fsm.connCh <- conn: |