From 70fae5c8cc6c8f9e96f2b0f143a71cca551725bc Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 17 Jan 2016 09:26:56 -0800 Subject: rpki: add reason to rpki monitor api tells a reason why notificaiton was sent, withdraw, peer down, and others Signed-off-by: FUJITA Tomonori --- server/server.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'server/server.go') diff --git a/server/server.go b/server/server.go index 2853dc1e..3471ee7e 100644 --- a/server/server.go +++ b/server/server.go @@ -564,7 +564,7 @@ func (server *BgpServer) dropPeerAllRoutes(peer *Peer) []*SenderMsg { for _, rf := range peer.configuredRFlist() { dsts := server.globalRib.DeletePathsByPeer(peer.fsm.peerInfo, rf) - server.validatePaths(dsts) + server.validatePaths(dsts, true) if peer.isRouteServerClient() { pathList := make([]*table.Path, len(dsts)) for _, targetPeer := range server.neighborMap { @@ -773,14 +773,19 @@ func (server *BgpServer) isRpkiMonitored() bool { return false } -func (server *BgpServer) validatePaths(dsts []*table.Destination) { +func (server *BgpServer) validatePaths(dsts []*table.Destination, peerDown bool) { isMonitor := server.isRpkiMonitored() for _, dst := range dsts { if isMonitor { rrList := make([]*api.ROAResult, 0, len(dst.WithdrawnList)) for _, path := range dst.WithdrawnList { if path.Validation() == config.RPKI_VALIDATION_RESULT_TYPE_INVALID { + reason := api.ROAResult_WITHDRAW + if peerDown { + reason = api.ROAResult_PEER_DOWN + } rr := &api.ROAResult{ + Reason: reason, Address: path.GetSource().Address.String(), Timestamp: path.GetTimestamp().Unix(), OriginAs: path.GetSourceAs(), @@ -838,7 +843,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([] moded = append(moded, server.RSimportPaths(targetPeer, pathList)...) } dsts := rib.ProcessPaths(append(pathList, moded...)) - server.validatePaths(dsts) + server.validatePaths(dsts, false) for _, targetPeer := range server.neighborMap { if !targetPeer.isRouteServerClient() || targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED { continue @@ -861,7 +866,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) ([] } alteredPathList = pathList dsts := rib.ProcessPaths(pathList) - server.validatePaths(dsts) + server.validatePaths(dsts, false) sendPathList := make([]*table.Path, 0, len(dsts)) for _, dst := range dsts { path := dst.NewFeed(table.GLOBAL_RIB_NAME) -- cgit v1.2.3