summaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-03-19 17:18:16 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-03-19 17:18:16 +0900
commit9152c24906d712ab1334e22df6d9b48c38cdf665 (patch)
tree99201b7e5bfb8097fa999b4da701b4182986d79c /server
parent0076c6d4104c1c03715683b11766c69ebfeaee87 (diff)
table: remove unnecessary distinction of paths
struct Path has a flag which can tell whether the path is withdrawal path or not. so table.ProcessPaths() needs not to return withdrawal path and non-withdrawal path separetly. this removes such unnecessary distinction. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r--server/peer.go26
-rw-r--r--server/peer_test.go8
2 files changed, 13 insertions, 21 deletions
diff --git a/server/peer.go b/server/peer.go
index 2efceeac..c237aff7 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -311,18 +311,10 @@ func (peer *Peer) handleREST(restReq *api.RestRequest) {
close(restReq.ResponseCh)
}
-func (peer *Peer) sendUpdateMsgFromPaths(pList []table.Path, wList []table.Path) {
- pathList := append([]table.Path(nil), pList...)
- pathList = append(pathList, wList...)
-
- for _, p := range wList {
- if !p.IsWithdraw() {
- log.Fatal("withdraw pathlist has non withdraw path")
- }
- }
- peer.adjRib.UpdateOut(pathList)
+func (peer *Peer) sendUpdateMsgFromPaths(pList []table.Path) {
+ peer.adjRib.UpdateOut(pList)
sendpathList := []table.Path{}
- for _, p := range pathList {
+ for _, p := range pList {
if _, ok := peer.rfMap[p.GetRouteFamily()]; ok {
sendpathList = append(sendpathList, p)
}
@@ -333,12 +325,12 @@ func (peer *Peer) sendUpdateMsgFromPaths(pList []table.Path, wList []table.Path)
func (peer *Peer) handlePeerMsg(m *peerMsg) {
switch m.msgType {
case PEER_MSG_PATH:
- pList, wList, _ := peer.rib.ProcessPaths(m.msgData.([]table.Path))
- peer.sendUpdateMsgFromPaths(pList, wList)
+ pList, _ := peer.rib.ProcessPaths(m.msgData.([]table.Path))
+ peer.sendUpdateMsgFromPaths(pList)
case PEER_MSG_PEER_DOWN:
for _, rf := range peer.configuredRFlist() {
- pList, wList, _ := peer.rib.DeletePathsforPeer(m.msgData.(*table.PeerInfo), rf)
- peer.sendUpdateMsgFromPaths(pList, wList)
+ pList, _ := peer.rib.DeletePathsforPeer(m.msgData.(*table.PeerInfo), rf)
+ peer.sendUpdateMsgFromPaths(pList)
}
}
}
@@ -356,8 +348,8 @@ func (peer *Peer) handleServerMsg(m *serverMsg) {
if _, ok := peer.siblings[d.Address.String()]; ok {
delete(peer.siblings, d.Address.String())
for _, rf := range peer.configuredRFlist() {
- pList, wList, _ := peer.rib.DeletePathsforPeer(d, rf)
- peer.sendUpdateMsgFromPaths(pList, wList)
+ pList, _ := peer.rib.DeletePathsforPeer(d, rf)
+ peer.sendUpdateMsgFromPaths(pList)
}
} else {
log.Warning("can not find peer: ", d.Address.String())
diff --git a/server/peer_test.go b/server/peer_test.go
index cceb6992..f8703d2c 100644
--- a/server/peer_test.go
+++ b/server/peer_test.go
@@ -69,9 +69,9 @@ func TestProcessBGPUpdate_fourbyteAS(t *testing.T) {
msg := table.NewProcessMessage(m, peerInfo)
pathList := msg.ToPathList()
- pList, wList, _ := rib1.ProcessPaths(pathList)
+ pList, _ := rib1.ProcessPaths(pathList)
assert.Equal(t, len(pList), 1)
- assert.Equal(t, len(wList), 0)
+ assert.Equal(t, pList[0].IsWithdraw(), false)
fmt.Println(pList)
sendMsg := table.CreateUpdateMsgFromPaths(pList)
assert.Equal(t, len(sendMsg), 1)
@@ -87,9 +87,9 @@ func TestProcessBGPUpdate_fourbyteAS(t *testing.T) {
assert.Equal(t, attrAS.Value[0].(*bgp.AsPathParam).AS, []uint16{bgp.AS_TRANS, 4000, bgp.AS_TRANS})
rib2 := table.NewTableManager("peer_test", []bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC})
- pList2, wList2, _ := rib2.ProcessPaths(pathList)
+ pList2, _ := rib2.ProcessPaths(pathList)
assert.Equal(t, len(pList2), 1)
- assert.Equal(t, len(wList2), 0)
+ assert.Equal(t, pList[0].IsWithdraw(), false)
sendMsg2 := table.CreateUpdateMsgFromPaths(pList2)
assert.Equal(t, len(sendMsg2), 1)
update2 := sendMsg2[0].Body.(*bgp.BGPUpdate)