summaryrefslogtreecommitdiffhomepage
path: root/config/util.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-13 14:04:50 +0900
committerSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-06-16 09:09:47 +0900
commitbe2524ee3e158a0d248d730f727da80bab09aed8 (patch)
treee27c107dc19f448bcfdd325f88cb27d82c406da4 /config/util.go
parent83684d5e62fb14596aabf03747a8b395543f91bb (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/util.go')
-rw-r--r--config/util.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/config/util.go b/config/util.go
index 36999411..8ecf56d5 100644
--- a/config/util.go
+++ b/config/util.go
@@ -140,3 +140,14 @@ func ParseMaskLength(prefix, mask string) (int, int, error) {
}
return min, max, nil
}
+
+func ExtractNeighborAddress(c *Neighbor) (string, error) {
+ addr := c.State.NeighborAddress
+ if addr == "" {
+ addr = c.Config.NeighborAddress
+ if addr == "" {
+ return "", fmt.Errorf("NeighborAddress is not configured")
+ }
+ }
+ return addr, nil
+}