diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-01-23 20:33:10 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-10 22:15:04 -0800 |
commit | 607d56ad264363c1ebf44a81eb2ab19c2f3da40a (patch) | |
tree | ee3fa849242f7ca7eea122dfb90c84a15d0013c5 /server | |
parent | 9861b237685d420ff390b5338da94396f7cc5274 (diff) |
server: reflect graceful restart configuration in a sending open message
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/server/fsm.go b/server/fsm.go index 6656d544..e180b375 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -469,6 +469,35 @@ func capabilitiesFromConfig(gConf *config.Global, pConf *config.Neighbor) []bgp. caps = append(caps, bgp.NewCapMultiProtocol(family)) } caps = append(caps, bgp.NewCapFourOctetASNumber(gConf.Config.As)) + + if c := pConf.GracefulRestart.Config; c.Enabled { + tuples := []*bgp.CapGracefulRestartTuple{} + + // RFC 4724 4.1 + // To re-establish the session with its peer, the Restarting Speaker + // MUST set the "Restart State" bit in the Graceful Restart Capability + // of the OPEN message. + restarting := pConf.GracefulRestart.State.LocalRestarting + + if !c.HelperOnly { + for i, rf := range pConf.AfiSafis { + if rf.MpGracefulRestart.Config.Enabled { + k, _ := bgp.GetRouteFamily(string(rf.AfiSafiName)) + // When restarting, always flag forwaring bit. + // This can be a lie, depending on how gobgpd is used. + // For a route-server use-case, since a route-server + // itself doesn't forward packets, and the dataplane + // is a l2 switch which continues to work with no + // relation to bgpd, this behavior is ok. + // TODO consideration of other use-cases + tuples = append(tuples, bgp.NewCapGracefulRestartTuple(k, restarting)) + pConf.AfiSafis[i].MpGracefulRestart.State.Advertised = true + } + } + } + time := c.RestartTime + caps = append(caps, bgp.NewCapGracefulRestart(restarting, time, tuples)) + } return caps } |