summaryrefslogtreecommitdiffhomepage
path: root/pkg/server/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/server/server.go')
-rw-r--r--pkg/server/server.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/pkg/server/server.go b/pkg/server/server.go
index 274f7177..ee58585f 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -3689,9 +3689,9 @@ func (s *BgpServer) MonitorTable(ctx context.Context, r *api.MonitorTableRequest
return s.watch(watchBestPath(r.Current)), nil
case api.TableType_ADJ_IN:
if r.PostPolicy {
- return s.watch(watchPostUpdate(r.Current)), nil
+ return s.watch(watchPostUpdate(r.Current, r.Name)), nil
}
- return s.watch(watchUpdate(r.Current)), nil
+ return s.watch(watchUpdate(r.Current, r.Name)), nil
default:
return nil, fmt.Errorf("unsupported resource type: %v", r.TableType)
}
@@ -3731,6 +3731,9 @@ func (s *BgpServer) MonitorTable(ctx context.Context, r *api.MonitorTableRequest
if path == nil || (r.Family != nil && family != path.GetRouteFamily()) {
continue
}
+ if len(r.Name) > 0 && r.Name != path.GetSource().Address.String() {
+ continue
+ }
select {
case <-ctx.Done():
return
@@ -3879,6 +3882,7 @@ type watchOptions struct {
initPeerState bool
tableName string
recvMessage bool
+ peerAddress string
}
type watchOption func(*watchOptions)
@@ -3892,21 +3896,23 @@ func watchBestPath(current bool) watchOption {
}
}
-func watchUpdate(current bool) watchOption {
+func watchUpdate(current bool, peerAddress string) watchOption {
return func(o *watchOptions) {
o.preUpdate = true
if current {
o.initUpdate = true
}
+ o.peerAddress = peerAddress
}
}
-func watchPostUpdate(current bool) watchOption {
+func watchPostUpdate(current bool, peerAddress string) watchOption {
return func(o *watchOptions) {
o.postUpdate = true
if current {
o.initPostUpdate = true
}
+ o.peerAddress = peerAddress
}
}
@@ -4088,10 +4094,14 @@ func (s *BgpServer) watch(opts ...watchOption) (w *watcher) {
for _, peer := range s.neighborMap {
peer.fsm.lock.RLock()
notEstablished := peer.fsm.state != bgp.BGP_FSM_ESTABLISHED
+ peerAddress := peer.fsm.peerInfo.Address.String()
peer.fsm.lock.RUnlock()
if notEstablished {
continue
}
+ if len(w.opts.peerAddress) > 0 && w.opts.peerAddress != peerAddress {
+ continue
+ }
configNeighbor := w.s.toConfig(peer, false)
for _, rf := range peer.configuredRFlist() {
peer.fsm.lock.RLock()
@@ -4146,9 +4156,13 @@ func (s *BgpServer) watch(opts ...watchOption) (w *watcher) {
for peerInfo, paths := range pathsByPeer {
// create copy which can be access to without mutex
var configNeighbor *config.Neighbor
- if peer, ok := s.neighborMap[peerInfo.Address.String()]; ok {
+ peerAddress := peerInfo.Address.String()
+ if peer, ok := s.neighborMap[peerAddress]; ok {
configNeighbor = w.s.toConfig(peer, false)
}
+ if w.opts.peerAddress != "" && w.opts.peerAddress != peerAddress {
+ continue
+ }
w.notify(&watchEventUpdate{
PeerAS: peerInfo.AS,