summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-11-18 13:44:14 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-11-18 14:00:51 +0900
commite11b09d7eae851d777a06ee18fde7865a361f5bb (patch)
treef33fd973aadabd3cb6ead949f0c8e3fadb481c20 /server
parent93d1dca70aa0ae3b34050d24ad7462b8757213bf (diff)
server: disable advertised number calculation with multiple neighbors
AdjRibOut isn't in memory so needs to be calculated on the fly. Doing such for multiple neighbors consumes too much CPU (especially there are lots of routes). Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/peer.go10
-rw-r--r--server/server.go6
-rw-r--r--server/server_test.go2
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
}
}