From bc57522a4a53f181c9f1be7865a79b35103887c2 Mon Sep 17 00:00:00 2001 From: Olivier Dugeon Date: Fri, 10 Jul 2020 17:21:03 +0200 Subject: [PATCH] Fix Unreserved Bandwidth verification in algo Path Computation Algorithms assume that Unreserved Bandwidth values are ordered by Class-Type priority which could be wrong. This patch set correct this issue by searching the correct Unreserved Bandwidth value that corresponds to the Class-Type instead of directly addressing the Unreserved Bandwidth list with the Class-Type as index. Signed-off-by: Olivier Dugeon Change-Id: I02c03c18cfe2eee2451f05739bf6df9ce6995a38 (cherry picked from commit 0d9eadca7b948a6090130de51f80eac845afbf9d) --- .../algo/impl/AbstractPathComputation.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/algo/algo-impl/src/main/java/org/opendaylight/algo/impl/AbstractPathComputation.java b/algo/algo-impl/src/main/java/org/opendaylight/algo/impl/AbstractPathComputation.java index cf691ccecc..202cc8218c 100644 --- a/algo/algo-impl/src/main/java/org/opendaylight/algo/impl/AbstractPathComputation.java +++ b/algo/algo-impl/src/main/java/org/opendaylight/algo/impl/AbstractPathComputation.java @@ -17,6 +17,7 @@ import org.opendaylight.graph.ConnectedEdge; import org.opendaylight.graph.ConnectedGraph; import org.opendaylight.graph.ConnectedVertex; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel; @@ -235,9 +236,14 @@ public abstract class AbstractPathComputation implements PathComputationAlgorith return true; } else { Long bandwidth = constraints.getBandwidth().getValue().longValue(); - if (attributes.getUnreservedBandwidth().get(constraints.getClassType().intValue()).getBandwidth() - .getValue().longValue() < bandwidth - || attributes.getMaxLinkBandwidth().getValue().longValue() < bandwidth + Long unrsv = 0L; + for (UnreservedBandwidth unResBw : attributes.getUnreservedBandwidth()) { + if (unResBw.getClassType().intValue() == constraints.getClassType().intValue()) { + unrsv = unResBw.getBandwidth().getValue().longValue(); + break; + } + } + if (unrsv < bandwidth || attributes.getMaxLinkBandwidth().getValue().longValue() < bandwidth || attributes.getMaxResvLinkBandwidth().getValue().longValue() < bandwidth) { LOG.debug("Bandwidth constraint is not met"); return true; -- 2.36.6