diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 10 | ||||
-rw-r--r-- | server/server.go | 6 | ||||
-rw-r--r-- | server/server_test.go | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/server/peer.go b/server/peer.go index 05018f89..780af50d 100644 --- a/server/peer.go +++ b/server/peer.go @@ -502,7 +502,7 @@ func (peer *Peer) PassConn(conn *net.TCPConn) { } } -func (peer *Peer) ToConfig() *config.Neighbor { +func (peer *Peer) ToConfig(getAdvertised bool) *config.Neighbor { // create copy which can be access to without mutex conf := *peer.fsm.pConf @@ -529,8 +529,12 @@ func (peer *Peer) ToConfig() *config.Neighbor { if peer.fsm.state == bgp.BGP_FSM_ESTABLISHED { rfList := peer.configuredRFlist() - pathList, _ := peer.getBestFromLocal(rfList) - conf.State.AdjTable.Advertised = uint32(len(pathList)) + if getAdvertised { + pathList, _ := peer.getBestFromLocal(rfList) + conf.State.AdjTable.Advertised = uint32(len(pathList)) + } else { + conf.State.AdjTable.Advertised = 0 + } conf.State.AdjTable.Received = uint32(peer.adjRibIn.Count(rfList)) conf.State.AdjTable.Accepted = uint32(peer.adjRibIn.Accepted(rfList)) diff --git a/server/server.go b/server/server.go index aaa69e7d..d18cf641 100644 --- a/server/server.go +++ b/server/server.go @@ -1618,7 +1618,7 @@ func (s *BgpServer) GetServer() (c *config.Global) { return c } -func (s *BgpServer) GetNeighbor() (l []*config.Neighbor) { +func (s *BgpServer) GetNeighbor(getAdvertised bool) (l []*config.Neighbor) { ch := make(chan struct{}) defer func() { <-ch }() @@ -1627,7 +1627,7 @@ func (s *BgpServer) GetNeighbor() (l []*config.Neighbor) { l = make([]*config.Neighbor, 0, len(s.neighborMap)) for _, peer := range s.neighborMap { - l = append(l, peer.ToConfig()) + l = append(l, peer.ToConfig(getAdvertised)) } } return l @@ -2511,7 +2511,7 @@ func (w *Watcher) Generate(t WatchEventType) (err error) { }() l := make([]*config.Neighbor, 0, len(w.s.neighborMap)) for _, peer := range w.s.neighborMap { - l = append(l, peer.ToConfig()) + l = append(l, peer.ToConfig(false)) } w.notify(&WatchEventTable{PathList: pathList, Neighbor: l}) default: diff --git a/server/server_test.go b/server/server_test.go index b9d8263f..46ef4be3 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -107,7 +107,7 @@ func TestMonitor(test *testing.T) { for { time.Sleep(time.Second) - if t.GetNeighbor()[0].State.SessionState == config.SESSION_STATE_ESTABLISHED { + if t.GetNeighbor(false)[0].State.SessionState == config.SESSION_STATE_ESTABLISHED { break } } |