summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-14 22:47:36 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-12-14 22:47:36 +0900
commitac6af737a7733612acf293ec5eb4c21932aa0e5d (patch)
tree1f1163f014c7d4b7062db52c05e61985a52c74f0
parente33c13b85a5188305ee698061ffffcb968d2979b (diff)
server: don't import path including looped as path
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--server/server.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/server/server.go b/server/server.go
index beeb85dc..b1690aae 100644
--- a/server/server.go
+++ b/server/server.go
@@ -439,6 +439,15 @@ func newSenderMsg(peer *Peer, messages []*bgp.BGPMessage) *SenderMsg {
}
}
+func isASLoop(peer *Peer, path *table.Path) bool {
+ for _, as := range path.GetAsList() {
+ if as == peer.conf.NeighborConfig.PeerAs {
+ return true
+ }
+ }
+ return false
+}
+
func filterpath(peer *Peer, path *table.Path) *table.Path {
if path == nil {
return nil
@@ -510,15 +519,8 @@ func filterpath(peer *Peer, path *table.Path) *table.Path {
return nil
}
- for _, as := range path.GetAsList() {
- if as == peer.conf.NeighborConfig.PeerAs {
- log.WithFields(log.Fields{
- "Topic": "Peer",
- "Key": remoteAddr,
- "Data": path,
- }).Debug("AS PATH loop, ignore.")
- return nil
- }
+ if isASLoop(peer, path) {
+ return nil
}
return path.Clone(remoteAddr, path.IsWithdraw)
}
@@ -665,6 +667,10 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []*
continue
}
for _, before := range pathList {
+ if isASLoop(targetPeer, before) {
+ before.Filter(targetPeer.ID(), table.POLICY_DIRECTION_IMPORT)
+ continue
+ }
after := server.policy.ApplyPolicy(targetPeer.TableID(), table.POLICY_DIRECTION_IMPORT, before)
if after == nil {
before.Filter(targetPeer.ID(), table.POLICY_DIRECTION_IMPORT)