diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-20 00:09:44 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-03-20 00:09:44 +0900 |
commit | 731f4fa3ea2ea58b1dccdb62eb14a407594c81d8 (patch) | |
tree | 4aa29c89ab7824a66475674b0db9377695ebe812 /server/server.go | |
parent | 66ac5a1051267c5d915461a2556ef33e8ac9e670 (diff) |
server: support mrt dump rotation like Quagga
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r-- | server/server.go | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/server/server.go b/server/server.go index 09d3fe31..035675f6 100644 --- a/server/server.go +++ b/server/server.go @@ -1163,19 +1163,23 @@ func (server *BgpServer) SetBmpConfig(c []config.BmpServer) error { return nil } -func (server *BgpServer) SetMrtConfig(c config.Mrt) error { - if c.FileName != "" { - ch := make(chan *GrpcResponse) - server.GrpcReqCh <- &GrpcRequest{ - RequestType: REQ_MOD_MRT, - Data: &api.ModMrtArguments{ - Operation: api.Operation_ADD, - Filename: c.FileName, - }, - ResponseCh: ch, - } - if err := (<-ch).Err(); err != nil { - return err +func (server *BgpServer) SetMrtConfig(c []config.Mrt) error { + for _, s := range c { + if s.FileName != "" { + ch := make(chan *GrpcResponse) + server.GrpcReqCh <- &GrpcRequest{ + RequestType: REQ_MOD_MRT, + Data: &api.ModMrtArguments{ + Operation: api.Operation_ADD, + DumpType: int32(s.DumpType.ToInt()), + Filename: s.FileName, + Interval: s.Interval, + }, + ResponseCh: ch, + } + if err := (<-ch).Err(); err != nil { + return err + } } } return nil @@ -2857,7 +2861,11 @@ func (server *BgpServer) handleModMrt(grpcReq *GrpcRequest) { } switch arg.Operation { case api.Operation_ADD: - w, err := newMrtWatcher(arg.Filename) + if arg.Interval != 0 && arg.Interval < 30 { + log.Info("minimum mrt dump interval is 30 seconds") + arg.Interval = 30 + } + w, err := newMrtWatcher(arg.DumpType, arg.Filename, arg.Interval) if err == nil { server.watchers[WATCHER_MRT] = w } @@ -2866,11 +2874,6 @@ func (server *BgpServer) handleModMrt(grpcReq *GrpcRequest) { delete(server.watchers, WATCHER_MRT) w.stop() grpcDone(grpcReq, nil) - case api.Operation_REPLACE: - go func() { - err := w.restart(arg.Filename) - grpcDone(grpcReq, err) - }() } } |