Teach AbstractBestPathSelector about depreferenced routes 73/78473/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 17:48:07 +0000 (18:48 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 19:30:06 +0000 (20:30 +0100)
draft-uttaro-idr-bgp-persistence-04 mandates that routes tagged
with LLGR_STALE are to be used as routes of least preference.

Teach best path selection about this use it as the first step
of discrimination: depreferenced paths will always lose to
non-depreferenced paths.

JIRA: BGPCEP-495
Change-Id: I81a1ba1d09c554dee754329b5a907fbff3d6bf84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/spi/AbstractBestPathSelector.java

index 26740f33f191fa7bf57bd687a19b20e1f7d81f6d..45d2636a01f5189ba6d8d9db72de7a993ebc7c53 100644 (file)
@@ -47,6 +47,12 @@ public class AbstractBestPathSelector {
      * @return true if the existing path is better, false if the new path is better
      */
     protected boolean isExistingPathBetter(@Nonnull final BestPathState state) {
+        // 0. draft-uttaro-idr-bgp-persistence-04 defines "depreferenced" paths
+        final boolean stateDepref = state.isDepreferenced();
+        if (this.bestState.isDepreferenced() != stateDepref) {
+            return stateDepref;
+        }
+
         // 1. prefer path with accessible nexthop
         // - we assume that all nexthops are accessible
         /*