diff options
author | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-06-20 10:55:59 +0900 |
---|---|---|
committer | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-06-20 11:28:09 +0900 |
commit | 85a62d8edebce1a05ab7842a545b9a3b49d2e320 (patch) | |
tree | 66425b8269bd0db8532b60090b9524371831e781 | |
parent | 1c7829604d492dde7d9cdd491a77fe3d70797691 (diff) |
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 <satoshi.fujimoto7@gmail.com>
-rw-r--r-- | config/default.go | 5 | ||||
-rw-r--r-- | server/peer.go | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/config/default.go b/config/default.go index 9daba924..8f1cd908 100644 --- a/config/default.go +++ b/config/default.go @@ -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 { diff --git a/server/peer.go b/server/peer.go index 00785cd2..e51efc93 100644 --- a/server/peer.go +++ b/server/peer.go @@ -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 |