diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-03 21:54:38 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-01-03 21:54:38 +0900 |
commit | a41413ae86c5666c84d4e0cdc52e832c704ab9a6 (patch) | |
tree | 91a0311d82e1b840a76a3effe2b103258ae8cf03 /server/peer.go | |
parent | 48f95fa12b4c9a223a9dbd85baf8c7158327a49e (diff) |
server: fix PEER_MSG_PATH about rf
send PEER_MSG_PATH to only peers that have the same rf.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/server/peer.go b/server/peer.go index b65edc11..a54a8af4 100644 --- a/server/peer.go +++ b/server/peer.go @@ -132,7 +132,9 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) { msgData: pathList, } for _, s := range peer.siblings { - // TODO: check rf + if s.rf != peer.rf { + continue + } s.peerMsgCh <- pm } } @@ -166,27 +168,27 @@ func (peer *Peer) handleREST(restReq *api.RestRequest) { close(restReq.ResponseCh) } -func (peer *Peer) handlePeerMsg(m *peerMsg) { - sendpath := func(pList []table.Path, wList []table.Path) { - pathList := append([]table.Path(nil), pList...) - pathList = append(pathList, wList...) +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") - } + for _, p := range wList { + if !p.IsWithdraw() { + log.Fatal("withdraw pathlist has non withdraw path") } - peer.adjRib.UpdateOut(pathList) - peer.sendMessages(table.CreateUpdateMsgFromPaths(pathList)) } + peer.adjRib.UpdateOut(pathList) + peer.sendMessages(table.CreateUpdateMsgFromPaths(pathList)) +} +func (peer *Peer) handlePeerMsg(m *peerMsg) { switch m.msgType { case PEER_MSG_PATH: pList, wList, _ := peer.rib.ProcessPaths(m.msgData.([]table.Path)) - sendpath(pList, wList) + peer.sendUpdateMsgFromPaths(pList, wList) case PEER_MSG_PEER_DOWN: pList, wList, _ := peer.rib.DeletePathsforPeer(m.msgData.(*table.PeerInfo)) - sendpath(pList, wList) + peer.sendUpdateMsgFromPaths(pList, wList) } } @@ -204,7 +206,9 @@ func (peer *Peer) handleServerMsg(m *serverMsg) { msgData: pathList, } for _, s := range peer.siblings { - // TODO: check rf + if s.rf != peer.rf { + continue + } s.peerMsgCh <- pm } case SRV_MSG_PEER_DELETED: @@ -212,7 +216,8 @@ func (peer *Peer) handleServerMsg(m *serverMsg) { _, found := peer.siblings[d.Address.String()] if found { delete(peer.siblings, d.Address.String()) - // TODO: do the same that PEER_MSG_PEER_DOWN handler + pList, wList, _ := peer.rib.DeletePathsforPeer(d) + peer.sendUpdateMsgFromPaths(pList, wList) } else { log.Warning("can not find peer: ", d.Address.String()) } |