BUG-6427: Application peer doesnt announce routes 15/44015/1
authorClaudio D. Gasparini <cgaspari@cisco.com>
Mon, 15 Aug 2016 18:51:11 +0000 (20:51 +0200)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Mon, 15 Aug 2016 20:28:43 +0000 (22:28 +0200)
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 <cgaspari@cisco.com>
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/add/AddPathAbstractRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/base/BaseAbstractRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractRouteEntry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ExportPolicyPeerTrackerImpl.java

index 7725180ceb3612caa039e9b9400e47c686181916..395811b2f7c041bd4094ab0ccbb3959498a642f8 100644 (file)
@@ -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<PeerId, PeerExporTuple> 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,
index fe1cf37f0e325fdfe97dabde1bf15439c13718d1..aca064cb45d083bc9b799f075050b2b573823f98 100644 (file)
@@ -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));
             }
         }
index 1bc617d1108a3c3c8fb54b04f8d8565b27125b51..1a58a0df190bacb32de6a53c8d5ed877a48ca6c8 100644 (file)
@@ -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) {
index f7eec81f32e7c754313382800f2db7178d9bc8de..ec61de5ea182b3f8d82cda2030e9210e9b65299a 100644 (file)
@@ -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<PeerRole, PeerExportGroup> ret = peerPathRoles.values().stream().collect(Collectors.toSet()).stream().filter(role -> role != PeerRole.Internal)
+        final Map<PeerRole, PeerExportGroup> 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)));