diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-09-14 11:23:46 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-10-03 14:53:44 +0900 |
commit | 6ed2c5624cbc7d2dcee126603e5f7893910d17d4 (patch) | |
tree | f033fe04e194d8131ce6e98e9e179005b758d234 /config | |
parent | 0db5461625d75fc85f1a1144d17af8d0f61b5473 (diff) |
config: add-paths structure per AFI-SAFI
This patch introduce "add-paths" structure per AFI-SAFI in order to
enable to store add-paths feature config/state per AFI-SAFI.
Also, this patch renames a few variables to avoid the name collisions.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'config')
-rw-r--r-- | config/bgp_configs.go | 6 | ||||
-rw-r--r-- | config/default.go | 14 | ||||
-rw-r--r-- | config/util.go | 19 |
3 files changed, 29 insertions, 10 deletions
diff --git a/config/bgp_configs.go b/config/bgp_configs.go index 7c5eddb8..1c87bb88 100644 --- a/config/bgp_configs.go +++ b/config/bgp_configs.go @@ -3933,6 +3933,9 @@ type AfiSafi struct { RouteTargetMembership RouteTargetMembership `mapstructure:"route-target-membership" json:"route-target-membership,omitempty"` // original -> gobgp:long-lived-graceful-restart LongLivedGracefulRestart LongLivedGracefulRestart `mapstructure:"long-lived-graceful-restart" json:"long-lived-graceful-restart,omitempty"` + // original -> gobgp:add-paths + // add-paths configuration options related to a particular AFI-SAFI. + AddPaths AddPaths `mapstructure:"add-paths" json:"add-paths,omitempty"` } func (lhs *AfiSafi) Equal(rhs *AfiSafi) bool { @@ -3993,6 +3996,9 @@ func (lhs *AfiSafi) Equal(rhs *AfiSafi) bool { if !lhs.LongLivedGracefulRestart.Equal(&(rhs.LongLivedGracefulRestart)) { return false } + if !lhs.AddPaths.Equal(&(rhs.AddPaths)) { + return false + } return true } diff --git a/config/default.go b/config/default.go index 93693ce6..ed1fac91 100644 --- a/config/default.go +++ b/config/default.go @@ -201,6 +201,12 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui } else { n.AfiSafis = []AfiSafi{defaultAfiSafi(AFI_SAFI_TYPE_IPV6_UNICAST, true)} } + for i := range n.AfiSafis { + n.AfiSafis[i].AddPaths.Config.Receive = n.AddPaths.Config.Receive + n.AfiSafis[i].AddPaths.State.Receive = n.AddPaths.Config.Receive + n.AfiSafis[i].AddPaths.Config.SendMax = n.AddPaths.Config.SendMax + n.AfiSafis[i].AddPaths.State.SendMax = n.AddPaths.Config.SendMax + } } else { afs, err := extractArray(v.Get("neighbor.afi-safis")) if err != nil { @@ -221,6 +227,14 @@ func setDefaultNeighborConfigValuesWithViper(v *viper.Viper, n *Neighbor, asn ui n.AfiSafis[i].Config.Enabled = true } 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 + } + 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 + } + n.AfiSafis[i].AddPaths.State.SendMax = n.AfiSafis[i].AddPaths.Config.SendMax } } diff --git a/config/util.go b/config/util.go index de7ba3d4..f63e6d69 100644 --- a/config/util.go +++ b/config/util.go @@ -66,17 +66,16 @@ func (c AfiSafis) ToRfList() ([]bgp.RouteFamily, error) { } func CreateRfMap(p *Neighbor) map[bgp.RouteFamily]bgp.BGPAddPathMode { - rfs, _ := AfiSafis(p.AfiSafis).ToRfList() - mode := bgp.BGP_ADD_PATH_NONE - if p.AddPaths.Config.Receive { - mode |= bgp.BGP_ADD_PATH_RECEIVE - } - if p.AddPaths.Config.SendMax > 0 { - mode |= bgp.BGP_ADD_PATH_SEND - } rfMap := make(map[bgp.RouteFamily]bgp.BGPAddPathMode) - for _, rf := range rfs { - rfMap[rf] = mode + for _, af := range p.AfiSafis { + mode := bgp.BGP_ADD_PATH_NONE + if af.AddPaths.State.Receive { + mode |= bgp.BGP_ADD_PATH_RECEIVE + } + if af.AddPaths.State.SendMax > 0 { + mode |= bgp.BGP_ADD_PATH_SEND + } + rfMap[af.State.Family] = mode } return rfMap } |