diff options
author | Naoto Hanaue <hanaue.naoto@po.ntts.co.jp> | 2016-02-26 19:55:28 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-02-27 03:47:00 -0800 |
commit | a53d1945056b6c43c1de5dcaafc5ef92fcd33614 (patch) | |
tree | 318edb562c31ec11708fea1282cb8cded6ea870d /table | |
parent | b334dd4185bc91afd405ba326a03c09cfe9a9623 (diff) |
ops: fix and integration the attribute name that indicates the route received from an external resource
Diffstat (limited to 'table')
-rw-r--r-- | table/destination_test.go | 2 | ||||
-rw-r--r-- | table/path.go | 36 | ||||
-rw-r--r-- | table/path_test.go | 20 | ||||
-rw-r--r-- | table/policy_test.go | 2 | ||||
-rw-r--r-- | table/table_manager.go | 10 | ||||
-rw-r--r-- | table/table_test.go | 2 |
6 files changed, 35 insertions, 37 deletions
diff --git a/table/destination_test.go b/table/destination_test.go index 1bd6c944..f5556175 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, false) + pathD[i] = NewPath(peerD[i], nlri_info, false, pathAttributes, time.Now(), false) } return pathD } diff --git a/table/path.go b/table/path.go index 498e19cf..9d1b00b1 100644 --- a/table/path.go +++ b/table/path.go @@ -52,8 +52,7 @@ type originInfo struct { timestamp time.Time noImplicitWithdraw bool validation config.RpkiValidationResultType - isFromZebra bool - isFromOps bool + isFromExternal bool key string uuid []byte eor bool @@ -84,7 +83,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, isFromOps bool) *Path { +func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, timestamp time.Time, noImplicitWithdraw bool) *Path { if !isWithdraw && pattrs == nil { log.WithFields(log.Fields{ "Topic": "Table", @@ -119,7 +118,6 @@ func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pa source: source, timestamp: timestamp, noImplicitWithdraw: noImplicitWithdraw, - isFromOps: isFromOps, }, IsWithdraw: isWithdraw, pathAttrs: pattrs, @@ -266,17 +264,17 @@ func (path *Path) ToApiStruct(id string) *api.Path { return ret }(path.GetPathAttrs()) return &api.Path{ - Nlri: n, - Pattrs: pattrs, - Age: int64(time.Now().Sub(path.OriginInfo().timestamp).Seconds()), - IsWithdraw: path.IsWithdraw, - Validation: int32(path.OriginInfo().validation.ToInt()), - Filtered: path.Filtered(id) == POLICY_DIRECTION_IN, - Family: family, - SourceAsn: path.OriginInfo().source.AS, - SourceId: path.OriginInfo().source.ID.String(), - Stale: path.IsStale(), - IsFromOps: path.OriginInfo().isFromOps, + Nlri: n, + Pattrs: pattrs, + Age: int64(time.Now().Sub(path.OriginInfo().timestamp).Seconds()), + IsWithdraw: path.IsWithdraw, + Validation: int32(path.OriginInfo().validation.ToInt()), + Filtered: path.Filtered(id) == POLICY_DIRECTION_IN, + Family: family, + SourceAsn: path.OriginInfo().source.AS, + SourceId: path.OriginInfo().source.ID.String(), + Stale: path.IsStale(), + IsFromExternal: path.OriginInfo().isFromExternal, } } @@ -313,12 +311,12 @@ func (path *Path) SetValidation(r config.RpkiValidationResultType) { path.OriginInfo().validation = r } -func (path *Path) IsFromZebra() bool { - return path.OriginInfo().isFromZebra +func (path *Path) IsFromExternal() bool { + return path.OriginInfo().isFromExternal } -func (path *Path) SetIsFromZebra(y bool) { - path.OriginInfo().isFromZebra = y +func (path *Path) SetIsFromExternal(y bool) { + path.OriginInfo().isFromExternal = y } func (path *Path) UUID() []byte { diff --git a/table/path_test.go b/table/path_test.go index 5f625785..e12640e2 100644 --- a/table/path_test.go +++ b/table/path_test.go @@ -13,14 +13,14 @@ 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, false) + ipv4p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), 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, false) + ipv6p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), 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, false) + path := NewPath(peerP[0], nlri_info, false, pathAttributes, time.Now(), false) assert.NotNil(t, path) } @@ -88,7 +88,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, false) + p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false) assert.Equal(10, p.GetAsPathLen()) } @@ -114,7 +114,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, false) + p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false) p.PrependAsn(65000, 1) assert.Equal([]uint32{65000, 65001, 65002, 65003, 65004, 65005, 0, 0, 0}, p.GetAsSeqList()) @@ -136,7 +136,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, false) + p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false) asn := uint32(65000) p.PrependAsn(asn, 1) @@ -164,7 +164,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, false) + p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false) asn := uint32(65000) p.PrependAsn(asn, 1) @@ -194,7 +194,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, false) + p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false) asn := uint32(65000) p.PrependAsn(asn, 1) @@ -230,7 +230,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, false) + p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false) expected := []uint32{65000, 65000} for _, v := range asns { @@ -269,7 +269,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, false) + pathP[i] = NewPath(peerP[i], nlri_info, false, pathAttributes, time.Now(), false) } return pathP } diff --git a/table/policy_test.go b/table/policy_test.go index 8874a2f6..38b55794 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, false) + p := NewPath(nil, nil, false, pathAttributes, time.Time{}, false) return astest{ path: p, result: result, diff --git a/table/table_manager.go b/table/table_manager.go index 119b81b2..afb4deac 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, false) + path := NewPath(p, nlri, false, pathAttributes, now, 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, false) + path := NewPath(p, nlri, true, pathAttributes, now, 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, false) + path := NewPath(p, nlri, false, pathAttributes, now, 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, false) + path := NewPath(p, nlri, true, pathAttributes, now, 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, false)) + msgs = append(msgs, NewPath(info, nlri, false, pattr, time.Now(), false)) } return msgs, nil } diff --git a/table/table_test.go b/table/table_test.go index b38d11a9..9cec4133 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, false) + pathT[i] = NewPath(peerT[i], nlri_info, false, pathAttributes, time.Now(), false) } return pathT } |