mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
outlet/routing: switch to GoBGP v4
This commit is contained in:
5
go.mod
5
go.mod
@@ -37,7 +37,8 @@ require (
|
||||
github.com/openconfig/gnmic/pkg/api v0.1.9
|
||||
github.com/opencontainers/image-spec v1.1.1
|
||||
github.com/oschwald/maxminddb-golang/v2 v2.0.0
|
||||
github.com/osrg/gobgp/v3 v3.37.0
|
||||
github.com/osrg/gobgp/v4 v4.0.0
|
||||
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10
|
||||
github.com/prometheus/client_golang v1.23.2
|
||||
github.com/rs/zerolog v1.34.0
|
||||
github.com/scrapli/scrapligo v1.3.3
|
||||
@@ -146,13 +147,11 @@ require (
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/openconfig/grpctunnel v0.1.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/osrg/gobgp/v4 v4.0.0 // indirect
|
||||
github.com/pascaldekloe/name v1.0.1 // indirect
|
||||
github.com/paulmach/orb v0.11.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.22 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/prometheus/client_model v0.6.2 // indirect
|
||||
|
||||
11
go.sum
11
go.sum
@@ -157,9 +157,8 @@ github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
|
||||
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
|
||||
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
@@ -236,8 +235,6 @@ github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFr
|
||||
github.com/jellydator/ttlcache/v2 v2.11.1 h1:AZGME43Eh2Vv3giG6GeqeLeFXxwxn1/qHItqWZl6U64=
|
||||
github.com/jellydator/ttlcache/v2 v2.11.1/go.mod h1:RtE5Snf0/57e+2cLWFYWCCsLas2Hy3c5Z4n14XmSvTI=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
|
||||
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
|
||||
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
|
||||
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
|
||||
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
|
||||
@@ -339,8 +336,6 @@ github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJw
|
||||
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
|
||||
github.com/oschwald/maxminddb-golang/v2 v2.0.0 h1:Gyljxck1kHbBxDgLM++NfDWBqvu1pWWfT8XbosSo0bo=
|
||||
github.com/oschwald/maxminddb-golang/v2 v2.0.0/go.mod h1:gG4V88LsawPEqtbL1Veh1WRh+nVSYwXzJ1P5Fcn77g0=
|
||||
github.com/osrg/gobgp/v3 v3.37.0 h1:+ObuOdvj7G7nxrT0fKFta+EAupdWf/q1WzbXydr8IOY=
|
||||
github.com/osrg/gobgp/v3 v3.37.0/go.mod h1:kVHVFy1/fyZHJ8P32+ctvPeJogn9qKwa1YCeMRXXrP0=
|
||||
github.com/osrg/gobgp/v4 v4.0.0 h1:DCL7iWUAPgL/DDBp1FSdkayQ0ptYYkucpuMkre+HGaI=
|
||||
github.com/osrg/gobgp/v4 v4.0.0/go.mod h1:1a0YiXMuyRPqcCX+fkXZ2UUtcOnUxAWynFunUOSZepk=
|
||||
github.com/pascaldekloe/name v1.0.1 h1:9lnXOHeqeHHnWLbKfH6X98+4+ETVqFqxN09UXSjcMb0=
|
||||
@@ -455,9 +450,8 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
|
||||
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
|
||||
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
|
||||
github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||
@@ -577,7 +571,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
bnet "github.com/bio-routing/bio-rd/net"
|
||||
rpb "github.com/bio-routing/bio-rd/route/api"
|
||||
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
bnet "github.com/bio-routing/bio-rd/net"
|
||||
"github.com/bio-routing/bio-rd/protocols/bgp/server"
|
||||
rpb "github.com/bio-routing/bio-rd/route/api"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/reflection"
|
||||
|
||||
@@ -9,8 +9,10 @@ import (
|
||||
"net/netip"
|
||||
"time"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bmp"
|
||||
"akvorado/common/helpers"
|
||||
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bmp"
|
||||
)
|
||||
|
||||
// peerKey is the key used to identify a peer
|
||||
@@ -32,14 +34,13 @@ type peerInfo struct {
|
||||
|
||||
// peerKeyFromBMPPeerHeader computes the peer key from the BMP peer header.
|
||||
func peerKeyFromBMPPeerHeader(exporter netip.AddrPort, header *bmp.BMPPeerHeader) peerKey {
|
||||
peer, _ := netip.AddrFromSlice(header.PeerAddress.To16())
|
||||
return peerKey{
|
||||
exporter: exporter,
|
||||
ip: peer,
|
||||
ip: header.PeerAddress,
|
||||
ptype: header.PeerType,
|
||||
distinguisher: RD(header.PeerDistinguisher),
|
||||
asn: header.PeerAS,
|
||||
bgpID: binary.BigEndian.Uint32(header.PeerBGPID.To4()),
|
||||
bgpID: binary.BigEndian.Uint32(header.PeerBGPID.AsSlice()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +179,7 @@ func (p *Provider) handlePeerUpNotification(pkey peerKey, body *bmp.BMPPeerUpNot
|
||||
}
|
||||
|
||||
// Check for ADD-PATH support.
|
||||
receivedAddPath := map[bgp.RouteFamily]bgp.BGPAddPathMode{}
|
||||
receivedAddPath := map[bgp.Family]bgp.BGPAddPathMode{}
|
||||
received, _ := body.ReceivedOpenMsg.Body.(*bgp.BGPOpen)
|
||||
for _, param := range received.OptParams {
|
||||
switch param := param.(type) {
|
||||
@@ -187,14 +188,14 @@ func (p *Provider) handlePeerUpNotification(pkey peerKey, body *bmp.BMPPeerUpNot
|
||||
switch capability := capability.(type) {
|
||||
case *bgp.CapAddPath:
|
||||
for _, tuple := range capability.Tuples {
|
||||
receivedAddPath[tuple.RouteFamily] = tuple.Mode
|
||||
receivedAddPath[tuple.Family] = tuple.Mode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sent, _ := body.SentOpenMsg.Body.(*bgp.BGPOpen)
|
||||
addPathOption := map[bgp.RouteFamily]bgp.BGPAddPathMode{}
|
||||
addPathOption := map[bgp.Family]bgp.BGPAddPathMode{}
|
||||
for _, param := range sent.OptParams {
|
||||
switch param := param.(type) {
|
||||
case *bgp.OptionParameterCapability:
|
||||
@@ -202,11 +203,11 @@ func (p *Provider) handlePeerUpNotification(pkey peerKey, body *bmp.BMPPeerUpNot
|
||||
switch capability := capability.(type) {
|
||||
case *bgp.CapAddPath:
|
||||
for _, sent := range capability.Tuples {
|
||||
receivedMode := receivedAddPath[sent.RouteFamily]
|
||||
receivedMode := receivedAddPath[sent.Family]
|
||||
if receivedMode == bgp.BGP_ADD_PATH_BOTH || receivedMode == bgp.BGP_ADD_PATH_SEND {
|
||||
if sent.Mode == bgp.BGP_ADD_PATH_BOTH || sent.Mode == bgp.BGP_ADD_PATH_RECEIVE {
|
||||
// We have at least the receive mode. We only do decoding.
|
||||
addPathOption[sent.RouteFamily] = bgp.BGP_ADD_PATH_RECEIVE
|
||||
addPathOption[sent.Family] = bgp.BGP_ADD_PATH_RECEIVE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +257,7 @@ func (p *Provider) handleRouteMonitoring(pkey peerKey, body *bmp.BMPRouteMonitor
|
||||
for _, attr := range update.PathAttributes {
|
||||
switch attr := attr.(type) {
|
||||
case *bgp.PathAttributeNextHop:
|
||||
nh, _ = netip.AddrFromSlice(attr.Value.To16())
|
||||
nh = helpers.AddrTo6(attr.Value)
|
||||
case *bgp.PathAttributeAsPath:
|
||||
if p.config.CollectASNs || p.config.CollectASPaths {
|
||||
rta.asPath = asPathFlat(attr)
|
||||
@@ -292,40 +293,37 @@ func (p *Provider) handleRouteMonitoring(pkey peerKey, body *bmp.BMPRouteMonitor
|
||||
|
||||
// Regular NLRI and withdrawn routes
|
||||
if pkey.ptype == bmp.BMP_PEER_TYPE_L3VPN || p.isAcceptedRD(0) {
|
||||
// We know we have IPv4 NLRI
|
||||
for _, ipprefix := range update.NLRI {
|
||||
prefix := ipprefix.Prefix
|
||||
plen := int(ipprefix.Length)
|
||||
if prefix.To4() != nil {
|
||||
prefix = prefix.To16()
|
||||
plen += 96
|
||||
v4UCPrefix, ok := ipprefix.NLRI.(*bgp.IPAddrPrefix)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
pf, _ := netip.AddrFromSlice(prefix)
|
||||
added += p.rib.AddPrefix(netip.PrefixFrom(pf, plen), route{
|
||||
pfx := helpers.PrefixTo6(v4UCPrefix.Prefix)
|
||||
added += p.rib.AddPrefix(pfx, route{
|
||||
peer: pinfo.reference,
|
||||
nlri: p.rib.nlris.Put(nlri{
|
||||
family: bgp.RF_IPv4_UC,
|
||||
path: ipprefix.PathIdentifier(),
|
||||
path: ipprefix.ID,
|
||||
rd: pkey.distinguisher,
|
||||
}),
|
||||
nextHop: p.rib.nextHops.Put(nextHop(nh)),
|
||||
attributes: p.rib.rtas.Put(rta),
|
||||
prefixLen: uint8(plen),
|
||||
prefixLen: uint8(pfx.Bits()),
|
||||
})
|
||||
}
|
||||
for _, ipprefix := range update.WithdrawnRoutes {
|
||||
prefix := ipprefix.Prefix
|
||||
plen := int(ipprefix.Length)
|
||||
if prefix.To4() != nil {
|
||||
prefix = prefix.To16()
|
||||
plen += 96
|
||||
v4UCPrefix, ok := ipprefix.NLRI.(*bgp.IPAddrPrefix)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
pf, _ := netip.AddrFromSlice(prefix)
|
||||
pfx := helpers.PrefixTo6(v4UCPrefix.Prefix)
|
||||
if nlriRef, ok := p.rib.nlris.Ref(nlri{
|
||||
family: bgp.RF_IPv4_UC,
|
||||
path: ipprefix.PathIdentifier(),
|
||||
path: ipprefix.ID,
|
||||
rd: pkey.distinguisher,
|
||||
}); ok {
|
||||
removed += p.rib.RemovePrefix(netip.PrefixFrom(pf, plen), route{
|
||||
removed += p.rib.RemovePrefix(pfx, route{
|
||||
peer: pinfo.reference,
|
||||
nlri: nlriRef,
|
||||
})
|
||||
@@ -335,58 +333,38 @@ func (p *Provider) handleRouteMonitoring(pkey peerKey, body *bmp.BMPRouteMonitor
|
||||
|
||||
// MP reach and unreach NLRI
|
||||
for _, attr := range update.PathAttributes {
|
||||
var pf netip.Addr
|
||||
var plen int
|
||||
var rd RD
|
||||
var ipprefixes []bgp.AddrPrefixInterface
|
||||
var ipprefixes []bgp.PathNLRI
|
||||
var family bgp.Family
|
||||
switch attr := attr.(type) {
|
||||
case *bgp.PathAttributeMpReachNLRI:
|
||||
nh, _ = netip.AddrFromSlice(attr.Nexthop.To16())
|
||||
nh = helpers.AddrTo6(attr.Nexthop)
|
||||
ipprefixes = attr.Value
|
||||
family = bgp.NewFamily(attr.AFI, attr.SAFI)
|
||||
case *bgp.PathAttributeMpUnreachNLRI:
|
||||
ipprefixes = attr.Value
|
||||
family = bgp.NewFamily(attr.AFI, attr.SAFI)
|
||||
}
|
||||
for _, ipprefix := range ipprefixes {
|
||||
switch ipprefix := ipprefix.(type) {
|
||||
var pfx netip.Prefix
|
||||
var rd RD
|
||||
switch nlri := ipprefix.NLRI.(type) {
|
||||
case *bgp.IPAddrPrefix:
|
||||
pf, _ = netip.AddrFromSlice(ipprefix.Prefix.To16())
|
||||
plen = int(ipprefix.Length + 96)
|
||||
rd = pkey.distinguisher
|
||||
case *bgp.IPv6AddrPrefix:
|
||||
pf, _ = netip.AddrFromSlice(ipprefix.Prefix.To16())
|
||||
plen = int(ipprefix.Length)
|
||||
pfx = helpers.PrefixTo6(nlri.Prefix)
|
||||
rd = pkey.distinguisher
|
||||
case *bgp.LabeledIPAddrPrefix:
|
||||
pf, _ = netip.AddrFromSlice(ipprefix.Prefix.To16())
|
||||
plen = int(ipprefix.IPPrefixLen() + 96)
|
||||
rd = pkey.distinguisher
|
||||
case *bgp.LabeledIPv6AddrPrefix:
|
||||
pf, _ = netip.AddrFromSlice(ipprefix.Prefix.To16())
|
||||
plen = int(ipprefix.IPPrefixLen())
|
||||
pfx = helpers.PrefixTo6(nlri.Prefix)
|
||||
rd = pkey.distinguisher
|
||||
case *bgp.LabeledVPNIPAddrPrefix:
|
||||
pf, _ = netip.AddrFromSlice(ipprefix.Prefix.To16())
|
||||
plen = int(ipprefix.IPPrefixLen() + 96)
|
||||
rd = RDFromRouteDistinguisherInterface(ipprefix.RD)
|
||||
case *bgp.LabeledVPNIPv6AddrPrefix:
|
||||
pf, _ = netip.AddrFromSlice(ipprefix.Prefix.To16())
|
||||
plen = int(ipprefix.IPPrefixLen())
|
||||
rd = RDFromRouteDistinguisherInterface(ipprefix.RD)
|
||||
pfx = helpers.PrefixTo6(nlri.Prefix)
|
||||
rd = RDFromRouteDistinguisherInterface(nlri.RD)
|
||||
case *bgp.EVPNNLRI:
|
||||
switch route := ipprefix.RouteTypeData.(type) {
|
||||
switch route := nlri.RouteTypeData.(type) {
|
||||
case *bgp.EVPNIPPrefixRoute:
|
||||
prefix := route.IPPrefix
|
||||
plen = int(route.IPPrefixLength)
|
||||
if prefix.To4() != nil {
|
||||
prefix = prefix.To16()
|
||||
plen += 96
|
||||
}
|
||||
pf, _ = netip.AddrFromSlice(prefix.To16())
|
||||
pfx = helpers.PrefixTo6(netip.PrefixFrom(route.IPPrefix, int(route.IPPrefixLength)))
|
||||
rd = RDFromRouteDistinguisherInterface(route.RD)
|
||||
}
|
||||
default:
|
||||
p.metrics.ignoredNlri.WithLabelValues(exporterStr,
|
||||
bgp.AfiSafiToRouteFamily(ipprefix.AFI(), ipprefix.SAFI()).String()).Inc()
|
||||
p.metrics.ignoredNlri.WithLabelValues(exporterStr, family.String()).Inc()
|
||||
continue
|
||||
}
|
||||
if pkey.ptype != bmp.BMP_PEER_TYPE_L3VPN && !p.isAcceptedRD(rd) {
|
||||
@@ -394,24 +372,24 @@ func (p *Provider) handleRouteMonitoring(pkey peerKey, body *bmp.BMPRouteMonitor
|
||||
}
|
||||
switch attr.(type) {
|
||||
case *bgp.PathAttributeMpReachNLRI:
|
||||
added += p.rib.AddPrefix(netip.PrefixFrom(pf, plen), route{
|
||||
added += p.rib.AddPrefix(pfx, route{
|
||||
peer: pinfo.reference,
|
||||
nlri: p.rib.nlris.Put(nlri{
|
||||
family: bgp.AfiSafiToRouteFamily(ipprefix.AFI(), ipprefix.SAFI()),
|
||||
family: family,
|
||||
rd: rd,
|
||||
path: ipprefix.PathIdentifier(),
|
||||
path: ipprefix.ID,
|
||||
}),
|
||||
nextHop: p.rib.nextHops.Put(nextHop(nh)),
|
||||
attributes: p.rib.rtas.Put(rta),
|
||||
prefixLen: uint8(plen),
|
||||
prefixLen: uint8(pfx.Bits()),
|
||||
})
|
||||
case *bgp.PathAttributeMpUnreachNLRI:
|
||||
if nlriRef, ok := p.rib.nlris.Ref(nlri{
|
||||
family: bgp.AfiSafiToRouteFamily(ipprefix.AFI(), ipprefix.SAFI()),
|
||||
family: family,
|
||||
rd: rd,
|
||||
path: ipprefix.PathIdentifier(),
|
||||
path: ipprefix.ID,
|
||||
}); ok {
|
||||
removed += p.rib.RemovePrefix(netip.PrefixFrom(pf, plen), route{
|
||||
removed += p.rib.RemovePrefix(pfx, route{
|
||||
peer: pinfo.reference,
|
||||
nlri: nlriRef,
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"akvorado/common/helpers"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
var asPathCache [][]uint32
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
// RD defines a route distinguisher.
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
package bmp_test
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"testing"
|
||||
|
||||
"akvorado/common/helpers"
|
||||
"akvorado/outlet/routing/provider/bmp"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
func TestParseRouteDistinguisher(t *testing.T) {
|
||||
@@ -70,7 +71,13 @@ func TestRDFromRouteDistinguisherInterface(t *testing.T) {
|
||||
{bgp.NewRouteDistinguisherFourOctetAS(100, 200), "2:100:200"},
|
||||
{bgp.NewRouteDistinguisherFourOctetAS(66000, 200), "66000:200"},
|
||||
{bgp.NewRouteDistinguisherTwoOctetAS(120, 200), "120:200"},
|
||||
{bgp.NewRouteDistinguisherIPAddressAS("2.2.2.2", 30), "2.2.2.2:30"},
|
||||
{func() bgp.RouteDistinguisherInterface {
|
||||
rd, err := bgp.NewRouteDistinguisherIPAddressAS(netip.MustParseAddr("2.2.2.2"), 30)
|
||||
if err != nil {
|
||||
t.Fatalf("bgp.NewRouteDistinguisherIPAddressAS() error:\n%+v", err)
|
||||
}
|
||||
return rd
|
||||
}(), "2.2.2.2:30"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
got := bmp.RDFromRouteDistinguisherInterface(tc.input).String()
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"akvorado/common/helpers/intern"
|
||||
|
||||
"github.com/gaissmai/bart"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
// prefixIndex is a typed index for prefixes in the RIB
|
||||
@@ -49,7 +49,7 @@ type route struct {
|
||||
// nlri is the NLRI for the route (when combined with prefix). The
|
||||
// route family is included as we may normalize NLRI accross AFI/SAFI.
|
||||
type nlri struct {
|
||||
family bgp.RouteFamily
|
||||
family bgp.Family
|
||||
path uint32
|
||||
rd RD
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"akvorado/common/helpers"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
func TestLargeCommunitiesAlign(t *testing.T) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"akvorado/common/reporter"
|
||||
"akvorado/outlet/routing/provider"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
func TestBMP(t *testing.T) {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"net/netip"
|
||||
"time"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bmp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bmp"
|
||||
)
|
||||
|
||||
// serveConnection handle the connection from an exporter.
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
|
||||
"github.com/benbjohnson/clock"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bmp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bmp"
|
||||
)
|
||||
|
||||
// NewMock creates a new mock provider for BMP (it's a real one
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
package bmp
|
||||
|
||||
import "github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
import "github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
|
||||
// asPathFlat transforms an AS path to a flat AS path: first value of
|
||||
// a set is used, confed seq is considered as a regular seq.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"akvorado/common/helpers"
|
||||
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
func TestASPathFlat(t *testing.T) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"akvorado/common/reporter"
|
||||
|
||||
"github.com/benbjohnson/clock"
|
||||
"github.com/osrg/gobgp/v3/pkg/packet/bgp"
|
||||
"github.com/osrg/gobgp/v4/pkg/packet/bgp"
|
||||
)
|
||||
|
||||
// LookupResult is the result of the Lookup() function.
|
||||
|
||||
Reference in New Issue
Block a user