summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
Diffstat (limited to 'table')
-rw-r--r--table/destination_test.go2
-rw-r--r--table/path.go7
-rw-r--r--table/path_test.go20
-rw-r--r--table/policy_test.go2
-rw-r--r--table/table_manager.go10
-rw-r--r--table/table_test.go2
6 files changed, 23 insertions, 20 deletions
diff --git a/table/destination_test.go b/table/destination_test.go
index f5556175..1bd6c944 100644
--- a/table/destination_test.go
+++ b/table/destination_test.go
@@ -81,7 +81,7 @@ func DestCreatePath(peerD []*PeerInfo) []*Path {
nlriList := updateMsgD.NLRI
pathAttributes := updateMsgD.PathAttributes
nlri_info := nlriList[0]
- pathD[i] = NewPath(peerD[i], nlri_info, false, pathAttributes, time.Now(), false)
+ pathD[i] = NewPath(peerD[i], nlri_info, false, pathAttributes, time.Now(), false, false)
}
return pathD
}
diff --git a/table/path.go b/table/path.go
index 375ad1af..9ed5b78b 100644
--- a/table/path.go
+++ b/table/path.go
@@ -52,6 +52,7 @@ type originInfo struct {
noImplicitWithdraw bool
validation config.RpkiValidationResultType
isFromZebra bool
+ isFromOps bool
key string
uuid []byte
eor bool
@@ -68,7 +69,7 @@ type Path struct {
filtered map[string]PolicyDirection
}
-func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool) *Path {
+func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool, isFromOps bool) *Path {
if !isWithdraw && pattrs == nil {
log.WithFields(log.Fields{
"Topic": "Table",
@@ -84,6 +85,7 @@ func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pa
source: source,
timestamp: timestamp,
noImplicitWithdraw: noImplicitWithdraw,
+ isFromOps: isFromOps,
},
IsWithdraw: isWithdraw,
pathAttrs: pattrs,
@@ -99,7 +101,7 @@ func NewEOR(family bgp.RouteFamily) *Path {
nlri: nlri,
eor: true,
},
- filtered: make(map[string]PolicyDirection),
+ filtered: make(map[string]PolicyDirection),
}
}
@@ -240,6 +242,7 @@ func (path *Path) ToApiStruct(id string) *api.Path {
SourceAsn: path.OriginInfo().source.AS,
SourceId: path.OriginInfo().source.ID.String(),
Stale: path.IsStale(),
+ IsFromOps: path.OriginInfo().isFromOps,
}
}
diff --git a/table/path_test.go b/table/path_test.go
index bcc532a1..6c71cc05 100644
--- a/table/path_test.go
+++ b/table/path_test.go
@@ -14,13 +14,13 @@ import (
func TestPathNewIPv4(t *testing.T) {
peerP := PathCreatePeer()
pathP := PathCreatePath(peerP)
- ipv4p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), false)
+ ipv4p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), false, false)
assert.NotNil(t, ipv4p)
}
func TestPathNewIPv6(t *testing.T) {
peerP := PathCreatePeer()
pathP := PathCreatePath(peerP)
- ipv6p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), false)
+ ipv6p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), false, false)
assert.NotNil(t, ipv6p)
}
@@ -42,7 +42,7 @@ func TestPathCreatePath(t *testing.T) {
nlriList := updateMsgP.NLRI
pathAttributes := updateMsgP.PathAttributes
nlri_info := nlriList[0]
- path := NewPath(peerP[0], nlri_info, false, pathAttributes, time.Now(), false)
+ path := NewPath(peerP[0], nlri_info, false, pathAttributes, time.Now(), false, false)
assert.NotNil(t, path)
}
@@ -87,7 +87,7 @@ func TestASPathLen(t *testing.T) {
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false, false)
assert.Equal(10, p.GetAsPathLen())
}
@@ -113,7 +113,7 @@ func TestPathPrependAsnToExistingSeqAttr(t *testing.T) {
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false, false)
p.PrependAsn(65000, 1)
assert.Equal([]uint32{65000, 65001, 65002, 65003, 65004, 65005, 0, 0, 0}, p.GetAsSeqList())
@@ -135,7 +135,7 @@ func TestPathPrependAsnToNewAsPathAttr(t *testing.T) {
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false, false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -163,7 +163,7 @@ func TestPathPrependAsnToNewAsPathSeq(t *testing.T) {
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false, false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -193,7 +193,7 @@ func TestPathPrependAsnToEmptyAsPathAttr(t *testing.T) {
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false, false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -229,7 +229,7 @@ func TestPathPrependAsnToFullPathAttr(t *testing.T) {
update := bgpmsg.Body.(*bgp.BGPUpdate)
UpdatePathAttrs4ByteAs(update)
peer := PathCreatePeer()
- p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false, false)
expected := []uint32{65000, 65000}
for _, v := range asns {
@@ -258,7 +258,7 @@ func PathCreatePath(peerP []*PeerInfo) []*Path {
nlriList := updateMsgP.NLRI
pathAttributes := updateMsgP.PathAttributes
nlri_info := nlriList[0]
- pathP[i] = NewPath(peerP[i], nlri_info, false, pathAttributes, time.Now(), false)
+ pathP[i] = NewPath(peerP[i], nlri_info, false, pathAttributes, time.Now(), false, false)
}
return pathP
}
diff --git a/table/policy_test.go b/table/policy_test.go
index 38b55794..8874a2f6 100644
--- a/table/policy_test.go
+++ b/table/policy_test.go
@@ -876,7 +876,7 @@ func TestAsPathCondition(t *testing.T) {
bgp.NewAs4PathParam(asPathAttrType, ases),
}
pathAttributes := []bgp.PathAttributeInterface{bgp.NewPathAttributeAsPath(aspathParam)}
- p := NewPath(nil, nil, false, pathAttributes, time.Time{}, false)
+ p := NewPath(nil, nil, false, pathAttributes, time.Time{}, false, false)
return astest{
path: p,
result: result,
diff --git a/table/table_manager.go b/table/table_manager.go
index afb4deac..119b81b2 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -33,7 +33,7 @@ func nlri2Path(m *bgp.BGPMessage, p *PeerInfo, now time.Time) []*Path {
pathAttributes := updateMsg.PathAttributes
pathList := make([]*Path, 0)
for _, nlri := range updateMsg.NLRI {
- path := NewPath(p, nlri, false, pathAttributes, now, false)
+ path := NewPath(p, nlri, false, pathAttributes, now, false, false)
pathList = append(pathList, path)
}
return pathList
@@ -44,7 +44,7 @@ func withdraw2Path(m *bgp.BGPMessage, p *PeerInfo, now time.Time) []*Path {
pathAttributes := updateMsg.PathAttributes
pathList := make([]*Path, 0)
for _, nlri := range updateMsg.WithdrawnRoutes {
- path := NewPath(p, nlri, true, pathAttributes, now, false)
+ path := NewPath(p, nlri, true, pathAttributes, now, false, false)
pathList = append(pathList, path)
}
return pathList
@@ -67,7 +67,7 @@ func mpreachNlri2Path(m *bgp.BGPMessage, p *PeerInfo, now time.Time) []*Path {
for _, mp := range attrList {
nlri_info := mp.Value
for _, nlri := range nlri_info {
- path := NewPath(p, nlri, false, pathAttributes, now, false)
+ path := NewPath(p, nlri, false, pathAttributes, now, false, false)
pathList = append(pathList, path)
}
}
@@ -92,7 +92,7 @@ func mpunreachNlri2Path(m *bgp.BGPMessage, p *PeerInfo, now time.Time) []*Path {
nlri_info := mp.Value
for _, nlri := range nlri_info {
- path := NewPath(p, nlri, true, pathAttributes, now, false)
+ path := NewPath(p, nlri, true, pathAttributes, now, false, false)
pathList = append(pathList, path)
}
}
@@ -189,7 +189,7 @@ func (manager *TableManager) AddVrf(name string, rd bgp.RouteDistinguisherInterf
pattr := make([]bgp.PathAttributeInterface, 0, 2)
pattr = append(pattr, bgp.NewPathAttributeOrigin(bgp.BGP_ORIGIN_ATTR_TYPE_IGP))
pattr = append(pattr, bgp.NewPathAttributeMpReachNLRI(nexthop, []bgp.AddrPrefixInterface{nlri}))
- msgs = append(msgs, NewPath(info, nlri, false, pattr, time.Now(), false))
+ msgs = append(msgs, NewPath(info, nlri, false, pattr, time.Now(), false, false))
}
return msgs, nil
}
diff --git a/table/table_test.go b/table/table_test.go
index 9cec4133..b38d11a9 100644
--- a/table/table_test.go
+++ b/table/table_test.go
@@ -107,7 +107,7 @@ func TableCreatePath(peerT []*PeerInfo) []*Path {
nlriList := updateMsgT.NLRI
pathAttributes := updateMsgT.PathAttributes
nlri_info := nlriList[0]
- pathT[i] = NewPath(peerT[i], nlri_info, false, pathAttributes, time.Now(), false)
+ pathT[i] = NewPath(peerT[i], nlri_info, false, pathAttributes, time.Now(), false, false)
}
return pathT
}