summaryrefslogtreecommitdiffhomepage
path: root/config
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-10-03 14:27:58 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-07 21:53:46 +0900
commite541ede1b5e4d08aaa3fffd1ee13744cc1b69c59 (patch)
treea1506709a7fff5bed29003fe02e71f1efd524a61 /config
parent8fed41e4cca863b20ff9467cbc33de2972717b86 (diff)
config: Pass Global Config to SetDefaultNeighborConfig
In neighbor config, there are some parameters whose default value can be changed depending on the global config. This commit modifies the argument of config.SetDefaultNeighborConfigValues() to pass the global config. It enables to change the default settings of neighbor depending on the global config. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'config')
-rw-r--r--config/default.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/config/default.go b/config/default.go
index 41bcbd40..f69c96aa 100644
--- a/config/default.go
+++ b/config/default.go
@@ -101,11 +101,18 @@ func isLocalLinkLocalAddress(ifindex int, addr net.IP) (bool, error) {
return false, nil
}
-func SetDefaultNeighborConfigValues(n *Neighbor, asn uint32) error {
- return setDefaultNeighborConfigValuesWithViper(nil, n, asn)
+func SetDefaultNeighborConfigValues(n *Neighbor, g *Global) error {
+ return setDefaultNeighborConfigValuesWithViper(nil, n, g)
}
-func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn uint32) error {
+func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, g *Global) error {
+ if n == nil {
+ return fmt.Errorf("neighbor config is nil")
+ }
+ if g == nil {
+ return fmt.Errorf("global config is nil")
+ }
+
if v == nil {
// Determines this function is called against the same Neighbor struct,
// and if already called, returns immediately.
@@ -116,7 +123,7 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui
}
if n.Config.LocalAs == 0 {
- n.Config.LocalAs = asn
+ n.Config.LocalAs = g.Config.As
}
n.State.LocalAs = n.Config.LocalAs
@@ -407,7 +414,7 @@ func setDefaultConfigValuesWithViper(v *viper.Viper, b *BgpConfigSet) error {
if len(list) > idx {
vv.Set("neighbor", list[idx])
}
- if err := setDefaultNeighborConfigValuesWithViper(vv, &n, b.Global.Config.As); err != nil {
+ if err := setDefaultNeighborConfigValuesWithViper(vv, &n, &b.Global); err != nil {
return err
}
b.Neighbors[idx] = n