Handle SID Index in SRGB block 29/96929/4
authorOlivier Dugeon <olivier.dugeon@orange.com>
Mon, 19 Jul 2021 15:38:54 +0000 (17:38 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 20 Jul 2021 10:09:23 +0000 (10:09 +0000)
When building Graph from BGP-LS, Segment Routing Global Block (SRGB)
advertized with a SID Index instead of an MPLS Label thrown a Java
Exception in getVertex() function. This commit allows the support of
both SID Index and MPLS Label for SRGB lower bound value.

JIRA: BGPCEP-970
Change-Id: I14cf39831f5ef47f7e80e91659ae6daeeacb1b91
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateGraphBuilder.java

index ec013bca693557140b814cffecbaab9e930a8102..eee5fd630a6333951fd03b361bb6d8fb18ffd5e6 100644 (file)
@@ -56,6 +56,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.ospf.adj.flags._case.OspfAdjFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.prefix.sid.tlv.flags.IsisPrefixFlagsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.SidCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.DecimalBandwidth;
@@ -435,11 +436,18 @@ public class LinkstateGraphBuilder extends AbstractTopologyBuilder<LinkstateRout
                     (key << 24 & 0xFF) + "." + (key << 16 & 0xFF) + "." + (key << 8 & 0xFF) + "." + (key & 0xFF));
         }
         if (na.getSrCapabilities() != null) {
-            builder.setSrgb(new SrgbBuilder()
-                    .setLowerBound(
-                            ((LocalLabelCase) na.getSrCapabilities().getSidLabelIndex()).getLocalLabel().getValue())
-                    .setRangeSize(na.getSrCapabilities().getRangeSize().getValue())
-                    .build());
+            final SidLabelIndex labelIndex = na.getSrCapabilities().getSidLabelIndex();
+            if (labelIndex instanceof LocalLabelCase) {
+                builder.setSrgb(new SrgbBuilder()
+                        .setLowerBound(((LocalLabelCase) labelIndex).getLocalLabel().getValue())
+                        .setRangeSize(na.getSrCapabilities().getRangeSize().getValue())
+                        .build());
+            } else if (labelIndex instanceof SidCase) {
+                builder.setSrgb(new SrgbBuilder()
+                        .setLowerBound(((SidCase) labelIndex).getSid())
+                        .setRangeSize(na.getSrCapabilities().getRangeSize().getValue())
+                        .build());
+            }
         }
         if (na.getNodeFlags() != null) {
             if (na.getNodeFlags().getAbr()) {