From b01b7ff7bc40416b401f8398f07764c18ef23f0c Mon Sep 17 00:00:00 2001 From: "Claudio D. Gasparini" Date: Mon, 15 Aug 2016 20:51:11 +0200 Subject: [PATCH] BUG-6427: Application peer doesnt announce routes Application peer doesnt announce routes. Fix by add Internal Role group to Exporgroup. Also filter routes by peer destination role, to avoid unnecessary do remove to a non-existing route. Change-Id: I3619b93d6d511bd6b4ef353b8a2f62a9b4a9b661 Signed-off-by: Claudio D. Gasparini --- .../bgp/mode/impl/add/AddPathAbstractRouteEntry.java | 8 +++++--- .../bgp/mode/impl/base/BaseAbstractRouteEntry.java | 9 +++++---- .../protocol/bgp/mode/spi/AbstractRouteEntry.java | 5 +++-- .../bgp/rib/impl/ExportPolicyPeerTrackerImpl.java | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java index 7725180ceb..395811b2f7 100644 --- a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java +++ b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java @@ -111,7 +111,8 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry { final DOMDataWriteTransaction tx) { final boolean destPeerSupAddPath = peerPT.isAddPathSupportedByPeer(destPeer); if(this.bestPath != null) { - this.bestPath.stream().filter(path -> filterRoutes(path.getPeerId(), destPeer, peerPT, localTK, discPeers) && + final PeerRole destPeerRole = getRoutePeerIdRole(peerPT, destPeer); + this.bestPath.stream().filter(path -> filterRoutes(path.getPeerId(), destPeer, peerPT, localTK, discPeers, destPeerRole) && peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath(this.bestPath.indexOf(path)))) .forEach(path -> writeRoutePath(destPeer, routeId, peerPT, peerGroup, destPeerSupAddPath, path, rootPath, localTK, ribSup, tx)); } @@ -168,11 +169,12 @@ public abstract class AddPathAbstractRouteEntry extends AbstractRouteEntry { for (final PeerRole role : PeerRole.values()) { final PeerExportGroup peerGroup = peerPT.getPeerGroup(role); if (peerGroup != null) { - final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT, routePeerId), attributes); + final PeerRole destPeerRole = getRoutePeerIdRole(peerPT, routePeerId); + final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(destPeerRole, attributes); for (final Map.Entry pid : peerGroup.getPeers()) { final PeerId destPeer = pid.getKey(); final boolean destPeerSupAddPath = peerPT.isAddPathSupportedByPeer(destPeer); - if (filterRoutes(routePeerId, destPeer, peerPT, localTK, discPeers) && peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath)) { + if (filterRoutes(routePeerId, destPeer, peerPT, localTK, discPeers, destPeerRole) && peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath)) { if (destPeerSupAddPath) { update(destPeer, getAdjRibOutYII(ribSup, pid.getValue().getYii(), routeIdAddPath, localTK), effectiveAttributes, addPathValue, diff --git a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseAbstractRouteEntry.java b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseAbstractRouteEntry.java index fe1cf37f0e..aca064cb45 100644 --- a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseAbstractRouteEntry.java +++ b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseAbstractRouteEntry.java @@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.mode.impl.base; import com.google.common.annotations.VisibleForTesting; import com.google.common.primitives.UnsignedInteger; -import java.util.Optional; import javax.annotation.concurrent.NotThreadSafe; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; @@ -121,7 +120,8 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry { final DOMDataWriteTransaction tx) { if (this.bestPath != null) { final BaseBestPath path = this.bestPath; - if (filterRoutes(path.getPeerId(), destPeer, peerPT, localTK, discPeers)) { + final PeerRole destPeerRole = getRoutePeerIdRole(peerPT, destPeer); + if (filterRoutes(path.getPeerId(), destPeer, peerPT, localTK, discPeers, destPeerRole)) { final ContainerNode effAttrib = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT,path.getPeerId()), path.getAttributes()); writeRoute(destPeer, getAdjRibOutYII(ribSup, rootPath, routeId, localTK), effAttrib, createValue(routeId, path), ribSup, tx); } @@ -181,9 +181,10 @@ abstract class BaseAbstractRouteEntry extends AbstractRouteEntry { for (final PeerRole role : PeerRole.values()) { final PeerExportGroup peerGroup = peerPT.getPeerGroup(role); if (peerGroup != null) { - final ContainerNode effAttrib = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT,routePeerId), attributes); + final PeerRole destPeerRole = getRoutePeerIdRole(peerPT, routePeerId); + final ContainerNode effAttrib = peerGroup.effectiveAttributes(destPeerRole, attributes); peerGroup.getPeers().stream() - .filter(pid -> filterRoutes(routePeerId, pid.getKey(), peerPT, localTK, discPeers)) + .filter(pid -> filterRoutes(routePeerId, pid.getKey(), peerPT, localTK, discPeers, destPeerRole)) .forEach(pid -> update(pid.getKey(), getAdjRibOutYII(ribSup, pid.getValue().getYii(), routeId, localTK), effAttrib, value, ribSup, tx)); } } diff --git a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractRouteEntry.java b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractRouteEntry.java index 1bc617d110..1a58a0df19 100644 --- a/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractRouteEntry.java +++ b/bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractRouteEntry.java @@ -56,8 +56,9 @@ public abstract class AbstractRouteEntry implements RouteEntry { } protected final boolean filterRoutes(final PeerId rootPeer, final PeerId destPeer, final ExportPolicyPeerTracker peerPT, - final TablesKey localTK, final CacheDisconnectedPeers discPeers) { - return !rootPeer.equals(destPeer) && isTableSupported(destPeer, peerPT, localTK) && !discPeers.isPeerDisconnected(destPeer); + final TablesKey localTK, final CacheDisconnectedPeers discPeers, final PeerRole destPeerRole) { + return !rootPeer.equals(destPeer) && isTableSupported(destPeer, peerPT, localTK) && !discPeers.isPeerDisconnected(destPeer) && + !PeerRole.Internal.equals(destPeerRole); } private boolean isTableSupported(final PeerId destPeer, final ExportPolicyPeerTracker peerPT, final TablesKey localTK) { diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ExportPolicyPeerTrackerImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ExportPolicyPeerTrackerImpl.java index f7eec81f32..ec61de5ea1 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ExportPolicyPeerTrackerImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ExportPolicyPeerTrackerImpl.java @@ -68,7 +68,7 @@ final class ExportPolicyPeerTrackerImpl implements ExportPolicyPeerTracker { .collect(Collectors.groupingBy(Map.Entry::getValue, toMap(peer -> IdentifierUtils.peerKeyToPeerId(peer .getKey()), peer -> new PeerExporTuple(peer.getKey(), peer.getValue())))); - final Map ret = peerPathRoles.values().stream().collect(Collectors.toSet()).stream().filter(role -> role != PeerRole.Internal) + final Map ret = peerPathRoles.values().stream().collect(Collectors.toSet()).stream() .collect(toMap(identity(), role -> new PeerExportGroupImpl(ImmutableMap.copyOf(immutablePeers.get(role)), this.policyDatabase.exportPolicyForRole(role)), (oldKey, newKey) -> oldKey, () -> new EnumMap<>(PeerRole.class))); -- 2.36.6