Skip to content

Commit

Permalink
Merge pull request #4 from BelWue/addpath
Browse files Browse the repository at this point in the history
enable AddPath
  • Loading branch information
debugloop authored May 10, 2022
2 parents 381af50 + 400ceaf commit 664808e
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion routeinfo/routeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,18 @@ type Router struct {

func (r *Router) Connect() {
for _, addr := range r.Neighbors {
// determine AFI
var parsed net.IP
if parsed = net.ParseIP(addr); parsed == nil {
var afi api.Family_Afi
if parsed = net.ParseIP(addr); parsed != nil {
} else {
log.Printf("[error] Invalid address: %s", addr)
continue
}
if addr4 := parsed.To4(); addr4 != nil {
afi = api.Family_AFI_IP
} else {
afi = api.Family_AFI_IP6
}

if err := r.GobgpServer.AddPeer(context.Background(), &api.AddPeerRequest{
Expand All @@ -108,6 +117,21 @@ func (r *Router) Connect() {
NeighborAddress: addr,
PeerAsn: r.Asn,
},
// define the AFI manually to enable Add-Paths
AfiSafis: []*api.AfiSafi{&api.AfiSafi{
Config: &api.AfiSafiConfig{
Family: &api.Family{
Afi: afi,
Safi: api.Family_SAFI_UNICAST,
},
Enabled: true,
},
AddPaths: &api.AddPaths{
Config: &api.AddPathsConfig{
Receive: true,
},
},
}},
},
}); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 664808e

Please sign in to comment.