summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-07-28 10:11:43 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-29 16:31:35 +0900
commit59997e8daaf9793caecf178c770d9bb3882b148f (patch)
tree16ec6f729b9902d6711829647fbe8620d6fdd9ca /server
parentf3ae68b9f28e0ddbe33be3ecf09c2015cfba6078 (diff)
server: move default config setting logic inside BgpServer's methods
We have three ways to configure gobgp. config file, grpc api and native lib. Every methods eventually call (*server.BgpServer).Start() or (*server.BgpServer).AddNeighbor() when starting bgp server or adding neighbors. This commit moves default config setting logic inside them to remove redundant code in grpc_server.go and simplify the usage of native lib. Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/server.go9
1 files changed, 9 insertions, 0 deletions
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)