-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/pfxdedup' of github.com:bio-routing/bio-rd into fix…
…/pfxdedup
- Loading branch information
Showing
13 changed files
with
234 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
Cedric Kienzler | ||
Christoph Petrausch | ||
Daniel Czerwonk | ||
Maximilian Wilhelm | ||
Oliver Herms | ||
Serge Bazanski |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# List of RFCs bio routing implements | ||
|
||
Please keep this list ordered. | ||
|
||
* 1997 BGP Communities Attribute | ||
* 4271 A Border Gateway Protocol 4 (BGP-4) | ||
* 4456 BGP Route Reflection | ||
* 4760 Multiprotocol Extensions for BGP-4 | ||
* 6793 32bit ASNs | ||
* 7911 BGP AddPath | ||
* 7947 BGP Route Server | ||
* 8092 BGP Large Communities Attribute | ||
* 8212 Default External BGP (EBGP) Route Propagation Behavior without Policies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"runtime/pprof" | ||
"time" | ||
|
||
bnet "github.com/bio-routing/bio-rd/net" | ||
) | ||
|
||
func main() { | ||
for i := 0; i < 255; i++ { | ||
for j := 0; j < 255; j++ { | ||
for k := 0; k < 11; k++ { | ||
addr := bnet.IPv4FromOctets(10, uint8(i), uint8(j), uint8(k)) | ||
addr.Dedup() | ||
} | ||
} | ||
} | ||
|
||
buf := bytes.NewBuffer(nil) | ||
err := pprof.StartCPUProfile(buf) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
start := time.Now().UnixNano() | ||
|
||
for x := 0; x < 1; x++ { | ||
for i := 0; i < 255; i++ { | ||
for j := 0; j < 255; j++ { | ||
for k := 0; k < 11; k++ { | ||
addr := bnet.IPv4FromOctets(10, uint8(i), uint8(j), uint8(k)) | ||
addr.Dedup() | ||
} | ||
} | ||
} | ||
} | ||
|
||
end := time.Now().UnixNano() | ||
|
||
d := end - start | ||
pprof.StopCPUProfile() | ||
fmt.Printf("Looking up IP-Addresses took %d ms\n", d/1000000) | ||
|
||
ioutil.WriteFile("profile.pprof", buf.Bytes(), 0644) | ||
|
||
x := bytes.NewBuffer(nil) | ||
pprof.WriteHeapProfile(x) | ||
|
||
ioutil.WriteFile("heap.pprof", x.Bytes(), 0644) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"runtime/pprof" | ||
"time" | ||
|
||
bnet "github.com/bio-routing/bio-rd/net" | ||
) | ||
|
||
func main() { | ||
pfxs := make([]*bnet.Prefix, 0) | ||
for i := 0; i < 255; i++ { | ||
for j := 0; j < 255; j++ { | ||
for k := 0; k < 11; k++ { | ||
addr := bnet.IPv4FromOctets(uint8(k)+1, uint8(i), uint8(j), 0) | ||
addr.Dedup() | ||
|
||
pfxs = append(pfxs, bnet.NewPfx(addr, 24).Dedup()) | ||
} | ||
} | ||
} | ||
|
||
buf := bytes.NewBuffer(nil) | ||
err := pprof.StartCPUProfile(buf) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
start := time.Now().UnixNano() | ||
|
||
for i := range pfxs { | ||
pfxs[i].Dedup() | ||
} | ||
|
||
end := time.Now().UnixNano() | ||
|
||
d := end - start | ||
pprof.StopCPUProfile() | ||
fmt.Printf("Looking up Prefixes took %d ms\n", d/1000000) | ||
|
||
ioutil.WriteFile("profile.pprof", buf.Bytes(), 0644) | ||
|
||
x := bytes.NewBuffer(nil) | ||
pprof.WriteHeapProfile(x) | ||
|
||
ioutil.WriteFile("heap.pprof", x.Bytes(), 0644) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package net | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIPCache(t *testing.T) { | ||
a := &IP{ | ||
higher: 100, | ||
lower: 200, | ||
isLegacy: false, | ||
} | ||
b := &IP{ | ||
higher: 100, | ||
lower: 200, | ||
isLegacy: false, | ||
} | ||
|
||
x := a.Dedup() | ||
y := b.Dedup() | ||
|
||
assert.Equal(t, true, x == y) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPrefixCache(t *testing.T) { | ||
a := &Prefix{ | ||
addr: &IP{ | ||
higher: 100, | ||
lower: 200, | ||
isLegacy: false, | ||
}, | ||
pfxlen: 64, | ||
} | ||
b := &Prefix{ | ||
addr: &IP{ | ||
higher: 100, | ||
lower: 200, | ||
isLegacy: false, | ||
}, | ||
pfxlen: 64, | ||
} | ||
|
||
a.addr = a.addr.Dedup() | ||
b.addr = b.addr.Dedup() | ||
|
||
x := a.Dedup() | ||
y := b.Dedup() | ||
|
||
assert.Equal(t, true, x == y) | ||
} |