summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/fsm.go15
-rw-r--r--server/peer.go31
-rw-r--r--server/server.go2
3 files changed, 17 insertions, 31 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))
}
diff --git a/server/peer.go b/server/peer.go
index 4d2d1ceb..4a1860e8 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -215,8 +215,7 @@ func (peer *Peer) forwardingPreservedFamilies() ([]bgp.RouteFamily, []bgp.RouteF
list := []bgp.RouteFamily{}
for _, a := range peer.fsm.pConf.AfiSafis {
if s := a.MpGracefulRestart.State; s.Enabled && s.Received {
- f, _ := bgp.GetRouteFamily(string(a.Config.AfiSafiName))
- list = append(list, f)
+ list = append(list, a.State.Family)
}
}
return classifyFamilies(peer.configuredRFlist(), list)
@@ -226,8 +225,7 @@ func (peer *Peer) llgrFamilies() ([]bgp.RouteFamily, []bgp.RouteFamily) {
list := []bgp.RouteFamily{}
for _, a := range peer.fsm.pConf.AfiSafis {
if a.LongLivedGracefulRestart.State.Enabled {
- f, _ := bgp.GetRouteFamily(string(a.Config.AfiSafiName))
- list = append(list, f)
+ list = append(list, a.State.Family)
}
}
return classifyFamilies(peer.configuredRFlist(), list)
@@ -248,7 +246,7 @@ func (peer *Peer) isLLGREnabledFamily(family bgp.RouteFamily) bool {
func (peer *Peer) llgrRestartTime(family bgp.RouteFamily) uint32 {
for _, a := range peer.fsm.pConf.AfiSafis {
- if f, _ := bgp.GetRouteFamily(string(a.Config.AfiSafiName)); f == family {
+ if a.State.Family == family {
return a.LongLivedGracefulRestart.State.PeerRestartTime
}
}
@@ -258,7 +256,7 @@ func (peer *Peer) llgrRestartTime(family bgp.RouteFamily) uint32 {
func (peer *Peer) llgrRestartTimerExpired(family bgp.RouteFamily) bool {
all := true
for _, a := range peer.fsm.pConf.AfiSafis {
- if f, _ := bgp.GetRouteFamily(string(a.Config.AfiSafiName)); f == family {
+ if a.State.Family == family {
a.LongLivedGracefulRestart.State.PeerRestartTimerExpired = true
}
s := a.LongLivedGracefulRestart.State
@@ -498,18 +496,10 @@ func (peer *Peer) updatePrefixLimitConfig(c []config.AfiSafi) error {
}
m := make(map[bgp.RouteFamily]config.PrefixLimitConfig)
for _, e := range x {
- k, err := bgp.GetRouteFamily(string(e.Config.AfiSafiName))
- if err != nil {
- return err
- }
- m[k] = e.PrefixLimit.Config
+ m[e.State.Family] = e.PrefixLimit.Config
}
for _, e := range y {
- k, err := bgp.GetRouteFamily(string(e.Config.AfiSafiName))
- if err != nil {
- return err
- }
- if p, ok := m[k]; !ok {
+ if p, ok := m[e.State.Family]; !ok {
return fmt.Errorf("changing supported afi-safi is not allowed")
} else if !p.Equal(&e.PrefixLimit.Config) {
log.WithFields(log.Fields{
@@ -521,8 +511,8 @@ func (peer *Peer) updatePrefixLimitConfig(c []config.AfiSafi) error {
"OldShutdownThresholdPct": p.ShutdownThresholdPct,
"NewShutdownThresholdPct": e.PrefixLimit.Config.ShutdownThresholdPct,
}).Warnf("update prefix limit configuration")
- peer.prefixLimitWarned[k] = false
- if msg := peer.doPrefixLimit(k, &e.PrefixLimit.Config); msg != nil {
+ peer.prefixLimitWarned[e.State.Family] = false
+ if msg := peer.doPrefixLimit(e.State.Family, &e.PrefixLimit.Config); msg != nil {
sendFsmOutgoingMsg(peer, nil, msg, true)
}
}
@@ -544,9 +534,8 @@ func (peer *Peer) handleUpdate(e *FsmMsg) ([]*table.Path, []bgp.RouteFamily, *bg
peer.fsm.pConf.Timers.State.UpdateRecvTime = time.Now().Unix()
if len(e.PathList) > 0 {
peer.adjRibIn.Update(e.PathList)
- for _, family := range peer.fsm.pConf.AfiSafis {
- k, _ := bgp.GetRouteFamily(string(family.Config.AfiSafiName))
- if msg := peer.doPrefixLimit(k, &family.PrefixLimit.Config); msg != nil {
+ for _, af := range peer.fsm.pConf.AfiSafis {
+ if msg := peer.doPrefixLimit(af.State.Family, &af.PrefixLimit.Config); msg != nil {
return nil, nil, msg
}
}
diff --git a/server/server.go b/server/server.go
index ac435172..d4b790a1 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1009,7 +1009,7 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) {
rtc = true
}
for i, a := range peer.fsm.pConf.AfiSafis {
- if g, _ := bgp.GetRouteFamily(string(a.Config.AfiSafiName)); f == g {
+ if a.State.Family == f {
peer.fsm.pConf.AfiSafis[i].MpGracefulRestart.State.EndOfRibReceived = true
}
}