summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-10-18 15:06:33 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-10-20 10:33:10 +0900
commita88e0b5592b5f344981983d91f4f55a6d3f002bf (patch)
tree2fb183724091e4c1b2e2e6b70179821ea9c4b0fe /server/server.go
parent7cb50ce1cfdf959a74dad516ef65a6c6c34aaec8 (diff)
api: support statement modification via grpc
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index e25d314f..69c27f14 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1650,6 +1650,12 @@ func (server *BgpServer) handleGrpc(grpcReq *GrpcRequest) []*SenderMsg {
}
}
close(grpcReq.ResponseCh)
+ case REQ_MOD_STATEMENT:
+ err := server.handleGrpcModStatement(grpcReq)
+ grpcReq.ResponseCh <- &GrpcResponse{
+ ResponseErr: err,
+ }
+ close(grpcReq.ResponseCh)
case REQ_POLICY_ROUTEPOLICY, REQ_POLICY_ROUTEPOLICIES:
info := server.policy.PolicyMap
typ := grpcReq.RequestType
@@ -1783,6 +1789,36 @@ func (server *BgpServer) handleGrpcGetStatement(grpcReq *GrpcRequest) error {
return nil
}
+func (server *BgpServer) handleGrpcModStatement(grpcReq *GrpcRequest) error {
+ arg := grpcReq.Data.(*api.ModStatementArguments)
+ s, err := table.NewStatementFromApiStruct(arg.Statement, server.policy.DefinedSetMap)
+ if err != nil {
+ return err
+ }
+ m := server.policy.StatementMap
+ name := s.Name
+ d, ok := m[name]
+ switch arg.Operation {
+ case api.Operation_ADD:
+ if ok {
+ err = d.Add(s)
+ } else {
+ m[name] = s
+ }
+ case api.Operation_DEL:
+ err = d.Remove(s)
+ case api.Operation_DEL_ALL:
+ if server.policy.StatementInUse(d) {
+ return fmt.Errorf("can't delete. statement %s is in use", name)
+ }
+ delete(m, name)
+ case api.Operation_REPLACE:
+ err = d.Replace(s)
+ }
+ return err
+
+}
+
func (server *BgpServer) handleMrt(grpcReq *GrpcRequest) {
now := uint32(time.Now().Unix())
view := ""