Propagate depreferenced status through AbstractAdvertizedRoute 82/78482/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 21:53:20 +0000 (22:53 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 6 Dec 2018 01:38:55 +0000 (02:38 +0100)
AbstractPeer will need this info to differentiate which routes
to advertize when, propagate it out of selection state.

Change-Id: I83a243ffe98e55c719913f7c7b708b0ccab2cee2
JIRA: BGPCEP-495
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/api/BestPath.java
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/BaseRouteEntry.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractBestPath.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/AbstractAdvertizedRoute.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/ActualBestPathRoutes.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/entry/AdvertizedRoute.java

index c2a81e6c1323edab9577add3cdbb3e24d9480303..700971928df36a1997054ea4c9dad1c7aadea5cb 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.bgp.mode.api;
 
 import com.google.common.primitives.UnsignedInteger;
@@ -44,4 +43,11 @@ public interface BestPath {
      * @return pathId
      */
     long getPathId();
-}
\ No newline at end of file
+
+    /**
+     * Return true if this path is depreferenced.
+     *
+     * @return True if this path is depreferenced.
+     */
+    boolean isDepreferenced();
+}
index 1311ca50ccc3a79d8e973b218e4d1a7b15c68f82..cf5f5a86eb70484a5bdb147c3e21e35d5a722340 100644 (file)
@@ -131,7 +131,7 @@ public abstract class AddPathAbstractRouteEntry<C extends Routes & DataObject &
             // FIXME: can we use identity check here?
             final boolean isFirstBestPath = firstBestPath != null && firstBestPath.equals(path);
             final AdvertizedRoute<C, S, R, I> adv = new AdvertizedRoute<>(ribSupport, isFirstBestPath,
-                    routeAddPath, path.getAttributes(), path.getPeerId());
+                    routeAddPath, path.getAttributes(), path.getPeerId(), path.isDepreferenced());
             advertized.add(adv);
         }
         this.newBestPathToBeAdvertised = null;
@@ -148,7 +148,7 @@ public abstract class AddPathAbstractRouteEntry<C extends Routes & DataObject &
         for (final AddPathBestPath path : this.bestPath) {
             final R route = createRoute(ribSupport, entryInfo.getRouteKey(), path.getPathId(), path);
             final ActualBestPathRoutes<C, S, R, I> adv = new ActualBestPathRoutes<>(ribSupport, route, path.getPeerId(),
-                    path.getAttributes());
+                    path.getAttributes(), path.isDepreferenced());
             preexistentRoutes.add(adv);
         }
         return preexistentRoutes;
index b1c35906ddd273bf0d07d99e4bdb9cf34f6b4bbd..a8be574a836d693593d0b6d5964c3ce0fde6ce54 100644 (file)
@@ -54,7 +54,7 @@ final class BaseRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
         return this.offsets.isEmpty();
     }
 
-    private  R createRoute(final RIBSupport<C, S, R, I> ribSup, String routeKey, final long pathId,
+    private  R createRoute(final RIBSupport<C, S, R, I> ribSup, final String routeKey, final long pathId,
             final BaseBestPath path) {
         final R route = this.offsets.getValue(this.values, this.offsets.offsetOf(path.getRouterId()));
         return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
@@ -123,7 +123,7 @@ final class BaseRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
         }
         final R route = createRoute(ribSupport, routeKey, this.bestPath.getPathId(), this.bestPath);
         final AdvertizedRoute<C, S, R, I> adv = new AdvertizedRoute<>(ribSupport, route, this.bestPath.getAttributes(),
-                this.bestPath.getPeerId());
+                this.bestPath.getPeerId(), this.bestPath.isDepreferenced());
         LOG.trace("Selected best route {}", route);
         return Collections.singletonList(adv);
     }
@@ -136,6 +136,6 @@ final class BaseRouteEntry<C extends Routes & DataObject & ChoiceIn<Tables>,
         }
         final R route = createRoute(ribSupport, entryInfo.getRouteKey(), this.bestPath.getPathId(), this.bestPath);
         return Collections.singletonList(new ActualBestPathRoutes<>(ribSupport, route, this.bestPath.getPeerId(),
-                this.bestPath.getAttributes()));
+                this.bestPath.getAttributes(), this.bestPath.isDepreferenced()));
     }
 }
\ No newline at end of file
index 2f124da3cd69a16c46da38ba4293ce6dfd9a4ac4..74e6baed38bd5b9d56a69618937101e56474e067 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.bgp.mode.spi;
 
 import static java.util.Objects.requireNonNull;
@@ -35,6 +34,11 @@ public abstract class AbstractBestPath implements BestPath {
         return this.state.getAttributes();
     }
 
+    @Override
+    public final boolean isDepreferenced() {
+        return this.state.isDepreferenced();
+    }
+
     @Override
     public final String toString() {
         return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
index 9d1cc387b5f1623b0101ccc8b639a47b2d5ca40d..2d974e58c4b21c1d10f11a2285baff4143c4b1e8 100644 (file)
@@ -38,12 +38,14 @@ public abstract class AbstractAdvertizedRoute<C extends Routes & DataObject & Ch
     private final Attributes attributes;
     private final I nonAddPathRouteKeyIdentifier;
     private final I addPathRouteKeyIdentifier;
+    private final boolean depreferenced;
 
     AbstractAdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final R route, final PeerId fromPeerId,
-            final Attributes attributes) {
+            final Attributes attributes, final boolean depreferenced) {
         this.fromPeerId = fromPeerId;
         this.route = route;
         this.attributes = attributes;
+        this.depreferenced = depreferenced;
 
         final @NonNull String routeKey = verifyNotNull(route.getRouteKey());
         this.nonAddPathRouteKeyIdentifier = ribSupport.createRouteListKey(NON_PATH_ID_VALUE, routeKey);
@@ -62,6 +64,10 @@ public abstract class AbstractAdvertizedRoute<C extends Routes & DataObject & Ch
         return attributes;
     }
 
+    public final boolean isDepreferenced() {
+        return depreferenced;
+    }
+
     @Override
     public final I getNonAddPathRouteKeyIdentifier() {
         return this.nonAddPathRouteKeyIdentifier;
index b24a41d43a048c077bcc4f5f0fce1a1f105929dd..24b7c5598c48753963dbb7544597aa51cb40fcb4 100644 (file)
@@ -30,7 +30,7 @@ public final class ActualBestPathRoutes<C extends Routes & DataObject & ChoiceIn
         I extends Identifier<R>> extends AbstractAdvertizedRoute<C, S, R, I> {
 
     public ActualBestPathRoutes(final RIBSupport<C, S, R, I> ribSupport, final R route, final PeerId fromPeerId,
-            final Attributes attributes) {
-        super(ribSupport, route, fromPeerId, attributes);
+            final Attributes attributes, final boolean depreferenced) {
+        super(ribSupport, route, fromPeerId, attributes, depreferenced);
     }
 }
index 71489d5a6eb50ceea6b4d2b712318ebeb798ceea..b78af61d4d7483a822f7a98e0a72ddf5487bab8c 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.protocol.bgp.rib.spi.entry;
 
 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
@@ -31,13 +30,13 @@ public final class AdvertizedRoute<C extends Routes & DataObject & ChoiceIn<Tabl
     private final boolean isFirstBestPath;
 
     public AdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final R route, final Attributes attributes,
-            final PeerId fromPeerId) {
-        this(ribSupport, true, route, attributes, fromPeerId);
+            final PeerId fromPeerId, final boolean depreferenced) {
+        this(ribSupport, true, route, attributes, fromPeerId, depreferenced);
     }
 
     public AdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final boolean isFirstBestPath,
-            final R route, final Attributes attributes, final PeerId fromPeerId) {
-        super(ribSupport, route, fromPeerId, attributes);
+            final R route, final Attributes attributes, final PeerId fromPeerId, final boolean depreferenced) {
+        super(ribSupport, route, fromPeerId, attributes, depreferenced);
         this.isFirstBestPath = isFirstBestPath;
     }