diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-05-14 08:41:29 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-05-14 08:41:29 +0900 |
commit | f9a997b6b26ae5084c3e1e36bd1638be9166046a (patch) | |
tree | 60ded15f3c77c081bb030d3c6a204adec0a78940 /server | |
parent | 3b6fe71343ab742dfdea5aab8cdcb47b6652e096 (diff) |
server: don't path information if path include the same AS number
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/peer.go | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/server/peer.go b/server/peer.go index 8687b106..2a4e71a0 100644 --- a/server/peer.go +++ b/server/peer.go @@ -162,14 +162,40 @@ func (peer *Peer) sendPathsToSiblings(pathList []table.Path) { if len(pathList) == 0 { return } - pm := &peerMsg{ - msgType: PEER_MSG_PATH, - msgData: pathList, - } for _, s := range peer.siblings { - if peer.peerConfig.RouteServer.RouteServerClient && peer.peerConfig.PeerAs == s.As { - // don't send to a peer having the same AS number. - continue + var pm *peerMsg + if peer.peerConfig.RouteServer.RouteServerClient { + checkas := func(asnum uint32, p []table.Path) []table.Path { + plist := []table.Path{} + for _, path := range p { + asList := path.GetAsList() + send := true + for _, as := range asList { + if as == asnum { + send = false + break + } + } + if send { + plist = append(plist, path) + } + } + return plist + } + p := checkas(s.As, pathList) + if len(p) == 0 { + continue + } else { + pm = &peerMsg{ + msgType: PEER_MSG_PATH, + msgData: p, + } + } + } else { + pm = &peerMsg{ + msgType: PEER_MSG_PATH, + msgData: pathList, + } } s.peerMsgCh <- pm } |