summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--api/grpc_server.go55
-rw-r--r--docs/sources/lib.md8
-rw-r--r--server/server.go9
3 files changed, 17 insertions, 55 deletions
diff --git a/api/grpc_server.go b/api/grpc_server.go
index 69ade16c..37841ff9 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -735,18 +735,12 @@ func (s *Server) DeleteVrf(ctx context.Context, arg *DeleteVrfRequest) (*DeleteV
}
func (s *Server) AddNeighbor(ctx context.Context, arg *AddNeighborRequest) (*AddNeighborResponse, error) {
- c, err := func(a *Peer) (config.Neighbor, error) {
- pconf := config.Neighbor{}
+ c, err := func(a *Peer) (*config.Neighbor, error) {
+ pconf := &config.Neighbor{}
if a.Conf != nil {
pconf.Config.NeighborAddress = a.Conf.NeighborAddress
pconf.Config.PeerAs = a.Conf.PeerAs
pconf.Config.LocalAs = a.Conf.LocalAs
-
- if pconf.Config.PeerAs != pconf.Config.LocalAs {
- pconf.Config.PeerType = config.PEER_TYPE_EXTERNAL
- } else {
- pconf.Config.PeerType = config.PEER_TYPE_INTERNAL
- }
pconf.Config.AuthPassword = a.Conf.AuthPassword
pconf.Config.RemovePrivateAs = config.RemovePrivateAsOption(a.Conf.RemovePrivateAs)
pconf.Config.RouteFlapDamping = a.Conf.RouteFlapDamping
@@ -755,17 +749,11 @@ func (s *Server) AddNeighbor(ctx context.Context, arg *AddNeighborRequest) (*Add
pconf.Config.PeerGroup = a.Conf.PeerGroup
pconf.Config.NeighborAddress = a.Conf.NeighborAddress
}
- if a.Timers != nil {
- if a.Timers.Config != nil {
- pconf.Timers.Config.ConnectRetry = float64(a.Timers.Config.ConnectRetry)
- pconf.Timers.Config.HoldTime = float64(a.Timers.Config.HoldTime)
- pconf.Timers.Config.KeepaliveInterval = float64(a.Timers.Config.KeepaliveInterval)
- pconf.Timers.Config.MinimumAdvertisementInterval = float64(a.Timers.Config.MinimumAdvertisementInterval)
- }
- } else {
- pconf.Timers.Config.ConnectRetry = float64(config.DEFAULT_CONNECT_RETRY)
- pconf.Timers.Config.HoldTime = float64(config.DEFAULT_HOLDTIME)
- pconf.Timers.Config.KeepaliveInterval = float64(config.DEFAULT_HOLDTIME / 3)
+ if a.Timers != nil && a.Timers.Config != nil {
+ pconf.Timers.Config.ConnectRetry = float64(a.Timers.Config.ConnectRetry)
+ pconf.Timers.Config.HoldTime = float64(a.Timers.Config.HoldTime)
+ pconf.Timers.Config.KeepaliveInterval = float64(a.Timers.Config.KeepaliveInterval)
+ pconf.Timers.Config.MinimumAdvertisementInterval = float64(a.Timers.Config.MinimumAdvertisementInterval)
}
if a.RouteReflector != nil {
pconf.RouteReflector.Config.RouteReflectorClusterId = config.RrClusterIdType(a.RouteReflector.RouteReflectorClusterId)
@@ -807,34 +795,10 @@ func (s *Server) AddNeighbor(ctx context.Context, arg *AddNeighborRequest) (*Add
}
pconf.AfiSafis = append(pconf.AfiSafis, cAfiSafi)
}
- } else {
- if net.ParseIP(a.Conf.NeighborAddress).To4() != nil {
- pconf.AfiSafis = []config.AfiSafi{
- config.AfiSafi{
- Config: config.AfiSafiConfig{
- AfiSafiName: "ipv4-unicast",
- },
- },
- }
- } else {
- pconf.AfiSafis = []config.AfiSafi{
- config.AfiSafi{
- Config: config.AfiSafiConfig{
- AfiSafiName: "ipv6-unicast",
- },
- },
- }
- }
}
if a.Transport != nil {
pconf.Transport.Config.LocalAddress = a.Transport.LocalAddress
pconf.Transport.Config.PassiveMode = a.Transport.PassiveMode
- } else {
- if net.ParseIP(a.Conf.NeighborAddress).To4() != nil {
- pconf.Transport.Config.LocalAddress = "0.0.0.0"
- } else {
- pconf.Transport.Config.LocalAddress = "::"
- }
}
if a.EbgpMultihop != nil {
pconf.EbgpMultihop.Config.Enabled = a.EbgpMultihop.Enabled
@@ -845,7 +809,7 @@ func (s *Server) AddNeighbor(ctx context.Context, arg *AddNeighborRequest) (*Add
if err != nil {
return nil, err
}
- return &AddNeighborResponse{}, s.bgpServer.AddNeighbor(&c)
+ return &AddNeighborResponse{}, s.bgpServer.AddNeighbor(c)
}
func (s *Server) DeleteNeighbor(ctx context.Context, arg *DeleteNeighborRequest) (*DeleteNeighborResponse, error) {
@@ -1662,9 +1626,6 @@ func (s *Server) StartServer(ctx context.Context, arg *StartServerRequest) (*Sta
AfiSafis: families,
},
}
- if err := config.SetDefaultConfigValues(b); err != nil {
- return nil, err
- }
return &StartServerResponse{}, s.bgpServer.Start(&b.Global)
}
diff --git a/docs/sources/lib.md b/docs/sources/lib.md
index ad1e257c..479f7d1e 100644
--- a/docs/sources/lib.md
+++ b/docs/sources/lib.md
@@ -40,10 +40,6 @@ func main() {
},
}
- if err := config.SetDefaultGlobalConfigValues(global); err != nil {
- log.Fatal(err)
- }
-
if err := s.Start(global); err != nil {
log.Fatal(err)
}
@@ -56,10 +52,6 @@ func main() {
},
}
- if err := config.SetDefaultNeighborConfigValues(n, global.Config.As); err != nil {
- log.Fatal(err)
- }
-
if err := s.AddNeighbor(n); err != nil {
log.Fatal(err)
}
diff --git a/server/server.go b/server/server.go
index 6841a854..ee8374a6 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1151,6 +1151,10 @@ func (s *BgpServer) Start(c *config.Global) (err error) {
return
}
+ if err = config.SetDefaultGlobalConfigValues(c); err != nil {
+ return
+ }
+
if c.Config.Port > 0 {
acceptCh := make(chan *net.TCPConn, 4096)
for _, addr := range c.Config.LocalAddressList {
@@ -1645,6 +1649,11 @@ func (s *BgpServer) GetNeighbor() (l []*config.Neighbor) {
}
func (server *BgpServer) addNeighbor(c *config.Neighbor) error {
+
+ if err := config.SetDefaultNeighborConfigValues(c, server.bgpConfig.Global.Config.As); err != nil {
+ return err
+ }
+
addr := c.Config.NeighborAddress
if _, y := server.neighborMap[addr]; y {
return fmt.Errorf("Can't overwrite the exising peer: %s", addr)