peer: Set NeighborAddress before initializing dynamic peers

If State.NeighborAddress is not set, setting default configs
for the dynamic peers will fail. This patch set State.NeighborAddress
before setting default configs.
And this patch avoids overwriting State.NeighborAddress if it is set.

Signed-off-by: Satoshi Fujimoto <[email protected]>
This commit is contained in:
Satoshi Fujimoto
2017-06-20 11:28:09 +09:00
parent 1c7829604d
commit 85a62d8ede
2 changed files with 7 additions and 2 deletions
+4 -1
View File
@@ -130,8 +130,11 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui
}
}
if n.State.NeighborAddress == "" {
n.State.NeighborAddress = n.Config.NeighborAddress
}
n.State.PeerAs = n.Config.PeerAs
n.State.NeighborAddress = n.Config.NeighborAddress
n.AsPathOptions.State.AllowOwnAs = n.AsPathOptions.Config.AllowOwnAs
if !v.IsSet("neighbor.timers.config.connect-retry") && n.Timers.Config.ConnectRetry == 0 {
+3 -1
View File
@@ -62,6 +62,9 @@ func newDynamicPeer(g *config.Global, neighborAddress string, pg *config.PeerGro
Config: config.NeighborConfig{
PeerGroup: pg.Config.PeerGroupName,
},
State: config.NeighborState{
NeighborAddress: neighborAddress,
},
Transport: config.Transport{
Config: config.TransportConfig{
PassiveMode: true,
@@ -82,7 +85,6 @@ func newDynamicPeer(g *config.Global, neighborAddress string, pg *config.PeerGro
}).Debugf("Can't set default config: %s", err)
return nil
}
conf.State.NeighborAddress = neighborAddress
peer := NewPeer(g, &conf, loc, policy)
peer.fsm.state = bgp.BGP_FSM_ACTIVE
return peer