deduplicate extended communities
This commit is contained in:
parent
afc402f3cc
commit
2b7efe725f
@ -1,7 +1,6 @@
|
||||
package pools
|
||||
|
||||
import (
|
||||
"log"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
@ -60,10 +59,6 @@ func (p *CommunitiesPool) AcquireExt(communities []api.ExtCommunity) []api.ExtCo
|
||||
// Make identification list
|
||||
ids := make([]int, len(communities))
|
||||
for i, comm := range communities {
|
||||
if len(comm) != 3 {
|
||||
log.Println("ERROR: malformed ext. bgp community:", comm)
|
||||
continue
|
||||
}
|
||||
r := 0 // RO
|
||||
if comm[0].(string) == "rt" {
|
||||
r = 1
|
||||
|
@ -259,7 +259,7 @@ func parseRouteBgpInfo(data interface{}) *api.BGPInfo {
|
||||
LocalPref: localPref,
|
||||
Med: med,
|
||||
Communities: pools.Communities.Acquire(communities),
|
||||
ExtCommunities: extCommunities,
|
||||
ExtCommunities: pools.ExtCommunities.AcquireExt(extCommunities),
|
||||
LargeCommunities: pools.LargeCommunities.Acquire(largeCommunities),
|
||||
}
|
||||
return bgp
|
||||
@ -300,10 +300,12 @@ func parseExtBgpCommunities(data interface{}) []api.ExtCommunity {
|
||||
log.Println("Ignoring malformed ext community:", cdata)
|
||||
continue
|
||||
}
|
||||
val1, _ := strconv.Atoi(cdata[1].(string))
|
||||
val2, _ := strconv.Atoi(cdata[2].(string))
|
||||
communities = append(communities, api.ExtCommunity{
|
||||
cdata[0],
|
||||
cdata[1],
|
||||
cdata[2],
|
||||
val1,
|
||||
val2,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,7 @@ func (gobgp *GoBGP) parsePathIntoRoute(
|
||||
|
||||
route.BGP.AsPath = pools.ASPaths.Acquire(route.BGP.AsPath)
|
||||
route.BGP.Communities = pools.Communities.Acquire(route.BGP.Communities)
|
||||
route.BGP.ExtCommunities = pools.ExtCommunities.AcquireExt(route.BGP.ExtCommunities)
|
||||
route.BGP.LargeCommunities = pools.LargeCommunities.Acquire(route.BGP.LargeCommunities)
|
||||
|
||||
route.Metric = (route.BGP.LocalPref + route.BGP.Med)
|
||||
|
@ -184,7 +184,7 @@ func decodeRoute(details map[string]interface{}) (*api.Route, error) {
|
||||
AsPath: pools.ASPaths.Acquire(asPath),
|
||||
NextHop: pools.Gateways4.Acquire(trueNextHop),
|
||||
Communities: pools.Communities.Acquire(communities),
|
||||
ExtCommunities: extendedCommunities,
|
||||
ExtCommunities: pools.ExtCommunities.AcquireExt(extendedCommunities),
|
||||
LargeCommunities: pools.LargeCommunities.Acquire(largeCommunities),
|
||||
LocalPref: localPref,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user