summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/server/server.go b/server/server.go
index 08775593..2900f55b 100644
--- a/server/server.go
+++ b/server/server.go
@@ -470,6 +470,8 @@ func filterpath(peer *Peer, pathList []*table.Path) []*table.Path {
continue
}
+ remoteAddr := peer.conf.NeighborConfig.NeighborAddress
+
//iBGP handling
if !path.IsLocal() && peer.isIBGPPeer() {
ignore := true
@@ -485,7 +487,7 @@ func filterpath(peer *Peer, pathList []*table.Path) []*table.Path {
if id := path.GetOriginatorID(); peer.gConf.GlobalConfig.RouterId.Equal(id) {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": remoteAddr,
"OriginatorID": id,
"Data": path,
}).Debug("Originator ID is mine, ignore")
@@ -502,7 +504,7 @@ func filterpath(peer *Peer, pathList []*table.Path) []*table.Path {
if clusterId.Equal(peer.peerInfo.RouteReflectorClusterID) {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": remoteAddr,
"ClusterID": clusterId,
"Data": path,
}).Debug("cluster list path attribute has local cluster id, ignore")
@@ -515,17 +517,17 @@ func filterpath(peer *Peer, pathList []*table.Path) []*table.Path {
if ignore {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": remoteAddr,
"Data": path,
}).Debug("From same AS, ignore.")
continue
}
}
- if peer.conf.NeighborConfig.NeighborAddress.Equal(path.GetSource().Address) {
+ if remoteAddr.Equal(path.GetSource().Address) {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": remoteAddr,
"Data": path,
}).Debug("From me, ignore.")
continue
@@ -542,12 +544,12 @@ func filterpath(peer *Peer, pathList []*table.Path) []*table.Path {
if !send {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.conf.NeighborConfig.NeighborAddress,
+ "Key": remoteAddr,
"Data": path,
}).Debug("AS PATH loop, ignore.")
continue
}
- filtered = append(filtered, path.Clone(path.IsWithdraw))
+ filtered = append(filtered, path.Clone(remoteAddr, path.IsWithdraw))
}
return filtered
}
@@ -671,11 +673,11 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []*
if rib.OwnerName() == GLOBAL_RIB_NAME || rib.OwnerName() == neighborAddress {
continue
}
- sendPathList, _ := rib.ProcessPaths(targetPeer.ApplyPolicy(POLICY_DIRECTION_IMPORT, filterpath(targetPeer, pathList)))
+ sendPathList, _ := rib.ProcessPaths(targetPeer.ApplyPolicy(POLICY_DIRECTION_IMPORT, pathList))
if targetPeer.fsm.state != bgp.BGP_FSM_ESTABLISHED || len(sendPathList) == 0 {
continue
}
- sendPathList = targetPeer.ApplyPolicy(POLICY_DIRECTION_EXPORT, sendPathList)
+ sendPathList = targetPeer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(targetPeer, sendPathList))
if len(sendPathList) == 0 {
continue
}
@@ -757,15 +759,14 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan *
pathList := make([]*table.Path, 0)
if peer.isRouteServerClient() {
rib := server.localRibMap[peer.conf.NeighborConfig.NeighborAddress.String()]
- pathList = peer.ApplyPolicy(POLICY_DIRECTION_EXPORT, peer.getBests(rib))
+ pathList = peer.ApplyPolicy(POLICY_DIRECTION_EXPORT, filterpath(peer, peer.getBests(rib)))
} else {
rib := server.localRibMap[GLOBAL_RIB_NAME]
l, _ := peer.fsm.LocalHostPort()
peer.conf.Transport.TransportConfig.LocalAddress = net.ParseIP(l)
for _, path := range filterpath(peer, peer.getBests(rib)) {
- p := path.Clone(path.IsWithdraw)
- p.UpdatePathAttrs(&server.bgpConfig.Global, &peer.conf)
- pathList = append(pathList, p)
+ path.UpdatePathAttrs(&server.bgpConfig.Global, &peer.conf)
+ pathList = append(pathList, path)
}
}
if len(pathList) > 0 {