Fix wrong SR-NAI type for Path Computation 93/91093/4
authorOlivier Dugeon <olivier.dugeon@orange.com>
Fri, 10 Jul 2020 13:53:02 +0000 (15:53 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 17 Jul 2020 10:19:24 +0000 (10:19 +0000)
When computing a segment path for PcInitiate message, the Path Computation
Algorithms produce an SR-ERO composed by Node-SIDs (NAI Type = 1 or 2).
However, routers expect a SR-ERO composed by Adjacency-SIDs
(NAI Type = 3 or 4) with M-Flag set to 1. Indeed, Node SID NAI is only valid
for loose path while Path Computation determines strict path.

This patch set change NAI (1/2) by NAI (3/4) in the SR-ERO computed by the
Path Computation Algorithms.

JIRA: BGPCEP-913

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Change-Id: Ia57b0475d764830a671f785e7444aaf37007adeb

algo/algo-api/src/main/yang/path-computation.yang
algo/algo-impl/src/main/java/org/opendaylight/algo/impl/AbstractPathComputation.java
pcep/server/server-provider/src/main/java/org/opendaylight/bgpcep/pcep/server/provider/MessagesUtil.java

index b8eb473ef04b3b2d1182a6b5b1c04b0903911f01..07095a8ff485ba9cf922e197b09d49f1e76f6357 100644 (file)
@@ -131,9 +131,38 @@ module path-computation {
         }
     }
 
+    grouping sr-description {
+        description "Segment Routing path description";
+        leaf sid {
+            description "Segment Routing Identifier as an Index or MPLS label";
+            when "path-constraints/address-family = 2 or path-constraints/address-family = 3";
+            type uint32;
+        }
+        leaf local-ipv4 {
+            description "Local IPv4 address";
+            when "path-constraints/address-family = 2";
+            type inet:ipv4-address;
+        }
+        leaf remote-ipv4 {
+            description "Remote IPv4 address";
+            when "path-constraints/address-family = 2";
+            type inet:ipv4-address;
+        }
+        leaf local-ipv6 {
+            description "Local IPv4 address";
+            when "path-constraints/address-family = 3";
+            type inet:ipv6-address;
+        }
+        leaf remote-ipv6 {
+            description "Remote IPv4 address";
+            when "path-constraints/address-family = 3";
+            type inet:ipv6-address;
+        }
+    }
+
     grouping path-descriptions {
         description
-            "Computed Path description as a list of IPv4, IPv6 or MPLS Label";
+            "Computed Path description as a list of IPv4, IPv6 or Segment Routing subobject";
         list path-description {
             leaf ipv4 {
                 when "path-constraints/address-family = 0";
@@ -143,10 +172,7 @@ module path-computation {
                 when "path-constraints/address-family = 1";
                 type inet:ipv6-address;
             }
-            leaf label {
-                when "path-constraints/address-family = 2 or path-constraints/address-family = 3";
-                type netc:mpls-label;
-            }
+            uses sr-description;
         }
     }
 
index da4505a9e1402742489b296c5950b62e888b4db5..202cc8218cafba1f5359c2c4f76668b5655be614 100644 (file)
@@ -159,13 +159,21 @@ public abstract class AbstractPathComputation implements PathComputationAlgorith
                 break;
             case SrIpv4:
                 if (getIpv4NodeSid(edge.getDestination()) == null) {
-                    LOG.debug("No SR-Ipv4 SID");
+                    LOG.debug("No Node-SID for IPv4");
+                    return true;
+                }
+                if (attributes.getAdjSid() == null) {
+                    LOG.debug("No Adjacency-SID");
                     return true;
                 }
                 break;
             case SrIpv6:
                 if (getIpv6NodeSid(edge.getDestination()) == null) {
-                    LOG.debug("No SR-Ipv6 SID");
+                    LOG.debug("No Node-SID for IPv6");
+                    return true;
+                }
+                if (attributes.getAdjSid() == null) {
+                    LOG.debug("No SR Adjacency-SID");
                     return true;
                 }
                 break;
@@ -346,14 +354,16 @@ public abstract class AbstractPathComputation implements PathComputationAlgorith
                     break;
                 case SrIpv4:
                     pathDesc = new PathDescriptionBuilder()
-                            .setIpv4(edge.getDestination().getVertex().getRouterId().getIpv4Address())
-                            .setLabel(getIpv4NodeSid(edge.getDestination()))
+                            .setLocalIpv4(edge.getEdge().getEdgeAttributes().getLocalAddress().getIpv4Address())
+                            .setRemoteIpv4(edge.getEdge().getEdgeAttributes().getRemoteAddress().getIpv4Address())
+                            .setSid(edge.getEdge().getEdgeAttributes().getAdjSid())
                             .build();
                     break;
                 case SrIpv6:
                     pathDesc = new PathDescriptionBuilder()
-                            .setIpv6(edge.getDestination().getVertex().getRouterId().getIpv6Address())
-                            .setLabel(getIpv6NodeSid(edge.getDestination()))
+                            .setLocalIpv6(edge.getEdge().getEdgeAttributes().getLocalAddress().getIpv6Address())
+                            .setRemoteIpv6(edge.getEdge().getEdgeAttributes().getRemoteAddress().getIpv6Address())
+                            .setSid(edge.getEdge().getEdgeAttributes().getAdjSid())
                             .build();
                     break;
                 default:
index 1bd44466c8cedd28d5afc5915cfa638d4ac2c660..22e0a2eeded89ad7028420342aa722771046ead7 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.mes
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.SidType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.pcrep.pcrep.message.replies.result.success._case.success.paths.ero.subobject.subobject.type.SrEroType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.pcrep.pcrep.message.replies.result.success._case.success.paths.ero.subobject.subobject.type.SrEroTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.subobject.nai.IpNodeIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.subobject.nai.IpAdjacencyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder;
@@ -97,7 +97,7 @@ public final class MessagesUtil {
         /* Fulfill ERO sublist */
         for (PathDescription path : pathDescriptions) {
             Subobject sb = null;
-            if (path.getLabel() == null) {
+            if (path.getSid() == null) {
                 IpPrefix ipPref = null;
                 /* Prepare SubObject for IPv4 or IPv6 address */
                 if (path.getIpv4() != null) {
@@ -121,25 +121,31 @@ public final class MessagesUtil {
             } else {
                 /* Prepare SubObject for Segment Routing */
                 SrEroType srEro = null;
-                if (path.getIpv4() != null) {
+                if ((path.getLocalIpv4() != null) && (path.getRemoteIpv4() != null)) {
                     srEro = new SrEroTypeBuilder()
-                            .setSidType(SidType.Ipv4NodeId)
-                            .setSid(path.getLabel().getValue())
+                            .setSidType(SidType.Ipv4Adjacency)
+                            .setSid(path.getSid())
                             .setCFlag(false)
-                            .setMFlag(false)
-                            .setNai(new IpNodeIdBuilder()
-                                    .setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getIpv4().getValue())))
+                            .setMFlag(true)
+                            .setNai(new IpAdjacencyBuilder()
+                                    .setLocalIpAddress(
+                                            new IpAddressNoZone(new Ipv4AddressNoZone(path.getLocalIpv4().getValue())))
+                                    .setRemoteIpAddress(
+                                            new IpAddressNoZone(new Ipv4AddressNoZone(path.getRemoteIpv4().getValue())))
                                     .build())
                             .build();
                 }
-                if (path.getIpv6() != null) {
+                if ((path.getLocalIpv6() != null) && (path.getRemoteIpv6() != null)) {
                     srEro = new SrEroTypeBuilder()
-                            .setSidType(SidType.Ipv6NodeId)
-                            .setSid(path.getLabel().getValue())
+                            .setSidType(SidType.Ipv6Adjacency)
+                            .setSid(path.getSid())
                             .setCFlag(false)
-                            .setMFlag(false)
-                            .setNai(new IpNodeIdBuilder()
-                                    .setIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getIpv6().getValue())))
+                            .setMFlag(true)
+                            .setNai(new IpAdjacencyBuilder()
+                                    .setLocalIpAddress(
+                                            new IpAddressNoZone(new Ipv6AddressNoZone(path.getLocalIpv6().getValue())))
+                                    .setRemoteIpAddress(
+                                            new IpAddressNoZone(new Ipv6AddressNoZone(path.getRemoteIpv6().getValue())))
                                     .build())
                             .build();
                 }