diff options
author | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-06-13 14:04:50 +0900 |
---|---|---|
committer | Satoshi Fujimoto <satoshi.fujimoto7@gmail.com> | 2017-06-16 09:09:47 +0900 |
commit | be2524ee3e158a0d248d730f727da80bab09aed8 (patch) | |
tree | e27c107dc19f448bcfdd325f88cb27d82c406da4 /config/default.go | |
parent | 83684d5e62fb14596aabf03747a8b395543f91bb (diff) |
config: Use State to get NeighborAddress instead of Config
By introducing dynamic neighbor feature,
GoBGP can have dynamic neighbors,
and corresponding Config.NeighboAddress can be empty.
This patch sets State.NeighborAddress for all neighbors,
and gets the neighbor's address from them.
Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'config/default.go')
-rw-r--r-- | config/default.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/config/default.go b/config/default.go index 3b0db592..1ff57adb 100644 --- a/config/default.go +++ b/config/default.go @@ -131,6 +131,7 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui } 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 { @@ -154,14 +155,14 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui if err != nil { return err } - n.Config.NeighborAddress = addr + n.State.NeighborAddress = addr } if n.Transport.Config.LocalAddress == "" { - if n.Config.NeighborAddress == "" { + if n.State.NeighborAddress == "" { return fmt.Errorf("no neighbor address/interface specified") } - ipAddr, err := net.ResolveIPAddr("ip", n.Config.NeighborAddress) + ipAddr, err := net.ResolveIPAddr("ip", n.State.NeighborAddress) if err != nil { return err } @@ -184,8 +185,8 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui defaultAfiSafi(AFI_SAFI_TYPE_IPV4_UNICAST, true), defaultAfiSafi(AFI_SAFI_TYPE_IPV6_UNICAST, true), } - } else if ipAddr, err := net.ResolveIPAddr("ip", n.Config.NeighborAddress); err != nil { - return fmt.Errorf("invalid neighbor address: %s", n.Config.NeighborAddress) + } else if ipAddr, err := net.ResolveIPAddr("ip", n.State.NeighborAddress); err != nil { + return fmt.Errorf("invalid neighbor address: %s", n.State.NeighborAddress) } else if ipAddr.IP.To4() != nil { n.AfiSafis = []AfiSafi{defaultAfiSafi(AFI_SAFI_TYPE_IPV4_UNICAST, true)} } else { |