Improve Pcep Server 09/97009/5
authorOlivier Dugeon <olivier.dugeon@orange.com>
Thu, 22 Jul 2021 12:35:18 +0000 (14:35 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 26 Jul 2021 09:48:21 +0000 (09:48 +0000)
Some PCCs send a PcRequest message with Metrics and/or Bandwidth set
with value equal to 0 which result to a NO_PATH when calling path
computation. Indeed, it is impossible to determine a path with a metric
less or equal to 0.

This patch set skip Metrics and/or Bandwidth equal to 0 when building
the list ofi constraints for the path computation algorithm.

Change-Id: I3b343e67fc35f3393d4ed136aa4224082823f066
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
pcep/server/server-provider/src/main/java/org/opendaylight/bgpcep/pcep/server/provider/PathComputationImpl.java

index 68eace1e8d76d99a212477980b8aa7107a0af854..42d64a077ae41c55432bda574ead67aaf44369ee 100644 (file)
@@ -213,15 +213,21 @@ public class PathComputationImpl implements PathComputation {
         if (metrics != null) {
             for (Metrics metric : metrics) {
                 convert = ByteBuffer.wrap(metric.getMetric().getValue().getValue()).getFloat();
+                final long value = convert.longValue();
+                /* Skip Metric with value equal to 0 */
+                if (value == 0) {
+                    continue;
+                }
+
                 switch (metric.getMetric().getMetricType().intValue()) {
                     case MessagesUtil.IGP_METRIC:
-                        ctsBuilder.setMetric(Uint32.valueOf(convert.longValue()));
+                        ctsBuilder.setMetric(Uint32.valueOf(value));
                         break;
                     case MessagesUtil.TE_METRIC:
-                        ctsBuilder.setTeMetric(Uint32.valueOf(convert.longValue()));
+                        ctsBuilder.setTeMetric(Uint32.valueOf(value));
                         break;
                     case MessagesUtil.PATH_DELAY:
-                        ctsBuilder.setDelay(new Delay(Uint32.valueOf(convert.longValue())));
+                        ctsBuilder.setDelay(new Delay(Uint32.valueOf(value)));
                         break;
                     default:
                         LOG.warn("Metric {} is not handle by Path Computation Constraints", metric);
@@ -233,11 +239,15 @@ public class PathComputationImpl implements PathComputation {
         /* Set Bandwidth and Class Type */
         if (bandwidth != null) {
             convert = ByteBuffer.wrap(bandwidth.getBandwidth().getValue()).getFloat();
-            ctsBuilder.setBandwidth(new DecimalBandwidth(BigDecimal.valueOf(convert.longValue())));
-            if (classType != null) {
-                ctsBuilder.setClassType(classType.getClassType().getValue());
-            } else {
-                ctsBuilder.setClassType(Uint8.ZERO);
+            final long value = convert.longValue();
+            /* Skip Bandwidth with value equal to 0 */
+            if (value != 0) {
+                ctsBuilder.setBandwidth(new DecimalBandwidth(BigDecimal.valueOf(value)));
+                if (classType != null) {
+                    ctsBuilder.setClassType(classType.getClassType().getValue());
+                } else {
+                    ctsBuilder.setClassType(Uint8.ZERO);
+                }
             }
         }