diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-20 16:05:41 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-10-20 16:05:41 +0900 |
commit | e0a0fd792d98ce1d092531fc20fcc2b8fa5cffba (patch) | |
tree | 7895159e14d1876c9017d57ae5a3f206ecf4ad06 | |
parent | 5af15b1d9c7ef62039356de9874b6d68658ec024 (diff) |
server: properly handle invalid policy config
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | gobgpd/main.go | 4 | ||||
-rw-r--r-- | server/server.go | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/gobgpd/main.go b/gobgpd/main.go index fd657c3f..1b5cd959 100644 --- a/gobgpd/main.go +++ b/gobgpd/main.go @@ -184,7 +184,9 @@ func main() { if policyConfig == nil { policyConfig = &newConfig.Policy - bgpServer.SetPolicy(newConfig.Policy) + if err := bgpServer.SetPolicy(newConfig.Policy); err != nil { + log.Fatal(err) + } } else { if config.CheckPolicyDifference(policyConfig, &newConfig.Policy) { log.Info("Policy config is updated") diff --git a/server/server.go b/server/server.go index b92aec16..16bb0c97 100644 --- a/server/server.go +++ b/server/server.go @@ -884,7 +884,7 @@ func (server *BgpServer) SetPolicy(pl config.RoutingPolicy) error { if err != nil { log.WithFields(log.Fields{ "Topic": "Policy", - }).Debugf("failed to create routing policy: %s", err) + }).Errorf("failed to create routing policy: %s", err) return err } server.policy = p @@ -894,8 +894,13 @@ func (server *BgpServer) SetPolicy(pl config.RoutingPolicy) error { return nil } -func (server *BgpServer) handlePolicy(pl config.RoutingPolicy) { - server.SetPolicy(pl) +func (server *BgpServer) handlePolicy(pl config.RoutingPolicy) error { + if err := server.SetPolicy(pl); err != nil { + log.WithFields(log.Fields{ + "Topic": "Policy", + }).Errorf("failed to set new policy: %s", err) + return err + } for _, peer := range server.neighborMap { log.WithFields(log.Fields{ "Topic": "Peer", @@ -903,6 +908,7 @@ func (server *BgpServer) handlePolicy(pl config.RoutingPolicy) { }).Info("call set policy") server.setPolicyByConfig(peer, peer.conf.ApplyPolicy) } + return nil } func (server *BgpServer) checkNeighborRequest(grpcReq *GrpcRequest) (*Peer, error) { |