summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/mrt.go12
-rw-r--r--server/server.go23
2 files changed, 32 insertions, 3 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
}
diff --git a/server/server.go b/server/server.go
index c0ac7c7c..81950c91 100644
--- a/server/server.go
+++ b/server/server.go
@@ -2417,6 +2417,7 @@ type watchOptions struct {
initUpdate bool
initPostUpdate bool
initPeerState bool
+ tableName string
}
type WatchOption func(*watchOptions)
@@ -2454,6 +2455,12 @@ func WatchPeerState(current bool) WatchOption {
}
}
+func WatchTableName(name string) WatchOption {
+ return func(o *watchOptions) {
+ o.tableName = name
+ }
+}
+
type Watcher struct {
opts watchOptions
realCh chan WatchEvent
@@ -2480,11 +2487,25 @@ func (w *Watcher) Generate(t WatchEventType) (err error) {
}
w.notify(&WatchEventAdjIn{PathList: clonePathList(pathList)})
case WATCH_EVENT_TYPE_TABLE:
+ id := table.GLOBAL_RIB_NAME
+ if len(w.opts.tableName) > 0 {
+ peer, ok := w.s.neighborMap[w.opts.tableName]
+ if !ok {
+ err = fmt.Errorf("Neighbor that has %v doesn't exist.", w.opts.tableName)
+ break
+ }
+ if !peer.isRouteServerClient() {
+ err = fmt.Errorf("Neighbor %v doesn't have local rib", w.opts.tableName)
+ return
+ }
+ id = peer.ID()
+ }
+
pathList := func() map[string][]*table.Path {
pathList := make(map[string][]*table.Path)
for _, t := range w.s.globalRib.Tables {
for _, dst := range t.GetSortedDestinations() {
- if paths := dst.GetKnownPathList(table.GLOBAL_RIB_NAME); len(paths) > 0 {
+ if paths := dst.GetKnownPathList(id); len(paths) > 0 {
pathList[dst.GetNlri().String()] = clonePathList(paths)
}
}