summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/config
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-11-25 21:02:55 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-11-25 23:27:02 +0900
commita5763c20d4ab411a3d6375cad32c8c8255c43a64 (patch)
treeecb2eaa8515b13f641c854993acecb42d522e3a7 /internal/pkg/config
parent7ec6a96962637d0c6f525ec6e8dd517f785842c7 (diff)
api: remove AddPaths from Peer and PeerGroup
AddPaths in AfiSafi should be used; it can handle configuration per family. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'internal/pkg/config')
-rw-r--r--internal/pkg/config/default.go8
-rw-r--r--internal/pkg/config/util.go10
-rw-r--r--internal/pkg/config/util_test.go26
3 files changed, 36 insertions, 8 deletions
diff --git a/internal/pkg/config/default.go b/internal/pkg/config/default.go
index 31dd1b17..b03eec8e 100644
--- a/internal/pkg/config/default.go
+++ b/internal/pkg/config/default.go
@@ -197,11 +197,15 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, g *Glo
}
n.AfiSafis[i].MpGracefulRestart.State.Enabled = n.AfiSafis[i].MpGracefulRestart.Config.Enabled
if !vv.IsSet("afi-safi.add-paths.config.receive") {
- n.AfiSafis[i].AddPaths.Config.Receive = n.AddPaths.Config.Receive
+ if n.AddPaths.Config.Receive == true {
+ n.AfiSafis[i].AddPaths.Config.Receive = n.AddPaths.Config.Receive
+ }
}
n.AfiSafis[i].AddPaths.State.Receive = n.AfiSafis[i].AddPaths.Config.Receive
if !vv.IsSet("afi-safi.add-paths.config.send-max") {
- n.AfiSafis[i].AddPaths.Config.SendMax = n.AddPaths.Config.SendMax
+ if n.AddPaths.Config.SendMax != 0 {
+ n.AfiSafis[i].AddPaths.Config.SendMax = n.AddPaths.Config.SendMax
+ }
}
n.AfiSafis[i].AddPaths.State.SendMax = n.AfiSafis[i].AddPaths.Config.SendMax
}
diff --git a/internal/pkg/config/util.go b/internal/pkg/config/util.go
index 5090a3b8..c7243caf 100644
--- a/internal/pkg/config/util.go
+++ b/internal/pkg/config/util.go
@@ -209,12 +209,12 @@ func isAfiSafiChanged(x, y []AfiSafi) bool {
if len(x) != len(y) {
return true
}
- m := make(map[string]bool)
- for _, e := range x {
- m[string(e.Config.AfiSafiName)] = true
+ m := make(map[string]AfiSafi)
+ for i, e := range x {
+ m[string(e.Config.AfiSafiName)] = x[i]
}
for _, e := range y {
- if !m[string(e.Config.AfiSafiName)] {
+ if v, ok := m[string(e.Config.AfiSafiName)]; !ok || !v.Config.Equal(&e.Config) || !v.AddPaths.Config.Equal(&e.AddPaths.Config) {
return true
}
}
@@ -539,7 +539,6 @@ func NewPeerFromConfigStruct(pconf *Neighbor) *api.Peer {
PassiveMode: pconf.Transport.Config.PassiveMode,
},
AfiSafis: afiSafis,
- AddPaths: newAddPathsFromConfigStruct(&pconf.AddPaths),
}
}
@@ -605,7 +604,6 @@ func NewPeerGroupFromConfigStruct(pconf *PeerGroup) *api.PeerGroup {
PassiveMode: pconf.Transport.Config.PassiveMode,
},
AfiSafis: afiSafis,
- AddPaths: newAddPathsFromConfigStruct(&pconf.AddPaths),
}
}
diff --git a/internal/pkg/config/util_test.go b/internal/pkg/config/util_test.go
index a34b02f4..62fe1c1c 100644
--- a/internal/pkg/config/util_test.go
+++ b/internal/pkg/config/util_test.go
@@ -30,3 +30,29 @@ func TestDetectConfigFileType(t *testing.T) {
assert.Equal("yaml", detectConfigFileType("bgpd.yml", "xxx"))
assert.Equal("json", detectConfigFileType("bgpd.json", "xxx"))
}
+
+func TestIsAfiSafiChanged(t *testing.T) {
+ v4 := AfiSafi{
+ Config: AfiSafiConfig{
+ AfiSafiName: AFI_SAFI_TYPE_IPV4_UNICAST,
+ },
+ }
+ v6 := AfiSafi{
+ Config: AfiSafiConfig{
+ AfiSafiName: AFI_SAFI_TYPE_IPV6_UNICAST,
+ },
+ }
+ old := []AfiSafi{v4}
+ new := []AfiSafi{v4}
+ assert.False(t, isAfiSafiChanged(old, new))
+
+ new = append(new, v6)
+ assert.True(t, isAfiSafiChanged(old, new))
+
+ new = []AfiSafi{v6}
+ assert.True(t, isAfiSafiChanged(old, new))
+ v4ap := v4
+ v4ap.AddPaths.Config.Receive = true
+ new = []AfiSafi{v4ap}
+ assert.True(t, isAfiSafiChanged(old, new))
+}