summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--table/destination.go23
-rw-r--r--table/destination_test.go36
-rw-r--r--table/table.go20
-rw-r--r--table/table_test.go37
-rw-r--r--table/temporary_structs.go5
5 files changed, 3 insertions, 118 deletions
diff --git a/table/destination.go b/table/destination.go
index 16a71f54..5e209712 100644
--- a/table/destination.go
+++ b/table/destination.go
@@ -54,8 +54,6 @@ type Destination interface {
String() string
addWithdraw(withdraw Path)
addNewPath(newPath Path)
- addSentRoute(sentRoute *SentRoute)
- removeSentRoute(peer *Peer) bool
constructWithdrawPath() Path
removeOldPathsFromSource(source *Peer) []Path
}
@@ -69,7 +67,6 @@ type DestinationDefault struct {
bestPath Path
bestPathReason string
oldBestPath Path
- sentRoutes map[*Peer]*SentRoute
}
func NewDestinationDefault(nlri bgp.AddrPrefixInterface) *DestinationDefault {
@@ -82,7 +79,6 @@ func NewDestinationDefault(nlri bgp.AddrPrefixInterface) *DestinationDefault {
destination.bestPath = nil
destination.bestPathReason = ""
destination.oldBestPath = nil
- destination.sentRoutes = make(map[*Peer]*SentRoute)
return destination
}
@@ -134,27 +130,12 @@ func (dd *DestinationDefault) addWithdraw(withdraw Path) {
dd.validatePath(withdraw)
dd.withdrawList = append(dd.withdrawList, withdraw)
}
+
func (dd *DestinationDefault) addNewPath(newPath Path) {
dd.validatePath(newPath)
dd.newPathList = append(dd.newPathList, newPath)
}
-func (dd *DestinationDefault) addSentRoute(sentRoute *SentRoute) {
- dd.sentRoutes[sentRoute.peer] = sentRoute
-}
-func (dd *DestinationDefault) removeSentRoute(peer *Peer) bool {
- if dd.wasSentTo(peer) {
- delete(dd.sentRoutes, peer)
- return true
- }
- return false
-}
-func (dd *DestinationDefault) wasSentTo(peer *Peer) bool {
- _, ok := dd.sentRoutes[peer]
- if ok {
- return true
- }
- return false
-}
+
func (dd *DestinationDefault) removeOldPathsFromSource(source *Peer) []Path {
removePaths := make([]Path, 0)
sourceVerNum := source.VersionNum
diff --git a/table/destination_test.go b/table/destination_test.go
index 33cc379a..066ee98b 100644
--- a/table/destination_test.go
+++ b/table/destination_test.go
@@ -110,42 +110,6 @@ func TestDestinationCalculate(t *testing.T) {
assert.Nil(t, e)
}
-func TestDestinationRemoveSentRoute(t *testing.T) {
- peerD := DestCreatePeer()
- msgD := DestCreateMSG(peerD)
- pathD := DestCreatePath(msgD)
- ipv4d := NewIPv4Destination(pathD[0].getNlri())
- //sent route and remove sent route
- sroute1 := &SentRoute{path: pathD[0], peer: peerD[0]}
- sroute2 := &SentRoute{path: pathD[1], peer: peerD[0]}
- sroute3 := &SentRoute{path: pathD[2], peer: peerD[1]}
- ipv4d.addSentRoute(sroute1)
- ipv4d.addSentRoute(sroute2)
- ipv4d.addSentRoute(sroute3)
- result := ipv4d.removeSentRoute(peerD[2])
- assert.Equal(t, result, false)
- result = ipv4d.removeSentRoute(peerD[1])
- assert.Equal(t, result, true)
-}
-
-func TestDestinationRemoveOldPathsFromSource(t *testing.T) {
- peerD := DestCreatePeer()
- msgD := DestCreateMSG(peerD)
- pathD := DestCreatePath(msgD)
- ipv4d := NewIPv4Destination(pathD[0].getNlri())
- sroute1 := &SentRoute{path: pathD[0], peer: peerD[0]}
- sroute2 := &SentRoute{path: pathD[1], peer: peerD[0]}
- sroute3 := &SentRoute{path: pathD[2], peer: peerD[1]}
- ipv4d.addSentRoute(sroute1)
- ipv4d.addSentRoute(sroute2)
- ipv4d.addSentRoute(sroute3)
- compPath := make([]Path, 0)
- for _, peer := range peerD {
- r_path := ipv4d.removeOldPathsFromSource(peer)
- assert.Equal(t, r_path, compPath)
- }
-}
-
func DestCreatePeer() []*Peer {
peerD1 := &Peer{VersionNum: 4, RemoteAs: 65000}
peerD2 := &Peer{VersionNum: 4, RemoteAs: 65001}
diff --git a/table/table.go b/table/table.go
index 87c92ddd..9b1aaa08 100644
--- a/table/table.go
+++ b/table/table.go
@@ -74,26 +74,6 @@ func insert(table Table, path Path) Destination {
}
return dest
}
-func insertSentRoute(table Table, sentRoute *SentRoute) {
- pd := sentRoute.path
- table.validatePath(pd)
- dest := getOrCreateDest(table, pd.getNlri())
- dest.addSentRoute(sentRoute)
-}
-
-//"Remove old paths from whose source is `peer`
-func (td *TableDefault) cleanupPathsForPeer(peer *Peer) {
- for _, dest := range td.destinations {
- pathsDeleted := dest.removeOldPathsFromSource(peer)
- hadSent := dest.removeSentRoute(peer)
- if hadSent {
- logger.Errorf("Cleaning paths from table %s for peer %s.", td, peer)
- }
- if pathsDeleted != nil {
- //need _signal_bus.dest_changed(dest)
- }
- }
-}
/*
//Cleans table of any path that do not have any RT in common with interested_rts
diff --git a/table/table_test.go b/table/table_test.go
index 35eddea9..094b6500 100644
--- a/table/table_test.go
+++ b/table/table_test.go
@@ -35,43 +35,6 @@ func TestTableTableKeyDefault(t *testing.T) {
assert.Nil(t, tk)
}
-func TestTableInsertSentRoute(t *testing.T) {
- peerT := TableCreatePeer()
- msgT := TableCreateMSG(peerT)
- pathT := TableCreatePath(msgT)
- ipv4t := NewIPv4Table(0)
- for _, path := range pathT {
- tableKey := ipv4t.tableKey(path.getNlri())
- dest := ipv4t.createDest(path.getNlri())
- ipv4t.setDestination(tableKey.String(), dest)
- }
- sroute := &SentRoute{path: pathT[0], peer: peerT[0]}
- insertSentRoute(ipv4t, sroute)
- tableKey := ipv4t.tableKey(pathT[0].getNlri())
- dest := ipv4t.getDestination(tableKey.String())
- sr := dest.removeSentRoute(peerT[0])
- assert.Equal(t, sr, true)
-}
-
-func TestTableCleanupPathsForPeer(t *testing.T) {
- peerT := TableCreatePeer()
- msgT := TableCreateMSG(peerT)
- pathT := TableCreatePath(msgT)
- ipv4t := NewIPv4Table(0)
- for _, path := range pathT {
- tableKey := ipv4t.tableKey(path.getNlri())
- dest := ipv4t.createDest(path.getNlri())
- ipv4t.setDestination(tableKey.String(), dest)
- }
- sroute := &SentRoute{path: pathT[0], peer: peerT[0]}
- insertSentRoute(ipv4t, sroute)
- ipv4t.cleanupPathsForPeer(peerT[0])
- tableKey := ipv4t.tableKey(pathT[0].getNlri())
- dest := ipv4t.getDestination(tableKey.String())
- cpfp := dest.removeSentRoute(peerT[0])
- assert.Equal(t, cpfp, false)
-}
-
func TestTableDeleteDestByNlri(t *testing.T) {
peerT := TableCreatePeer()
msgT := TableCreateMSG(peerT)
diff --git a/table/temporary_structs.go b/table/temporary_structs.go
index a561aa72..f892f625 100644
--- a/table/temporary_structs.go
+++ b/table/temporary_structs.go
@@ -13,10 +13,7 @@ type Peer struct {
RemoteAddress net.IP
protocol *BgpProtocol
}
-type SentRoute struct {
- path Path
- peer *Peer
-}
+
type BgpProtocol struct {
//need to define a structure
recvOpenMsg *bgp.BGPOpen