summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-12 21:18:08 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-16 16:25:24 +0900
commitb344eb3777e5088f0a97d585e81e546363ea4101 (patch)
tree16def797a39da2bf6d61fa30e664b699fc561247
parent49ec4a328fd2e1bdc81797f150089818031ae6e1 (diff)
table: kill unused field medSetByTargetNeighbor
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--server/server.go2
-rw-r--r--server/zclient.go2
-rw-r--r--table/destination_test.go2
-rw-r--r--table/path.go60
-rw-r--r--table/path_test.go36
-rw-r--r--table/policy_test.go2
-rw-r--r--table/table_manager.go10
-rw-r--r--table/table_test.go2
8 files changed, 45 insertions, 71 deletions
diff --git a/server/server.go b/server/server.go
index 2deb9b0f..817c7d05 100644
--- a/server/server.go
+++ b/server/server.go
@@ -1246,7 +1246,7 @@ func (server *BgpServer) Api2PathList(resource api.Resource, name string, ApiPat
pattr = append(pattr, bgp.NewPathAttributeExtendedCommunities(extcomms))
}
- paths = append(paths, table.NewPath(pi, nlri, path.IsWithdraw, pattr, false, time.Now(), path.NoImplicitWithdraw))
+ paths = append(paths, table.NewPath(pi, nlri, path.IsWithdraw, pattr, time.Now(), path.NoImplicitWithdraw))
}
return paths, nil
diff --git a/server/zclient.go b/server/zclient.go
index ba731cce..994f1c78 100644
--- a/server/zclient.go
+++ b/server/zclient.go
@@ -127,7 +127,7 @@ func createPathFromIPRouteMessage(m *zebra.Message, peerInfo *table.PeerInfo) *t
med := bgp.NewPathAttributeMultiExitDisc(body.Metric)
pattr = append(pattr, med)
- p := table.NewPath(peerInfo, nlri, isWithdraw, pattr, false, time.Now(), false)
+ p := table.NewPath(peerInfo, nlri, isWithdraw, pattr, time.Now(), false)
p.IsFromZebra = true
return p
}
diff --git a/table/destination_test.go b/table/destination_test.go
index 105d7104..a606cff6 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, false, time.Now(), 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 94bc5fd0..fc9380a7 100644
--- a/table/path.go
+++ b/table/path.go
@@ -29,23 +29,22 @@ import (
)
type Path struct {
- source *PeerInfo
- IsWithdraw bool
- nlri bgp.AddrPrefixInterface
- pathAttrs []bgp.PathAttributeInterface
- medSetByTargetNeighbor bool
- timestamp time.Time
- NoImplicitWithdraw bool
- Validation config.RpkiValidationResultType
- IsFromZebra bool
- Owner net.IP
- reason BestPathReason
- filtered map[string]PolicyDirection
- key string
- Uuid []byte
-}
-
-func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pattrs []bgp.PathAttributeInterface, medSetByTargetNeighbor bool, timestamp time.Time, noImplicitWithdraw bool) *Path {
+ source *PeerInfo
+ IsWithdraw bool
+ nlri bgp.AddrPrefixInterface
+ pathAttrs []bgp.PathAttributeInterface
+ timestamp time.Time
+ NoImplicitWithdraw bool
+ Validation config.RpkiValidationResultType
+ IsFromZebra bool
+ Owner net.IP
+ reason BestPathReason
+ filtered map[string]PolicyDirection
+ key string
+ Uuid []byte
+}
+
+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",
@@ -61,15 +60,14 @@ func NewPath(source *PeerInfo, nlri bgp.AddrPrefixInterface, isWithdraw bool, pa
}
return &Path{
- source: source,
- IsWithdraw: isWithdraw,
- nlri: nlri,
- pathAttrs: pattrs,
- medSetByTargetNeighbor: medSetByTargetNeighbor,
- timestamp: timestamp,
- NoImplicitWithdraw: noImplicitWithdraw,
- Owner: owner,
- filtered: make(map[string]PolicyDirection),
+ source: source,
+ IsWithdraw: isWithdraw,
+ nlri: nlri,
+ pathAttrs: pattrs,
+ timestamp: timestamp,
+ NoImplicitWithdraw: noImplicitWithdraw,
+ Owner: owner,
+ filtered: make(map[string]PolicyDirection),
}
}
@@ -221,7 +219,7 @@ func (path *Path) Clone(owner net.IP, isWithdraw bool) *Path {
newPathAttrs[i] = v
}
- p := NewPath(path.source, path.nlri, isWithdraw, newPathAttrs, false, path.timestamp, path.NoImplicitWithdraw)
+ p := NewPath(path.source, path.nlri, isWithdraw, newPathAttrs, path.timestamp, path.NoImplicitWithdraw)
p.Validation = path.Validation
p.Owner = owner
p.key = path.key
@@ -293,14 +291,6 @@ func (path *Path) GetNlri() bgp.AddrPrefixInterface {
return path.nlri
}
-func (path *Path) setMedSetByTargetNeighbor(medSetByTargetNeighbor bool) {
- path.medSetByTargetNeighbor = medSetByTargetNeighbor
-}
-
-func (path *Path) getMedSetByTargetNeighbor() bool {
- return path.medSetByTargetNeighbor
-}
-
func (path *Path) GetPathAttrs() []bgp.PathAttributeInterface {
return path.pathAttrs
}
diff --git a/table/path_test.go b/table/path_test.go
index 98e59092..48dec6fe 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(), pathP[0].getMedSetByTargetNeighbor(), time.Now(), 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(), pathP[0].getMedSetByTargetNeighbor(), time.Now(), false)
+ ipv6p := NewPath(pathP[0].GetSource(), pathP[0].GetNlri(), true, pathP[0].GetPathAttrs(), time.Now(), false)
assert.NotNil(t, ipv6p)
}
@@ -49,22 +49,6 @@ func TestPathGetNlri(t *testing.T) {
assert.Equal(t, r_nlri, nlri)
}
-func TestPathSetMedSetByTargetNeighbor(t *testing.T) {
- pd := &Path{}
- msbt := true
- pd.setMedSetByTargetNeighbor(msbt)
- r_msbt := pd.getMedSetByTargetNeighbor()
- assert.Equal(t, r_msbt, msbt)
-}
-
-func TestPathGetMedSetByTargetNeighbor(t *testing.T) {
- pd := &Path{}
- msbt := true
- pd.setMedSetByTargetNeighbor(msbt)
- r_msbt := pd.getMedSetByTargetNeighbor()
- assert.Equal(t, r_msbt, msbt)
-}
-
func TestPathCreatePath(t *testing.T) {
peerP := PathCreatePeer()
msg := updateMsgP1()
@@ -72,7 +56,7 @@ func TestPathCreatePath(t *testing.T) {
nlriList := updateMsgP.NLRI
pathAttributes := updateMsgP.PathAttributes
nlri_info := nlriList[0]
- path := NewPath(peerP[0], nlri_info, false, pathAttributes, false, time.Now(), false)
+ path := NewPath(peerP[0], nlri_info, false, pathAttributes, time.Now(), false)
assert.NotNil(t, path)
}
@@ -117,7 +101,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, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
assert.Equal(10, p.GetAsPathLen())
}
@@ -143,7 +127,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, false, time.Now(), 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())
@@ -165,7 +149,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, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -193,7 +177,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, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -223,7 +207,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, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
asn := uint32(65000)
p.PrependAsn(asn, 1)
@@ -259,7 +243,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, false, time.Now(), false)
+ p := NewPath(peer[0], update.NLRI[0], false, update.PathAttributes, time.Now(), false)
expected := []uint32{65000, 65000}
for _, v := range asns {
@@ -288,7 +272,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, false, time.Now(), 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 4df99f86..d7cc0254 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, false, time.Time{}, 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 31c46b6b..f21acef0 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, false, now, 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, false, now, 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, false, now, 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, false, now, false)
+ path := NewPath(p, nlri, true, pathAttributes, now, false)
pathList = append(pathList, path)
}
}
@@ -186,7 +186,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, false, time.Now(), 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 f957cef1..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, false, time.Now(), false)
+ pathT[i] = NewPath(peerT[i], nlri_info, false, pathAttributes, time.Now(), false)
}
return pathT
}