From fd1ccf16c69f9f5b395df7dd85eac97a60098c4a Mon Sep 17 00:00:00 2001 From: pberndro <p.berndroth@philuweb.de> Date: Sun, 24 Jun 2018 13:25:05 +0200 Subject: [PATCH] remove log for performance reasons and add count function for routes in LocRIB --- main.go | 2 +- protocols/bgp/server/update_helper.go | 1 - routingtable/adjRIBOut/adj_rib_out.go | 2 -- routingtable/locRIB/loc_rib.go | 8 ++++++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 22cba26f..7220ba4a 100644 --- a/main.go +++ b/main.go @@ -79,7 +79,7 @@ func main() { go func() { for { - fmt.Print(rib.Print()) + fmt.Printf("LocRIB count: %d\n", rib.Count()) time.Sleep(time.Second * 10) } }() diff --git a/protocols/bgp/server/update_helper.go b/protocols/bgp/server/update_helper.go index 34f784a1..e0a24a6e 100644 --- a/protocols/bgp/server/update_helper.go +++ b/protocols/bgp/server/update_helper.go @@ -82,7 +82,6 @@ func serializeAndSendUpdate(out io.Writer, update serializeAbleUpdate) error { return nil } - fmt.Printf("Sending Update: %v\n", updateBytes) _, err = out.Write(updateBytes) if err != nil { return fmt.Errorf("Failed sending Update: %v", err) diff --git a/routingtable/adjRIBOut/adj_rib_out.go b/routingtable/adjRIBOut/adj_rib_out.go index b667ac77..19b44b8b 100644 --- a/routingtable/adjRIBOut/adj_rib_out.go +++ b/routingtable/adjRIBOut/adj_rib_out.go @@ -72,12 +72,10 @@ func (a *AdjRIBOut) AddPath(pfx bnet.Prefix, p *route.Path) error { a.removePathsFromClients(pfx, oldPaths) } - fmt.Printf("Adding path: %s\n", p.Print()) pathID, err := a.pathIDManager.addPath(p) if err != nil { return fmt.Errorf("Unable to get path ID: %v", err) } - fmt.Printf("New path ID: %d\n", pathID) p.BGPPath.PathIdentifier = pathID a.rt.AddPath(pfx, p) diff --git a/routingtable/locRIB/loc_rib.go b/routingtable/locRIB/loc_rib.go index ff5750c3..fd8fd072 100644 --- a/routingtable/locRIB/loc_rib.go +++ b/routingtable/locRIB/loc_rib.go @@ -27,6 +27,14 @@ func New() *LocRIB { return a } +//Count routes from the LocRIP +func (a *LocRIB) Count() uint64 { + a.mu.RLock() + defer a.mu.RUnlock() + + return uint64(len(a.rt.Dump())) +} + // UpdateNewClient sends current state to a new client func (a *LocRIB) UpdateNewClient(client routingtable.RouteTableClient) error { a.mu.RLock() -- GitLab