summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-08-04 15:54:44 +0900
committerfujita <fujita@fujita-no-MacBook.local>2017-09-14 09:22:04 +0900
commitbb7d2f2541d67e7c2660ab80a91cb852e49ce1fb (patch)
tree4dc594a662f997f37bf2855514978d7bb006975f /server/fsm.go
parente82f1ebad2214e16960d08fe2ad85cd9422a187b (diff)
config: Introduce Family field into AfiSafiState
To reduce the translations of "AfiSafiName" into "bgp.RouteFamily", this patch introduces "Family" field into "AfiSafiState" and stores the translated value. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/server/fsm.go b/server/fsm.go
index 55a3aa0c..df31b30b 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -562,9 +562,8 @@ func (h *FSMHandler) active() (bgp.FSMState, FsmStateReason) {
func capabilitiesFromConfig(pConf *config.Neighbor) []bgp.ParameterCapabilityInterface {
caps := make([]bgp.ParameterCapabilityInterface, 0, 4)
caps = append(caps, bgp.NewCapRouteRefresh())
- for _, rf := range pConf.AfiSafis {
- family, _ := bgp.GetRouteFamily(string(rf.Config.AfiSafiName))
- caps = append(caps, bgp.NewCapMultiProtocol(family))
+ for _, af := range pConf.AfiSafis {
+ caps = append(caps, bgp.NewCapMultiProtocol(af.State.Family))
}
caps = append(caps, bgp.NewCapFourOctetASNumber(pConf.Config.LocalAs))
@@ -580,7 +579,6 @@ func capabilitiesFromConfig(pConf *config.Neighbor) []bgp.ParameterCapabilityInt
if !c.HelperOnly {
for i, rf := range pConf.AfiSafis {
- k, _ := bgp.GetRouteFamily(string(rf.Config.AfiSafiName))
if m := rf.MpGracefulRestart.Config; m.Enabled {
// When restarting, always flag forwaring bit.
// This can be a lie, depending on how gobgpd is used.
@@ -589,11 +587,11 @@ func capabilitiesFromConfig(pConf *config.Neighbor) []bgp.ParameterCapabilityInt
// 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))
+ tuples = append(tuples, bgp.NewCapGracefulRestartTuple(rf.State.Family, restarting))
pConf.AfiSafis[i].MpGracefulRestart.State.Advertised = true
}
if m := rf.LongLivedGracefulRestart.Config; m.Enabled {
- ltuples = append(ltuples, bgp.NewCapLongLivedGracefulRestartTuple(k, restarting, m.RestartTime))
+ ltuples = append(ltuples, bgp.NewCapLongLivedGracefulRestartTuple(rf.State.Family, restarting, m.RestartTime))
}
}
}
@@ -629,9 +627,8 @@ func capabilitiesFromConfig(pConf *config.Neighbor) []bgp.ParameterCapabilityInt
}
if uint8(mode) > 0 {
items := make([]*bgp.CapAddPathTuple, 0, len(pConf.AfiSafis))
- for _, rf := range pConf.AfiSafis {
- k, _ := bgp.GetRouteFamily(string(rf.Config.AfiSafiName))
- items = append(items, bgp.NewCapAddPathTuple(k, mode))
+ for _, af := range pConf.AfiSafis {
+ items = append(items, bgp.NewCapAddPathTuple(af.State.Family, mode))
}
caps = append(caps, bgp.NewCapAddPath(items))
}