Skip to content

Commit

Permalink
Implement next AS resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Herms committed Jan 15, 2021
1 parent 2c2db9f commit 4b5e4e7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.14

require (
github.com/ClickHouse/clickhouse-go v1.4.1
github.com/bio-routing/bio-rd v0.0.3-pre4
github.com/bio-routing/bio-rd v0.0.3-pre5
github.com/bio-routing/tflow2 v0.0.0-20200122091514-89924193643e
github.com/gogo/protobuf v1.3.1
github.com/pkg/errors v0.9.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ github.com/bio-routing/bio-rd v0.0.3-pre2 h1:Ho7ytp/sVp3Bh9SsFd1wn/IMwygwAkTRNkO
github.com/bio-routing/bio-rd v0.0.3-pre2/go.mod h1:Dm2pV+USySIWrQ13pjU0+KxXwiKPGdiigDv2fM+RcDs=
github.com/bio-routing/bio-rd v0.0.3-pre4 h1:Q3zvIBhT2V63p3/KTFpB1hShDD/9Ej0iWSC6xY9+6ks=
github.com/bio-routing/bio-rd v0.0.3-pre4/go.mod h1:Dm2pV+USySIWrQ13pjU0+KxXwiKPGdiigDv2fM+RcDs=
github.com/bio-routing/bio-rd v0.0.3-pre5 h1:DT9DmIf+tpU0++Y5/hz8Nx9Ly0X2NdaMlpjpLek/cDI=
github.com/bio-routing/bio-rd v0.0.3-pre5/go.mod h1:Dm2pV+USySIWrQ13pjU0+KxXwiKPGdiigDv2fM+RcDs=
github.com/bio-routing/tflow2 v0.0.0-20181230153523-2e308a4a3c3a/go.mod h1:tjzJ5IykdbWNs1FjmiJWsH6SRBl+aWgxO5I44DAegIw=
github.com/bio-routing/tflow2 v0.0.0-20200122091514-89924193643e h1:Zh5s5mFKBG1dwDLJU1fsPoFxTmixabOhqEuKrOkrKLM=
github.com/bio-routing/tflow2 v0.0.0-20200122091514-89924193643e/go.mod h1:4E2F/ExVEOHe9VF0fqQP60HTCWCMOWV4PyB8R/HndPU=
Expand Down
23 changes: 22 additions & 1 deletion pkg/clickhousegw/clickhousegw.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,28 @@ func (c *ClickHouseGateway) InsertFlows(flows []*flow.Flow) error {
return errors.Wrap(err, "Begin failed")
}

stmt, err := tx.Prepare("INSERT INTO flows (agent, int_in, int_out, src_ip_addr, dst_ip_addr, src_ip_pfx_addr, src_ip_pfx_len, dst_ip_pfx_addr, dst_ip_pfx_len, nexthop, next_asn, src_asn, dst_asn, ip_protocol, src_port, dst_port, timestamp, size, packets, samplerate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
stmt, err := tx.Prepare(`INSERT INTO flows (
agent,
int_in,
int_out,
src_ip_addr,
dst_ip_addr,
src_ip_pfx_addr,
src_ip_pfx_len,
dst_ip_pfx_addr,
dst_ip_pfx_len,
nexthop,
next_asn,
src_asn,
dst_asn,
ip_protocol,
src_port,
dst_port,
timestamp,
size,
packets,
samplerate
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ?, ?, ?)`)
if err != nil {
return errors.Wrap(err, "Prepare failed")
}
Expand Down
15 changes: 12 additions & 3 deletions pkg/ipannotator/ipannotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ func (ipa *IPAnnotator) Annotate(fl *flow.Flow) error {
}

fl.DstPfx = *drt.Prefix()
dstFirstASPathSeg := drt.BestPath().BGPPath.ASPath.GetLastSequenceSegment()
if dstFirstASPathSeg != nil {
dstASN := dstFirstASPathSeg.GetLastASN()
dstLastASPathSeg := drt.BestPath().BGPPath.ASPath.GetLastSequenceSegment()
if dstLastASPathSeg != nil {
dstASN := dstLastASPathSeg.GetLastASN()
if dstASN != nil {
fl.DstAs = *dstASN
}
}

dstFirstASPathSeg := drt.BestPath().BGPPath.ASPath.GetFirstSequenceSegment()
if dstFirstASPathSeg != nil {
nextASN := dstFirstASPathSeg.GetFirstASN()
if nextASN != nil {
fl.NextAs = *nextASN
}
}

return nil
}
1 change: 0 additions & 1 deletion pkg/routemirror/route_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,5 @@ func (r *RouteMirror) LPM(rtrAddr string, vrfRD uint64, addr bnet.IP) (*route.Ro
return nil, nil
}

// TODO: Check if PathSelection() in bio is wrong. Best route is apparently last element. Should be first...
return routes[len(routes)-1], nil
}

0 comments on commit 4b5e4e7

Please sign in to comment.