diff --git a/route/route_test.go b/route/route_test.go index aece08b7e592a2d4fd6119ba3562e5d15cbf5553..74243fa1a3abbfd29f91dc621174071b69f9383a 100644 --- a/route/route_test.go +++ b/route/route_test.go @@ -5,25 +5,25 @@ import ( "github.com/stretchr/testify/assert" - "github.com/bio-routing/bio-rd/net" + bnet "github.com/bio-routing/bio-rd/net" ) func TestNewRoute(t *testing.T) { tests := []struct { name string - pfx net.Prefix + pfx bnet.Prefix path *Path expected *Route }{ { name: "BGP Path", - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), path: &Path{ Type: BGPPathType, BGPPath: &BGPPath{}, }, expected: &Route{ - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), paths: []*Path{ &Path{ Type: BGPPathType, @@ -34,9 +34,9 @@ func TestNewRoute(t *testing.T) { }, { name: "Empty Path", - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), expected: &Route{ - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), paths: []*Path{}, }, }, @@ -52,14 +52,14 @@ func TestPrefix(t *testing.T) { tests := []struct { name string route *Route - expected net.Prefix + expected bnet.Prefix }{ { name: "Prefix", route: &Route{ - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), }, - expected: net.NewPfx(strAddr("10.0.0.0"), 8), + expected: bnet.NewPfx(strAddr("10.0.0.0"), 8), }, } @@ -78,7 +78,7 @@ func TestAddr(t *testing.T) { { name: "Prefix", route: &Route{ - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), }, expected: 0xa000000, }, @@ -99,7 +99,7 @@ func TestPfxlen(t *testing.T) { { name: "Prefix", route: &Route{ - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), }, expected: 8, }, @@ -120,7 +120,7 @@ func TestAddPath(t *testing.T) { }{ { name: "Regular BGP path", - route: NewRoute(net.NewPfx(strAddr("10.0.0.0"), 8), &Path{ + route: NewRoute(bnet.NewPfx(strAddr("10.0.0.0"), 8), &Path{ Type: BGPPathType, BGPPath: &BGPPath{}, }), @@ -129,7 +129,7 @@ func TestAddPath(t *testing.T) { BGPPath: &BGPPath{}, }, expected: &Route{ - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), paths: []*Path{ { Type: BGPPathType, @@ -144,13 +144,13 @@ func TestAddPath(t *testing.T) { }, { name: "Nil path", - route: NewRoute(net.NewPfx(strAddr("10.0.0.0"), 8), &Path{ + route: NewRoute(bnet.NewPfx(strAddr("10.0.0.0"), 8), &Path{ Type: BGPPathType, BGPPath: &BGPPath{}, }), newPath: nil, expected: &Route{ - pfx: net.NewPfx(strAddr("10.0.0.0"), 8), + pfx: bnet.NewPfx(strAddr("10.0.0.0"), 8), paths: []*Path{ { Type: BGPPathType, @@ -271,7 +271,7 @@ func TestCopy(t *testing.T) { { name: "", route: &Route{ - pfx: net.NewPfx(1000, 8), + pfx: bnet.NewPfx(1000, 8), ecmpPaths: 2, paths: []*Path{ { @@ -280,7 +280,7 @@ func TestCopy(t *testing.T) { }, }, expected: &Route{ - pfx: net.NewPfx(1000, 8), + pfx: bnet.NewPfx(1000, 8), ecmpPaths: 2, paths: []*Path{ { @@ -328,7 +328,7 @@ func TestBestPath(t *testing.T) { { Type: StaticPathType, StaticPath: &StaticPath{ - NextHop: 32, + NextHop: bnet.IPv4(32), }, }, }, @@ -336,7 +336,7 @@ func TestBestPath(t *testing.T) { expected: &Path{ Type: StaticPathType, StaticPath: &StaticPath{ - NextHop: 32, + NextHop: bnet.IPv4(32), }, }, }, @@ -366,13 +366,13 @@ func TestECMPPaths(t *testing.T) { { Type: StaticPathType, StaticPath: &StaticPath{ - NextHop: 32, + NextHop: bnet.IPv4(32), }, }, { Type: StaticPathType, StaticPath: &StaticPath{ - NextHop: 32, + NextHop: bnet.IPv4(32), }, }, }, @@ -381,13 +381,13 @@ func TestECMPPaths(t *testing.T) { { Type: StaticPathType, StaticPath: &StaticPath{ - NextHop: 32, + NextHop: bnet.IPv4(32), }, }, { Type: StaticPathType, StaticPath: &StaticPath{ - NextHop: 32, + NextHop: bnet.IPv4(32), }, }, }, @@ -399,6 +399,6 @@ func TestECMPPaths(t *testing.T) { } func strAddr(s string) uint32 { - ret, _ := net.StrToAddr(s) + ret, _ := bnet.StrToAddr(s) return ret } diff --git a/route/static.go b/route/static.go index 0ab6b26e3dc01c58b756efca28935b2e8e4e9d5a..af2990f25ba164346587bf1b3ebb0dae2011ffea 100644 --- a/route/static.go +++ b/route/static.go @@ -1,8 +1,10 @@ package route +import bnet "github.com/bio-routing/bio-rd/net" + // StaticPath represents a static path of a route type StaticPath struct { - NextHop uint32 + NextHop bnet.IP } func (r *Route) staticPathSelection() { diff --git a/routingtable/locRIB/loc_rib_test.go b/routingtable/locRIB/loc_rib_test.go index ea4d9c6c30e5596f4b0685d92a20b86eb182bf16..beefc93d3b4e69e70be4e52f3508261b02c9cc02 100644 --- a/routingtable/locRIB/loc_rib_test.go +++ b/routingtable/locRIB/loc_rib_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/bio-routing/bio-rd/net" + bnet "github.com/bio-routing/bio-rd/net" "github.com/bio-routing/bio-rd/route" "github.com/stretchr/testify/assert" @@ -38,7 +39,7 @@ func TestContainsPfxPath(t *testing.T) { path: &route.Path{ Type: route.StaticPathType, StaticPath: &route.StaticPath{ - NextHop: 2, + NextHop: bnet.IPv4(2), }, }, }, @@ -57,7 +58,7 @@ func TestContainsPfxPath(t *testing.T) { path: &route.Path{ Type: route.StaticPathType, StaticPath: &route.StaticPath{ - NextHop: 2, + NextHop: bnet.IPv4(2), }, }, }, @@ -67,7 +68,7 @@ func TestContainsPfxPath(t *testing.T) { path: &route.Path{ Type: route.StaticPathType, StaticPath: &route.StaticPath{ - NextHop: 2, + NextHop: bnet.IPv4(2), }, }, }, @@ -91,7 +92,7 @@ func TestLocRIB_RemovePathUnknown(t *testing.T) { &route.Path{ Type: route.StaticPathType, StaticPath: &route.StaticPath{ - NextHop: 2, + NextHop: bnet.IPv4(2), }, })) }