summaryrefslogtreecommitdiffhomepage
path: root/server/mrt.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-08-15 09:24:49 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-08-15 09:24:49 +0900
commit2c12fa2b92c3372d8639e84be6ee89a9ab581158 (patch)
tree22de5e752ecb359f319d790bb838eee91123e315 /server/mrt.go
parentcdca8b5ceffd12ff702903e3369f3cafff2787ae (diff)
mrt: support per-peer table dump with route server configuration
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/mrt.go')
-rw-r--r--server/mrt.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/server/mrt.go b/server/mrt.go
index 605d6fe0..b92ce293 100644
--- a/server/mrt.go
+++ b/server/mrt.go
@@ -32,6 +32,7 @@ type mrtWriter struct {
dead chan struct{}
s *BgpServer
filename string
+ tablename string
file *os.File
rotationInterval uint64
dumpInterval uint64
@@ -48,6 +49,9 @@ func (m *mrtWriter) loop() error {
case config.MRT_TYPE_UPDATES:
ops = append(ops, WatchUpdate(false))
case config.MRT_TYPE_TABLE:
+ if len(m.tablename) > 0 {
+ ops = append(ops, WatchTableName(m.tablename))
+ }
}
w := m.s.Watch(ops...)
rotator := func() *time.Ticker {
@@ -258,7 +262,7 @@ func mrtFileOpen(filename string, interval uint64) (*os.File, error) {
return file, err
}
-func newMrtWriter(s *BgpServer, dumpType config.MrtType, filename string, rInterval, dInterval uint64) (*mrtWriter, error) {
+func newMrtWriter(s *BgpServer, dumpType config.MrtType, filename, tablename string, rInterval, dInterval uint64) (*mrtWriter, error) {
file, err := mrtFileOpen(filename, rInterval)
if err != nil {
return nil, err
@@ -268,6 +272,7 @@ func newMrtWriter(s *BgpServer, dumpType config.MrtType, filename string, rInter
s: s,
filename: filename,
file: file,
+ tablename: tablename,
rotationInterval: rInterval,
dumpInterval: dInterval,
}
@@ -298,9 +303,12 @@ func (m *mrtManager) enable(c *config.MrtConfig) error {
}
} else if c.DumpType == config.MRT_TYPE_UPDATES {
dInterval = 0
+ if len(c.TableName) > 0 {
+ return fmt.Errorf("can't specify the table name with the update dump type")
+ }
}
- w, err := newMrtWriter(m.bgpServer, c.DumpType, c.FileName, rInterval, dInterval)
+ w, err := newMrtWriter(m.bgpServer, c.DumpType, c.FileName, c.TableName, rInterval, dInterval)
if err == nil {
m.writer[c.FileName] = w
}