Skip to content
Snippets Groups Projects
Unverified Commit 27fb65a6 authored by Christoph Petrausch's avatar Christoph Petrausch Committed by GitHub
Browse files

Merge pull request #254 from bio-routing/fix/dedup_mem

Make BGP path dedup optional. Set init cache size = 0.
parents 35380602 64cc1c4d
No related branches found
No related tags found
No related merge requests found
...@@ -106,7 +106,7 @@ func showRouteReceiveBGP(parts []string) { ...@@ -106,7 +106,7 @@ func showRouteReceiveBGP(parts []string) {
return return
} }
rr := route.RouteFromProtoRoute(r) rr := route.RouteFromProtoRoute(r, false)
fmt.Println(rr.Print()) fmt.Println(rr.Print())
} }
......
...@@ -8,6 +8,6 @@ import ( ...@@ -8,6 +8,6 @@ import (
) )
func printRoute(ar *api.Route) { func printRoute(ar *api.Route) {
r := route.RouteFromProtoRoute(ar) r := route.RouteFromProtoRoute(ar, false)
fmt.Println(r.Print()) fmt.Println(r.Print())
} }
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
) )
const ( const (
ipCachePreAlloc = 1500000 ipCachePreAlloc = 0
) )
var ( var (
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
) )
const ( const (
prefixCachePreAlloc = 1500000 prefixCachePreAlloc = 0
) )
var ( var (
......
...@@ -108,7 +108,7 @@ func (b *BGPPath) ToProto() *api.BGPPath { ...@@ -108,7 +108,7 @@ func (b *BGPPath) ToProto() *api.BGPPath {
} }
// BGPPathFromProtoBGPPath converts a proto BGPPath to BGPPath // BGPPathFromProtoBGPPath converts a proto BGPPath to BGPPath
func BGPPathFromProtoBGPPath(pb *api.BGPPath) *BGPPath { func BGPPathFromProtoBGPPath(pb *api.BGPPath, dedup bool) *BGPPath {
p := &BGPPath{ p := &BGPPath{
BGPPathA: &BGPPathA{ BGPPathA: &BGPPathA{
NextHop: bnet.IPFromProtoIP(*pb.NextHop), NextHop: bnet.IPFromProtoIP(*pb.NextHop),
...@@ -124,7 +124,9 @@ func BGPPathFromProtoBGPPath(pb *api.BGPPath) *BGPPath { ...@@ -124,7 +124,9 @@ func BGPPathFromProtoBGPPath(pb *api.BGPPath) *BGPPath {
ASPath: types.ASPathFromProtoASPath(pb.AsPath), ASPath: types.ASPathFromProtoASPath(pb.AsPath),
} }
p = p.Dedup() if dedup {
p = p.Dedup()
}
communities := make(types.Communities, len(pb.Communities)) communities := make(types.Communities, len(pb.Communities))
p.Communities = &communities p.Communities = &communities
......
...@@ -100,7 +100,7 @@ func TestBGPPathFromProtoBGPPath(t *testing.T) { ...@@ -100,7 +100,7 @@ func TestBGPPathFromProtoBGPPath(t *testing.T) {
ClusterList: &types.ClusterList{999, 199}, ClusterList: &types.ClusterList{999, 199},
} }
result := BGPPathFromProtoBGPPath(input) result := BGPPathFromProtoBGPPath(input, false)
assert.Equal(t, expected, result) assert.Equal(t, expected, result)
} }
......
...@@ -267,7 +267,7 @@ func (r *Route) ToProto() *api.Route { ...@@ -267,7 +267,7 @@ func (r *Route) ToProto() *api.Route {
} }
// RouteFromProtoRoute converts a proto Route to a Route // RouteFromProtoRoute converts a proto Route to a Route
func RouteFromProtoRoute(ar *api.Route) *Route { func RouteFromProtoRoute(ar *api.Route, dedup bool) *Route {
r := &Route{ r := &Route{
pfx: net.NewPrefixFromProtoPrefix(*ar.Pfx), pfx: net.NewPrefixFromProtoPrefix(*ar.Pfx),
paths: make([]*Path, 0, len(ar.Paths)), paths: make([]*Path, 0, len(ar.Paths)),
...@@ -278,7 +278,7 @@ func RouteFromProtoRoute(ar *api.Route) *Route { ...@@ -278,7 +278,7 @@ func RouteFromProtoRoute(ar *api.Route) *Route {
switch ar.Paths[i].Type { switch ar.Paths[i].Type {
case api.Path_BGP: case api.Path_BGP:
p.Type = BGPPathType p.Type = BGPPathType
p.BGPPath = BGPPathFromProtoBGPPath(ar.Paths[i].BgpPath) p.BGPPath = BGPPathFromProtoBGPPath(ar.Paths[i].BgpPath, dedup)
} }
r.paths = append(r.paths, p) r.paths = append(r.paths, p)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment