summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkishiguro <ishi@hash-set.com>2016-11-21 13:42:35 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-11-21 13:42:35 +0900
commit7006ec15fe72bdcf41f03d9e76db6783e7970b0a (patch)
tree42932a46cd50f62b5636b716af86ff18d2124ca8
parente11b09d7eae851d777a06ee18fde7865a361f5bb (diff)
api: Fix client.AddNeighbor() API does not properly configure AFI/SAFI bug
When we use gRPC API to add neighbor. Even if we specify, config.Neighbor.AfiSafis parameter, it is ignored in NewPeerFromConfigStruct(). Adding to that even if we fix the issue, NewNeighborFromAPIStruct() count Families twice. So resulting neighbor has duplicated Families configuration. This patch fixed both problems.
-rw-r--r--api/grpc_server.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go
index 65ea21f9..f445ab3a 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -89,6 +89,12 @@ func (s *Server) Serve() error {
}
func NewPeerFromConfigStruct(pconf *config.Neighbor) *Peer {
+ var families []uint32
+ for _, f := range pconf.AfiSafis {
+ if family, ok := bgp.AddressFamilyValueMap[string(f.Config.AfiSafiName)]; ok {
+ families = append(families, uint32(family))
+ }
+ }
prefixLimits := make([]*PrefixLimit, 0, len(pconf.AfiSafis))
for _, family := range pconf.AfiSafis {
if c := family.PrefixLimit.Config; c.MaxPrefixes > 0 {
@@ -117,6 +123,7 @@ func NewPeerFromConfigStruct(pconf *config.Neighbor) *Peer {
localCap = append(localCap, c)
}
return &Peer{
+ Families: families,
Conf: &PeerConf{
NeighborAddress: pconf.Config.NeighborAddress,
Id: s.RemoteRouterId,
@@ -883,20 +890,6 @@ func NewNeighborFromAPIStruct(a *Peer) (*config.Neighbor, error) {
}
}
}
- if a.Families != nil {
- for _, family := range a.Families {
- name, ok := bgp.AddressFamilyNameMap[bgp.RouteFamily(family)]
- if !ok {
- return pconf, fmt.Errorf("invalid address family: %d", family)
- }
- cAfiSafi := config.AfiSafi{
- Config: config.AfiSafiConfig{
- AfiSafiName: config.AfiSafiType(name),
- },
- }
- pconf.AfiSafis = append(pconf.AfiSafis, cAfiSafi)
- }
- }
if a.Transport != nil {
pconf.Transport.Config.LocalAddress = a.Transport.LocalAddress
pconf.Transport.Config.PassiveMode = a.Transport.PassiveMode