summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/rpki.go6
-rw-r--r--server/server.go8
-rw-r--r--server/zclient.go2
-rw-r--r--server/zclient_test.go8
-rw-r--r--table/destination.go30
-rw-r--r--table/message.go48
-rw-r--r--table/path.go344
-rw-r--r--table/path_test.go22
-rw-r--r--table/policy.go2
-rw-r--r--table/table.go6
-rw-r--r--table/table_manager_test.go212
11 files changed, 377 insertions, 311 deletions
diff --git a/server/rpki.go b/server/rpki.go
index e6097d00..ed4af2ea 100644
--- a/server/rpki.go
+++ b/server/rpki.go
@@ -453,7 +453,7 @@ func (c *roaManager) validate(pathList []*table.Path, isMonitor bool) []*api.ROA
}
if tree, ok := c.roas[path.GetRouteFamily()]; ok {
r, roaList := validatePath(c.AS, tree, path.GetNlri().String(), path.GetAsPath())
- if isMonitor && path.Validation != config.RpkiValidationResultType(r) {
+ if isMonitor && path.Validation() != config.RpkiValidationResultType(r) {
apiRoaList := func() []*api.ROA {
apiRoaList := make([]*api.ROA, 0)
for _, r := range roaList {
@@ -464,13 +464,13 @@ func (c *roaManager) validate(pathList []*table.Path, isMonitor bool) []*api.ROA
rr := &api.ROAResult{
OriginAs: path.GetSourceAs(),
Prefix: path.GetNlri().String(),
- OldResult: api.ROAResult_ValidationResult(path.Validation.ToInt()),
+ OldResult: api.ROAResult_ValidationResult(path.Validation().ToInt()),
NewResult: api.ROAResult_ValidationResult(r.ToInt()),
Roas: apiRoaList,
}
results = append(results, rr)
}
- path.Validation = config.RpkiValidationResultType(r)
+ path.SetValidation(config.RpkiValidationResultType(r))
}
}
return results
diff --git a/server/server.go b/server/server.go
index 817c7d05..4a198e49 100644
--- a/server/server.go
+++ b/server/server.go
@@ -556,7 +556,7 @@ func filterpath(peer *Peer, path *table.Path) *table.Path {
if !peer.isRouteServerClient() && isASLoop(peer, path) {
return nil
}
- return path.Clone(net.ParseIP(remoteAddr), path.IsWithdraw)
+ return path.Clone(peer.fsm.peerInfo.Address, path.IsWithdraw)
}
func (server *BgpServer) dropPeerAllRoutes(peer *Peer) []*SenderMsg {
@@ -643,7 +643,7 @@ func (server *BgpServer) broadcastValidationResults(results []*api.ROAResult) {
func (server *BgpServer) broadcastBests(bests []*table.Path) {
for _, path := range bests {
- if !path.IsFromZebra {
+ if !path.IsFromZebra() {
z := newBroadcastZapiBestMsg(server.zclient, path)
if z != nil {
server.broadcastMsgs = append(server.broadcastMsgs, z)
@@ -1268,7 +1268,7 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest) []*table.Pat
path := func() *table.Path {
for _, rf := range server.globalRib.GetRFlist() {
for _, path := range server.globalRib.GetPathList(table.GLOBAL_RIB_NAME, rf) {
- if len(path.Uuid) > 0 && bytes.Equal(path.Uuid, arg.Uuid) {
+ if len(path.UUID()) > 0 && bytes.Equal(path.UUID(), arg.Uuid) {
return path
}
}
@@ -1289,7 +1289,7 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest) []*table.Pat
if err == nil {
u := uuid.NewV4()
uuidBytes = u.Bytes()
- paths[0].Uuid = uuidBytes
+ paths[0].SetUUID(uuidBytes)
}
}
}
diff --git a/server/zclient.go b/server/zclient.go
index 994f1c78..3c3d3180 100644
--- a/server/zclient.go
+++ b/server/zclient.go
@@ -128,7 +128,7 @@ func createPathFromIPRouteMessage(m *zebra.Message, peerInfo *table.PeerInfo) *t
pattr = append(pattr, med)
p := table.NewPath(peerInfo, nlri, isWithdraw, pattr, time.Now(), false)
- p.IsFromZebra = true
+ p.SetIsFromZebra(true)
return p
}
diff --git a/server/zclient_test.go b/server/zclient_test.go
index dcb3cb5c..2fbd7554 100644
--- a/server/zclient_test.go
+++ b/server/zclient_test.go
@@ -59,7 +59,7 @@ func Test_createPathFromIPRouteMessage(t *testing.T) {
assert.NotEqual(nil, p)
assert.Equal("0.0.0.0", p.GetNexthop().String())
assert.Equal("192.168.100.0/24", p.GetNlri().String())
- assert.True(p.IsFromZebra)
+ assert.True(p.IsFromZebra())
assert.False(p.IsWithdraw)
// withdraw
@@ -71,7 +71,7 @@ func Test_createPathFromIPRouteMessage(t *testing.T) {
assert.Equal("192.168.100.0/24", p.GetNlri().String())
med, _ := p.GetMed()
assert.Equal(uint32(100), med)
- assert.True(p.IsFromZebra)
+ assert.True(p.IsFromZebra())
assert.True(p.IsWithdraw)
// IPv6
@@ -88,7 +88,7 @@ func Test_createPathFromIPRouteMessage(t *testing.T) {
assert.Equal("2001:db8:0:f101::/64", p.GetNlri().String())
med, _ = p.GetMed()
assert.Equal(uint32(100), med)
- assert.True(p.IsFromZebra)
+ assert.True(p.IsFromZebra())
assert.False(p.IsWithdraw)
// withdraw
@@ -98,7 +98,7 @@ func Test_createPathFromIPRouteMessage(t *testing.T) {
assert.NotEqual(nil, p)
assert.Equal("::", p.GetNexthop().String())
assert.Equal("2001:db8:0:f101::/64", p.GetNlri().String())
- assert.True(p.IsFromZebra)
+ assert.True(p.IsFromZebra())
assert.True(p.IsWithdraw)
}
diff --git a/table/destination.go b/table/destination.go
index 2577e7cb..d6f1f1de 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -141,7 +141,7 @@ func (dd *Destination) ToApiStruct(id string) *api.Destination {
ret := make([]*api.Path, 0, len(arg))
first := true
for _, p := range arg {
- if p.filtered[id] == POLICY_DIRECTION_NONE {
+ if p.Filtered(id) == POLICY_DIRECTION_NONE {
pp := p.ToApiStruct(id)
if first {
pp.Best = true
@@ -181,7 +181,7 @@ func (dd *Destination) setNlri(nlri bgp.AddrPrefixInterface) {
func (dd *Destination) GetKnownPathList(id string) []*Path {
list := make([]*Path, 0, len(dd.knownPathList))
for _, p := range dd.knownPathList {
- if p.filtered[id] == POLICY_DIRECTION_NONE {
+ if p.Filtered(id) == POLICY_DIRECTION_NONE {
list = append(list, p)
}
}
@@ -190,7 +190,7 @@ func (dd *Destination) GetKnownPathList(id string) []*Path {
func (dd *Destination) GetBestPath(id string) *Path {
for _, p := range dd.knownPathList {
- if p.filtered[id] == POLICY_DIRECTION_NONE {
+ if p.Filtered(id) == POLICY_DIRECTION_NONE {
return p
}
}
@@ -199,7 +199,7 @@ func (dd *Destination) GetBestPath(id string) *Path {
func (dd *Destination) oldBest(id string) *Path {
for _, p := range dd.oldKnownPathList {
- if p.filtered[id] == POLICY_DIRECTION_NONE {
+ if p.Filtered(id) == POLICY_DIRECTION_NONE {
return p
}
}
@@ -357,7 +357,7 @@ func (dest *Destination) implicitWithdraw() {
for _, path := range dest.knownPathList {
found := false
for _, newPath := range dest.newPathList {
- if newPath.NoImplicitWithdraw {
+ if newPath.NoImplicitWithdraw() {
continue
}
// Here we just check if source is same and not check if path
@@ -540,8 +540,8 @@ func compareByLocalPref(path1, path2 *Path) *Path {
//
// # Default local-pref values is 100
log.Debugf("enter compareByLocalPref")
- _, attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
- _, attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
+ attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
+ attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
if attribute1 == nil || attribute2 == nil {
return nil
@@ -591,8 +591,8 @@ func compareByASPath(path1, path2 *Path) *Path {
// Shortest as-path length is preferred. If both path have same lengths,
// we return None.
log.Debugf("enter compareByASPath")
- _, attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
- _, attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
if attribute1 == nil || attribute2 == nil {
log.WithFields(log.Fields{
@@ -622,8 +622,8 @@ func compareByOrigin(path1, path2 *Path) *Path {
// IGP is preferred over EGP; EGP is preferred over Incomplete.
// If both paths have same origin, we return None.
log.Debugf("enter compareByOrigin")
- _, attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
- _, attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attribute1 := path1.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attribute2 := path2.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
if attribute1 == nil || attribute2 == nil {
log.WithFields(log.Fields{
@@ -660,7 +660,7 @@ func compareByMED(path1, path2 *Path) *Path {
// like bgp always-compare-med
log.Debugf("enter compareByMED")
getMed := func(path *Path) uint32 {
- _, attribute := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attribute := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
if attribute == nil {
return 0
}
@@ -687,7 +687,7 @@ func compareByASNumber(path1, path2 *Path) *Path {
//peers, return None.
log.Debugf("enter compareByASNumber")
- log.Debugf("compareByASNumber -- p1Asn: %d, p2Asn: %d", path1.source.AS, path2.source.AS)
+ log.Debugf("compareByASNumber -- p1Asn: %d, p2Asn: %d", path1.GetSource().AS, path2.GetSource().AS)
// If one path is from ibgp peer and another is from ebgp peer, take the ebgp path
if path1.IsIBGP() != path2.IsIBGP() {
if path1.IsIBGP() {
@@ -734,8 +734,8 @@ func compareByRouterID(path1, path2 *Path) (*Path, error) {
}
// At least one path is not coming from NC, so we get local bgp id.
- id1 := binary.BigEndian.Uint32(path1.source.ID)
- id2 := binary.BigEndian.Uint32(path2.source.ID)
+ id1 := binary.BigEndian.Uint32(path1.GetSource().ID)
+ id2 := binary.BigEndian.Uint32(path2.GetSource().ID)
// If both router ids are same/equal we cannot decide.
// This case is possible since router ids are arbitrary.
diff --git a/table/message.go b/table/message.go
index ecd1610c..02cdaf3b 100644
--- a/table/message.go
+++ b/table/message.go
@@ -198,12 +198,6 @@ func UpdatePathAttrs4ByteAs(msg *bgp.BGPUpdate) error {
return nil
}
-func cloneAttrSlice(attrs []bgp.PathAttributeInterface) []bgp.PathAttributeInterface {
- clonedAttrs := make([]bgp.PathAttributeInterface, 0)
- clonedAttrs = append(clonedAttrs, attrs...)
- return clonedAttrs
-}
-
func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
rf := path.GetRouteFamily()
@@ -229,37 +223,47 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
} else {
if path.IsWithdraw {
if msg != nil {
- idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI)
u := msg.Body.(*bgp.BGPUpdate)
- unreach := u.PathAttributes[idx].(*bgp.PathAttributeMpUnreachNLRI)
- unreach.Value = append(unreach.Value, path.GetNlri())
+ for _, p := range u.PathAttributes {
+ if p.GetType() == bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI {
+ unreach := p.(*bgp.PathAttributeMpUnreachNLRI)
+ unreach.Value = append(unreach.Value, path.GetNlri())
+ }
+ }
} else {
- clonedAttrs := cloneAttrSlice(path.GetPathAttrs())
- idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ var nlris []bgp.AddrPrefixInterface
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
if attr == nil {
// for bmp post-policy
- idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI)
- reach := attr.(*bgp.PathAttributeMpUnreachNLRI)
- clonedAttrs[idx] = bgp.NewPathAttributeMpUnreachNLRI(reach.Value)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI)
+ nlris = attr.(*bgp.PathAttributeMpUnreachNLRI).Value
} else {
- reach := attr.(*bgp.PathAttributeMpReachNLRI)
- clonedAttrs[idx] = bgp.NewPathAttributeMpUnreachNLRI(reach.Value)
+ nlris = attr.(*bgp.PathAttributeMpReachNLRI).Value
+ }
+
+ clonedAttrs := path.GetPathAttrs()
+ for i, a := range clonedAttrs {
+ if a.GetType() == bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI || a.GetType() == bgp.BGP_ATTR_TYPE_MP_REACH_NLRI {
+ clonedAttrs[i] = bgp.NewPathAttributeMpUnreachNLRI(nlris)
+ break
+ }
}
return bgp.NewBGPUpdateMessage(nil, clonedAttrs, nil)
}
} else {
if msg != nil {
- idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
u := msg.Body.(*bgp.BGPUpdate)
- reachAttr := u.PathAttributes[idx].(*bgp.PathAttributeMpReachNLRI)
- u.PathAttributes[idx] = bgp.NewPathAttributeMpReachNLRI(reachAttr.Nexthop.String(),
- append(reachAttr.Value, path.GetNlri()))
+ for _, p := range u.PathAttributes {
+ if p.GetType() == bgp.BGP_ATTR_TYPE_MP_REACH_NLRI {
+ reach := p.(*bgp.PathAttributeMpReachNLRI)
+ reach.Value = append(reach.Value, path.GetNlri())
+ }
+ }
} else {
// we don't need to clone here but we
// might merge path to this message in
// the future so let's clone anyway.
- clonedAttrs := cloneAttrSlice(path.GetPathAttrs())
- return bgp.NewBGPUpdateMessage(nil, clonedAttrs, nil)
+ return bgp.NewBGPUpdateMessage(nil, path.GetPathAttrs(), nil)
}
}
}
diff --git a/table/path.go b/table/path.go
index fc9380a7..c647a7cc 100644
--- a/table/path.go
+++ b/table/path.go
@@ -28,20 +28,44 @@ import (
"time"
)
-type Path struct {
- source *PeerInfo
- IsWithdraw bool
+type Bitmap []uint64
+
+func (b Bitmap) Flag(i uint) {
+ b[i/64] |= 1 << uint(i%64)
+}
+
+func (b Bitmap) Unflag(i uint) {
+ b[i/64] &^= 1 << uint(i%64)
+}
+
+func (b Bitmap) GetFlag(i uint) bool {
+ return b[i/64]&(1<<uint(i%64)) > 0
+}
+
+func NewBitmap(size int) Bitmap {
+ return Bitmap(make([]uint64, size/64+1))
+}
+
+type originInfo struct {
nlri bgp.AddrPrefixInterface
- pathAttrs []bgp.PathAttributeInterface
+ source *PeerInfo
timestamp time.Time
- NoImplicitWithdraw bool
- Validation config.RpkiValidationResultType
- IsFromZebra bool
- Owner net.IP
- reason BestPathReason
- filtered map[string]PolicyDirection
+ noImplicitWithdraw bool
+ validation config.RpkiValidationResultType
+ isFromZebra bool
key string
- Uuid []byte
+ uuid []byte
+}
+
+type Path struct {
+ info *originInfo
+ IsWithdraw bool
+ pathAttrs []bgp.PathAttributeInterface
+ Owner net.IP
+ reason BestPathReason
+ parent *Path
+ dels []bgp.BGPAttrType
+ filtered map[string]PolicyDirection
}
func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool) *Path {
@@ -60,14 +84,16 @@ func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pa
}
return &Path{
- source: source,
- IsWithdraw: isWithdraw,
- nlri: nlri,
- pathAttrs: pattrs,
- timestamp: timestamp,
- NoImplicitWithdraw: noImplicitWithdraw,
- Owner: owner,
- filtered: make(map[string]PolicyDirection),
+ info: &originInfo{
+ nlri: nlri,
+ source: source,
+ timestamp: timestamp,
+ noImplicitWithdraw: noImplicitWithdraw,
+ },
+ IsWithdraw: isWithdraw,
+ pathAttrs: pattrs,
+ Owner: owner,
+ filtered: make(map[string]PolicyDirection),
}
}
@@ -97,15 +123,13 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
path.PrependAsn(global.Config.As, 1)
// MED Handling
- idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
- if idx >= 0 && !path.IsLocal() {
- path.pathAttrs = append(path.pathAttrs[:idx], path.pathAttrs[idx+1:]...)
+ if med := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC); med != nil && !path.IsLocal() {
+ path.delPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
}
// remove local-pref attribute
- idx, _ = path.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
- if idx >= 0 && !config.IsConfederationMember(global, peer) {
- path.pathAttrs = append(path.pathAttrs[:idx], path.pathAttrs[idx+1:]...)
+ if pref := path.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF); pref != nil && !config.IsConfederationMember(global, peer) {
+ path.delPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
}
} else if peer.Config.PeerType == config.PEER_TYPE_INTERNAL {
@@ -121,47 +145,38 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
// AS_PATH handling for iBGP
// if the path has AS_PATH path attribute, don't modify it.
// if not, attach *empty* AS_PATH path attribute.
- idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
- if idx < 0 {
+ if nh := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); nh == nil {
path.PrependAsn(0, 0)
}
// For iBGP peers we are required to send local-pref attribute
// for connected or local prefixes.
// We set default local-pref 100.
- p := bgp.NewPathAttributeLocalPref(100)
- idx, _ = path.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
- if idx < 0 {
- path.pathAttrs = append(path.pathAttrs, p)
- } else if !path.IsLocal() {
- path.pathAttrs[idx] = p
+ if pref := path.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF); pref == nil || !path.IsLocal() {
+ path.setPathAttr(bgp.NewPathAttributeLocalPref(100))
}
// RFC4456: BGP Route Reflection
// 8. Avoiding Routing Information Loops
- info := path.source
+ info := path.GetSource()
if peer.RouteReflector.Config.RouteReflectorClient {
// This attribute will carry the BGP Identifier of the originator of the route in the local AS.
// A BGP speaker SHOULD NOT create an ORIGINATOR_ID attribute if one already exists.
- idx, _ = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGINATOR_ID)
- if idx < 0 {
- p := bgp.NewPathAttributeOriginatorId(info.ID.String())
- path.pathAttrs = append(path.pathAttrs, p)
+ if path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGINATOR_ID) == nil {
+ path.setPathAttr(bgp.NewPathAttributeOriginatorId(info.ID.String()))
}
// When an RR reflects a route, it MUST prepend the local CLUSTER_ID to the CLUSTER_LIST.
// If the CLUSTER_LIST is empty, it MUST create a new one.
- idx, _ = path.getPathAttr(bgp.BGP_ATTR_TYPE_CLUSTER_LIST)
id := string(peer.RouteReflector.Config.RouteReflectorClusterId)
- if idx < 0 {
- p := bgp.NewPathAttributeClusterList([]string{id})
- path.pathAttrs = append(path.pathAttrs, p)
+ if p := path.getPathAttr(bgp.BGP_ATTR_TYPE_CLUSTER_LIST); p == nil {
+ path.setPathAttr(bgp.NewPathAttributeClusterList([]string{id}))
} else {
- p := path.pathAttrs[idx].(*bgp.PathAttributeClusterList)
- newClusterList := make([]string, 0, len(p.Value))
- for _, ip := range p.Value {
+ clusterList := p.(*bgp.PathAttributeClusterList)
+ newClusterList := make([]string, 0, len(clusterList.Value))
+ for _, ip := range clusterList.Value {
newClusterList = append(newClusterList, ip.String())
}
- path.pathAttrs[idx] = bgp.NewPathAttributeClusterList(append([]string{id}, newClusterList...))
+ path.setPathAttr(bgp.NewPathAttributeClusterList(append([]string{id}, newClusterList...)))
}
}
@@ -174,19 +189,19 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
}
func (path *Path) GetTimestamp() time.Time {
- return path.timestamp
+ return path.OriginInfo().timestamp
}
func (path *Path) setTimestamp(t time.Time) {
- path.timestamp = t
+ path.OriginInfo().timestamp = t
}
func (path *Path) IsLocal() bool {
- return path.source.Address == nil
+ return path.GetSource().Address == nil
}
func (path *Path) IsIBGP() bool {
- return path.source.AS == path.source.LocalAS
+ return path.GetSource().AS == path.GetSource().LocalAS
}
func (path *Path) ToApiStruct(id string) *api.Path {
@@ -204,9 +219,9 @@ func (path *Path) ToApiStruct(id string) *api.Path {
return &api.Path{
Nlri: n,
Pattrs: pattrs,
- Age: int64(time.Now().Sub(path.timestamp).Seconds()),
+ Age: int64(time.Now().Sub(path.OriginInfo().timestamp).Seconds()),
IsWithdraw: path.IsWithdraw,
- Validation: int32(path.Validation.ToInt()),
+ Validation: int32(path.OriginInfo().validation.ToInt()),
Filtered: path.Filtered(id) > POLICY_DIRECTION_NONE,
Family: family,
}
@@ -214,18 +229,54 @@ func (path *Path) ToApiStruct(id string) *api.Path {
// create new PathAttributes
func (path *Path) Clone(owner net.IP, isWithdraw bool) *Path {
- newPathAttrs := make([]bgp.PathAttributeInterface, len(path.pathAttrs))
- for i, v := range path.pathAttrs {
- newPathAttrs[i] = v
+ return &Path{
+ parent: path,
+ IsWithdraw: isWithdraw,
+ Owner: owner,
+ filtered: make(map[string]PolicyDirection),
}
+}
- p := NewPath(path.source, path.nlri, isWithdraw, newPathAttrs, path.timestamp, path.NoImplicitWithdraw)
- p.Validation = path.Validation
- p.Owner = owner
- p.key = path.key
+func (path *Path) root() *Path {
+ p := path
+ for p.parent != nil {
+ p = p.parent
+ }
return p
}
+func (path *Path) OriginInfo() *originInfo {
+ return path.root().info
+}
+
+func (path *Path) NoImplicitWithdraw() bool {
+ return path.OriginInfo().noImplicitWithdraw
+}
+
+func (path *Path) Validation() config.RpkiValidationResultType {
+ return path.OriginInfo().validation
+}
+
+func (path *Path) SetValidation(r config.RpkiValidationResultType) {
+ path.OriginInfo().validation = r
+}
+
+func (path *Path) IsFromZebra() bool {
+ return path.OriginInfo().isFromZebra
+}
+
+func (path *Path) SetIsFromZebra(y bool) {
+ path.OriginInfo().isFromZebra = y
+}
+
+func (path *Path) UUID() []byte {
+ return path.OriginInfo().uuid
+}
+
+func (path *Path) SetUUID(uuid []byte) {
+ path.OriginInfo().uuid = uuid
+}
+
func (path *Path) Filter(id string, reason PolicyDirection) {
path.filtered[id] = reason
}
@@ -235,18 +286,18 @@ func (path *Path) Filtered(id string) PolicyDirection {
}
func (path *Path) GetRouteFamily() bgp.RouteFamily {
- return bgp.AfiSafiToRouteFamily(path.nlri.AFI(), path.nlri.SAFI())
+ return bgp.AfiSafiToRouteFamily(path.OriginInfo().nlri.AFI(), path.OriginInfo().nlri.SAFI())
}
func (path *Path) setSource(source *PeerInfo) {
- path.source = source
+ path.OriginInfo().source = source
}
func (path *Path) GetSource() *PeerInfo {
- return path.source
+ return path.OriginInfo().source
}
func (path *Path) GetSourceAs() uint32 {
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
if attr != nil {
asPathParam := attr.(*bgp.PathAttributeAsPath).Value
if len(asPathParam) == 0 {
@@ -262,11 +313,11 @@ func (path *Path) GetSourceAs() uint32 {
}
func (path *Path) GetNexthop() net.IP {
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
if attr != nil {
return attr.(*bgp.PathAttributeNextHop).Value
}
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
if attr != nil {
return attr.(*bgp.PathAttributeMpReachNLRI).Nexthop
}
@@ -274,34 +325,82 @@ func (path *Path) GetNexthop() net.IP {
}
func (path *Path) SetNexthop(nexthop net.IP) {
- idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
if attr != nil {
- newNexthop := bgp.NewPathAttributeNextHop(nexthop.String())
- path.pathAttrs[idx] = newNexthop
+ path.setPathAttr(bgp.NewPathAttributeNextHop(nexthop.String()))
}
- idx, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
if attr != nil {
oldNlri := attr.(*bgp.PathAttributeMpReachNLRI)
- newNlri := bgp.NewPathAttributeMpReachNLRI(nexthop.String(), oldNlri.Value)
- path.pathAttrs[idx] = newNlri
+ path.setPathAttr(bgp.NewPathAttributeMpReachNLRI(nexthop.String(), oldNlri.Value))
}
}
func (path *Path) GetNlri() bgp.AddrPrefixInterface {
- return path.nlri
+ return path.OriginInfo().nlri
}
func (path *Path) GetPathAttrs() []bgp.PathAttributeInterface {
- return path.pathAttrs
+ seen := NewBitmap(math.MaxUint8)
+ list := make([]bgp.PathAttributeInterface, 0, 4)
+ p := path
+ for {
+ for _, t := range p.dels {
+ seen.Flag(uint(t))
+ }
+ for _, a := range p.pathAttrs {
+ if typ := uint(a.GetType()); !seen.GetFlag(typ) {
+ list = append(list, a)
+ seen.Flag(typ)
+ }
+ }
+ if p.parent == nil {
+ return list
+ }
+ p = p.parent
+ }
+}
+
+func (path *Path) getPathAttr(typ bgp.BGPAttrType) bgp.PathAttributeInterface {
+ p := path
+ for {
+ for _, t := range p.dels {
+ if t == typ {
+ return nil
+ }
+ }
+ for _, a := range p.pathAttrs {
+ if a.GetType() == typ {
+ return a
+ }
+ }
+ if p.parent == nil {
+ return nil
+ }
+ p = p.parent
+ }
}
-func (path *Path) getPathAttr(pattrType bgp.BGPAttrType) (int, bgp.PathAttributeInterface) {
- for i, p := range path.pathAttrs {
- if p.GetType() == pattrType {
- return i, p
+func (path *Path) setPathAttr(a bgp.PathAttributeInterface) {
+ if len(path.pathAttrs) == 0 {
+ path.pathAttrs = []bgp.PathAttributeInterface{a}
+ } else {
+ for i, b := range path.pathAttrs {
+ if a.GetType() == b.GetType() {
+ path.pathAttrs[i] = a
+ return
+ }
}
+ path.pathAttrs = append(path.pathAttrs, a)
+ }
+}
+
+func (path *Path) delPathAttr(typ bgp.BGPAttrType) {
+ if len(path.dels) == 0 {
+ path.dels = []bgp.BGPAttrType{typ}
+ } else {
+ path.dels = append(path.dels, typ)
}
- return -1, nil
}
// return Path's string representation
@@ -318,14 +417,14 @@ func (path *Path) String() string {
}
func (path *Path) getPrefix() string {
- if path.key == "" {
- return path.nlri.String()
+ if path.OriginInfo().key == "" {
+ path.OriginInfo().key = path.GetNlri().String()
}
- return path.key
+ return path.OriginInfo().key
}
func (path *Path) GetAsPath() *bgp.PathAttributeAsPath {
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
if attr != nil {
return attr.(*bgp.PathAttributeAsPath)
}
@@ -336,8 +435,7 @@ func (path *Path) GetAsPath() *bgp.PathAttributeAsPath {
func (path *Path) GetAsPathLen() int {
var length int = 0
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil {
- aspath := attr.(*bgp.PathAttributeAsPath)
+ if aspath := path.GetAsPath(); aspath != nil {
for _, as := range aspath.Value {
length += as.ASLen()
}
@@ -347,8 +445,7 @@ func (path *Path) GetAsPathLen() int {
func (path *Path) GetAsString() string {
s := bytes.NewBuffer(make([]byte, 0, 64))
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil {
- aspath := attr.(*bgp.PathAttributeAsPath)
+ if aspath := path.GetAsPath(); aspath != nil {
for i, paramIf := range aspath.Value {
segment := paramIf.(*bgp.As4PathParam)
if i != 0 {
@@ -388,8 +485,7 @@ func (path *Path) GetAsSeqList() []uint32 {
func (path *Path) getAsListofSpecificType(getAsSeq, getAsSet bool) []uint32 {
asList := []uint32{}
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil {
- aspath := attr.(*bgp.PathAttributeAsPath)
+ if aspath := path.GetAsPath(); aspath != nil {
for _, paramIf := range aspath.Value {
segment := paramIf.(*bgp.As4PathParam)
if getAsSeq && segment.Type == bgp.BGP_ASPATH_ATTR_TYPE_SEQ {
@@ -428,7 +524,7 @@ func (path *Path) getAsListofSpecificType(getAsSeq, getAsSet bool) []uint32 {
// into that segment, and places that segment into the AS_PATH.
func (path *Path) PrependAsn(asn uint32, repeat uint8) {
- idx, original := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ original := path.GetAsPath()
asns := make([]uint32, repeat)
for i, _ := range asns {
@@ -436,12 +532,10 @@ func (path *Path) PrependAsn(asn uint32, repeat uint8) {
}
var asPath *bgp.PathAttributeAsPath
- if idx < 0 {
+ if original == nil {
asPath = bgp.NewPathAttributeAsPath([]bgp.AsPathParamInterface{})
- path.pathAttrs = append(path.pathAttrs, asPath)
} else {
- asPath = cloneAsPath(original.(*bgp.PathAttributeAsPath))
- path.pathAttrs[idx] = asPath
+ asPath = cloneAsPath(original)
}
if len(asPath.Value) > 0 {
@@ -460,11 +554,12 @@ func (path *Path) PrependAsn(asn uint32, repeat uint8) {
p := bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, asns)
asPath.Value = append([]bgp.AsPathParamInterface{p}, asPath.Value...)
}
+ path.setPathAttr(asPath)
}
func (path *Path) GetCommunities() []uint32 {
communityList := []uint32{}
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES); attr != nil {
+ if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES); attr != nil {
communities := attr.(*bgp.PathAttributeCommunities)
communityList = append(communityList, communities.Value...)
}
@@ -477,12 +572,12 @@ func (path *Path) SetCommunities(communities []uint32, doReplace bool) {
if len(communities) == 0 && doReplace {
// clear communities
- path.ClearCommunities()
+ path.delPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
return
}
newList := make([]uint32, 0)
- idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
if attr != nil {
c := attr.(*bgp.PathAttributeCommunities)
if doReplace {
@@ -491,13 +586,10 @@ func (path *Path) SetCommunities(communities []uint32, doReplace bool) {
newList = append(newList, c.Value...)
newList = append(newList, communities...)
}
- newCommunities := bgp.NewPathAttributeCommunities(newList)
- path.pathAttrs[idx] = newCommunities
} else {
newList = append(newList, communities...)
- newCommunities := bgp.NewPathAttributeCommunities(newList)
- path.pathAttrs = append(path.pathAttrs, newCommunities)
}
+ path.setPathAttr(bgp.NewPathAttributeCommunities(newList))
}
@@ -521,7 +613,7 @@ func (path *Path) RemoveCommunities(communities []uint32) int {
}
count := 0
- idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
if attr != nil {
newList := make([]uint32, 0)
c := attr.(*bgp.PathAttributeCommunities)
@@ -535,26 +627,17 @@ func (path *Path) RemoveCommunities(communities []uint32) int {
}
if len(newList) != 0 {
- newCommunities := bgp.NewPathAttributeCommunities(newList)
- path.pathAttrs[idx] = newCommunities
+ path.setPathAttr(bgp.NewPathAttributeCommunities(newList))
} else {
- path.pathAttrs = append(path.pathAttrs[:idx], path.pathAttrs[idx+1:]...)
+ path.delPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
}
}
return count
}
-// ClearCommunities removes Communities path attribute.
-func (path *Path) ClearCommunities() {
- idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_COMMUNITIES)
- if idx >= 0 {
- path.pathAttrs = append(path.pathAttrs[:idx], path.pathAttrs[idx+1:]...)
- }
-}
-
func (path *Path) GetExtCommunities() []bgp.ExtendedCommunityInterface {
eCommunityList := make([]bgp.ExtendedCommunityInterface, 0)
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES); attr != nil {
+ if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES); attr != nil {
eCommunities := attr.(*bgp.PathAttributeExtendedCommunities).Value
for _, eCommunity := range eCommunities {
eCommunityList = append(eCommunityList, eCommunity)
@@ -564,7 +647,7 @@ func (path *Path) GetExtCommunities() []bgp.ExtendedCommunityInterface {
}
func (path *Path) SetExtCommunities(exts []bgp.ExtendedCommunityInterface, doReplace bool) {
- idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES)
if attr != nil {
l := attr.(*bgp.PathAttributeExtendedCommunities).Value
if doReplace {
@@ -572,14 +655,14 @@ func (path *Path) SetExtCommunities(exts []bgp.ExtendedCommunityInterface, doRep
} else {
l = append(l, exts...)
}
- path.pathAttrs[idx] = bgp.NewPathAttributeExtendedCommunities(l)
+ path.setPathAttr(bgp.NewPathAttributeExtendedCommunities(l))
} else {
- path.pathAttrs = append(path.pathAttrs, bgp.NewPathAttributeExtendedCommunities(exts))
+ path.setPathAttr(bgp.NewPathAttributeExtendedCommunities(exts))
}
}
func (path *Path) GetMed() (uint32, error) {
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
if attr == nil {
return 0, fmt.Errorf("no med path attr")
}
@@ -604,34 +687,27 @@ func (path *Path) SetMed(med int64, doReplace bool) error {
return newMed, nil
}
- idx, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
- if attr != nil {
- m := attr.(*bgp.PathAttributeMultiExitDisc)
- newMed, err := parseMed(m.Value, med, doReplace)
- if err != nil {
- return err
- }
- path.pathAttrs[idx] = newMed
- } else {
- m := 0
- newMed, err := parseMed(uint32(m), med, doReplace)
- if err != nil {
- return err
- }
- path.pathAttrs = append(path.pathAttrs, newMed)
+ m := uint32(0)
+ if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC); attr != nil {
+ m = attr.(*bgp.PathAttributeMultiExitDisc).Value
+ }
+ newMed, err := parseMed(m, med, doReplace)
+ if err != nil {
+ return err
}
+ path.setPathAttr(newMed)
return nil
}
func (path *Path) GetOriginatorID() net.IP {
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGINATOR_ID); attr != nil {
+ if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGINATOR_ID); attr != nil {
return attr.(*bgp.PathAttributeOriginatorId).Value
}
return nil
}
func (path *Path) GetClusterList() []net.IP {
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_CLUSTER_LIST); attr != nil {
+ if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_CLUSTER_LIST); attr != nil {
return attr.(*bgp.PathAttributeClusterList).Value
}
return nil
diff --git a/table/path_test.go b/table/path_test.go
index 48dec6fe..bcc532a1 100644
--- a/table/path_test.go
+++ b/table/path_test.go
@@ -24,26 +24,12 @@ func TestPathNewIPv6(t *testing.T) {
assert.NotNil(t, ipv6p)
}
-func TestPathSetSource(t *testing.T) {
- pd := &Path{}
- pr := &PeerInfo{AS: 65000}
- pd.setSource(pr)
- r_pr := pd.GetSource()
- assert.Equal(t, r_pr, pr)
-}
-
-func TestPathGetSource(t *testing.T) {
- pd := &Path{}
- pr := &PeerInfo{AS: 65001}
- pd.setSource(pr)
- r_pr := pd.GetSource()
- assert.Equal(t, r_pr, pr)
-}
-
func TestPathGetNlri(t *testing.T) {
nlri := bgp.NewIPAddrPrefix(24, "13.2.3.2")
pd := &Path{
- nlri: nlri,
+ info: &originInfo{
+ nlri: nlri,
+ },
}
r_nlri := pd.GetNlri()
assert.Equal(t, r_nlri, nlri)
@@ -72,7 +58,7 @@ func TestPathGetAttribute(t *testing.T) {
peerP := PathCreatePeer()
pathP := PathCreatePath(peerP)
nh := "192.168.50.1"
- _, pa := pathP[0].getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ pa := pathP[0].getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
r_nh := pa.(*bgp.PathAttributeNextHop).Value.String()
assert.Equal(t, r_nh, nh)
}
diff --git a/table/policy.go b/table/policy.go
index be9ba5ad..4484e7e6 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -1562,7 +1562,7 @@ func (c *RpkiValidationCondition) Type() ConditionType {
}
func (c *RpkiValidationCondition) Evaluate(path *Path) bool {
- return c.result == path.Validation
+ return c.result == path.Validation()
}
func (c *RpkiValidationCondition) Set() DefinedSet {
diff --git a/table/table.go b/table/table.go
index 36a29ed4..ecc067b4 100644
--- a/table/table.go
+++ b/table/table.go
@@ -72,7 +72,7 @@ func (t *Table) deletePathsByVrf(vrf *Vrf) []*Path {
for _, dest := range t.destinations {
for _, p := range dest.knownPathList {
var rd bgp.RouteDistinguisherInterface
- nlri := p.nlri
+ nlri := p.GetNlri()
switch nlri.(type) {
case *bgp.LabeledVPNIPAddrPrefix:
rd = nlri.(*bgp.LabeledVPNIPAddrPrefix).RD
@@ -146,7 +146,7 @@ func (t *Table) validatePath(path *Path) {
"ReceivedRf": path.GetRouteFamily().String(),
}).Error("Invalid path. RouteFamily mismatch")
}
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil {
+ if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH); attr != nil {
pathParam := attr.(*bgp.PathAttributeAsPath).Value
for _, as := range pathParam {
_, y := as.(*bgp.As4PathParam)
@@ -159,7 +159,7 @@ func (t *Table) validatePath(path *Path) {
}
}
}
- if _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS4_PATH); attr != nil {
+ if attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS4_PATH); attr != nil {
log.WithFields(log.Fields{
"Topic": "Table",
"Key": t.routeFamily,
diff --git a/table/table_manager_test.go b/table/table_manager_test.go
index 791c6c48..61019781 100644
--- a/table/table_manager_test.go
+++ b/table/table_manager_test.go
@@ -101,22 +101,22 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -152,22 +152,22 @@ func TestProcessBGPUpdate_0_select_onlypath_ipv6(t *testing.T) {
pathAttributes := bgpMessage.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -233,22 +233,22 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -314,22 +314,22 @@ func TestProcessBGPUpdate_1_select_high_localpref_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -397,22 +397,22 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -481,22 +481,22 @@ func TestProcessBGPUpdate_2_select_local_origin_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -537,22 +537,22 @@ func TestProcessBGPUpdate_3_select_aspath_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -593,22 +593,22 @@ func TestProcessBGPUpdate_3_select_aspath_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -674,22 +674,22 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -755,22 +755,22 @@ func TestProcessBGPUpdate_4_select_low_origin_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -836,22 +836,22 @@ func TestProcessBGPUpdate_5_select_low_med_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -917,22 +917,22 @@ func TestProcessBGPUpdate_5_select_low_med_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -998,22 +998,22 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1079,22 +1079,22 @@ func TestProcessBGPUpdate_6_select_ebgp_path_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1162,22 +1162,22 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv4(t *testing.T) {
// check PathAttribute
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1243,22 +1243,22 @@ func TestProcessBGPUpdate_7_select_low_routerid_path_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1325,22 +1325,22 @@ func TestProcessBGPUpdate_8_withdraw_path_ipv4(t *testing.T) {
checkPattr := func(expected *bgp.BGPMessage, actual *Path) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1428,22 +1428,22 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1452,22 +1452,22 @@ func TestProcessBGPUpdate_8_mpunreach_path_ipv6(t *testing.T) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
// check PathAttribute length
@@ -1547,22 +1547,22 @@ func TestProcessBGPUpdate_bestpath_lost_ipv4(t *testing.T) {
checkPattr := func(expected *bgp.BGPMessage, actual *Path) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1617,22 +1617,22 @@ func TestProcessBGPUpdate_bestpath_lost_ipv6(t *testing.T) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
// check PathAttribute length
@@ -1696,22 +1696,22 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv4(t *testing.T) {
checkPattr := func(expected *bgp.BGPMessage, actual *Path) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1777,22 +1777,22 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
pathAttributes := bgpMessage2.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1801,22 +1801,22 @@ func TestProcessBGPUpdate_implicit_withdrwal_ipv6(t *testing.T) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
expectedNexthopAttr := pathAttributes[0]
- _, attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
pathNexthop := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
// check PathAttribute length
@@ -1855,22 +1855,22 @@ func TestProcessBGPUpdate_multiple_nlri_ipv4(t *testing.T) {
checkPattr := func(expected *bgp.BGPMessage, actual *Path) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
expectedOrigin := pathAttributes[0]
- _, attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedNexthopAttr := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
pathNexthop := attr.(*bgp.PathAttributeNextHop)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedMed := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
@@ -1987,27 +1987,27 @@ func TestProcessBGPUpdate_multiple_nlri_ipv6(t *testing.T) {
checkPattr := func(expected *bgp.BGPMessage, actual *Path) {
pathAttributes := expected.Body.(*bgp.BGPUpdate).PathAttributes
pathNexthop := pathAttributes[4]
- _, attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
+ attr := actual.getPathAttr(bgp.BGP_ATTR_TYPE_MP_REACH_NLRI)
expectedNexthopAttr := attr.(*bgp.PathAttributeMpReachNLRI)
assert.Equal(t, expectedNexthopAttr, pathNexthop)
expectedOrigin := pathAttributes[0]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_ORIGIN)
pathOrigin := attr.(*bgp.PathAttributeOrigin)
assert.Equal(t, expectedOrigin, pathOrigin)
expectedAsPath := pathAttributes[1]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
pathAspath := attr.(*bgp.PathAttributeAsPath)
assert.Equal(t, expectedAsPath, pathAspath)
expectedMed := pathAttributes[2]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
pathMed := attr.(*bgp.PathAttributeMultiExitDisc)
assert.Equal(t, expectedMed, pathMed)
expectedLocalpref := pathAttributes[3]
- _, attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
+ attr = actual.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
localpref := attr.(*bgp.PathAttributeLocalPref)
assert.Equal(t, expectedLocalpref, localpref)
@@ -2132,7 +2132,7 @@ func TestProcessBGPUpdate_Timestamp(t *testing.T) {
peer := peerR1()
pList1 := ProcessMessage(m1, peer, time.Now())
path1 := pList1[0]
- t1 := path1.timestamp
+ t1 := path1.OriginInfo().timestamp
adjRib.Update(pList1)
m2 := bgp.NewBGPUpdateMessage(nil, pathAttributes, nlri)