Avantika-Huawei
Committed by Gerrit Code Review

[ONOS-4707] GoldenEye - SR-TE LSPs setup issues

Change-Id: I96efb496577d4ccfbbb8f9957703b4a4da126d8a
...@@ -406,15 +406,6 @@ public final class PceccSrTeBeHandler { ...@@ -406,15 +406,6 @@ public final class PceccSrTeBeHandler {
406 DeviceId deviceId = null; 406 DeviceId deviceId = null;
407 for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) { 407 for (Iterator<Link> iterator = linkList.iterator(); iterator.hasNext();) {
408 link = iterator.next(); 408 link = iterator.next();
409 - // Add source device label now
410 - deviceId = link.src().deviceId();
411 - nodeLabelId = pceStore.getGlobalNodeLabel(deviceId);
412 - if (nodeLabelId == null) {
413 - log.error("Unable to find node label for a device id {} in store.", deviceId.toString());
414 - return null;
415 - }
416 - labelStack.add(nodeLabelId);
417 -
418 // Add adjacency label for this link 409 // Add adjacency label for this link
419 adjLabelId = pceStore.getAdjLabel(link); 410 adjLabelId = pceStore.getAdjLabel(link);
420 if (adjLabelId == null) { 411 if (adjLabelId == null) {
...@@ -422,11 +413,7 @@ public final class PceccSrTeBeHandler { ...@@ -422,11 +413,7 @@ public final class PceccSrTeBeHandler {
422 return null; 413 return null;
423 } 414 }
424 labelStack.add(adjLabelId); 415 labelStack.add(adjLabelId);
425 - }
426 416
427 - // This is the last link in path
428 - // Add destination device label now.
429 - if (link != null) {
430 deviceId = link.dst().deviceId(); 417 deviceId = link.dst().deviceId();
431 nodeLabelId = pceStore.getGlobalNodeLabel(deviceId); 418 nodeLabelId = pceStore.getGlobalNodeLabel(deviceId);
432 if (nodeLabelId == null) { 419 if (nodeLabelId == null) {
......
...@@ -417,11 +417,8 @@ public class PceccSrTeBeHandlerTest { ...@@ -417,11 +417,8 @@ public class PceccSrTeBeHandlerTest {
417 // Compute label stack 417 // Compute label stack
418 LabelStack labelStack = srTeHandler.computeLabelStack(path1); 418 LabelStack labelStack = srTeHandler.computeLabelStack(path1);
419 419
420 - // check node-label of D1.deviceId()
421 List<LabelResourceId> labelList = labelStack.labelResources(); 420 List<LabelResourceId> labelList = labelStack.labelResources();
422 Iterator<LabelResourceId> iterator = labelList.iterator(); 421 Iterator<LabelResourceId> iterator = labelList.iterator();
423 - labelId = iterator.next();
424 - assertThat(labelId, is(LabelResourceId.labelResourceId(4097)));
425 422
426 // check adjacency label of D1.deviceId() 423 // check adjacency label of D1.deviceId()
427 labelId = iterator.next(); 424 labelId = iterator.next();
......
...@@ -59,6 +59,14 @@ public class PcepNaiIpv4Adjacency implements PcepNai { ...@@ -59,6 +59,14 @@ public class PcepNaiIpv4Adjacency implements PcepNai {
59 return ST_TYPE; 59 return ST_TYPE;
60 } 60 }
61 61
62 + public int getLocalIpv4Addr() {
63 + return localIpv4Addr;
64 + }
65 +
66 + public int getRemoteIpv4Addr() {
67 + return remoteIpv4Addr;
68 + }
69 +
62 @Override 70 @Override
63 public int write(ChannelBuffer bb) { 71 public int write(ChannelBuffer bb) {
64 int iLenStartIndex = bb.writerIndex(); 72 int iLenStartIndex = bb.writerIndex();
......
...@@ -84,7 +84,7 @@ public class SrEroSubObject implements PcepValueType { ...@@ -84,7 +84,7 @@ public class SrEroSubObject implements PcepValueType {
84 */ 84 */
85 protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class); 85 protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
86 86
87 - public static final short TYPE = 0x60; //TODO : type to be defined 87 + public static final short TYPE = 0x24; //TODO : type to be defined
88 public static final short LENGTH = 12; 88 public static final short LENGTH = 12;
89 public static final short VALUE_LENGTH = 10; 89 public static final short VALUE_LENGTH = 10;
90 public static final int SET = 1; 90 public static final int SET = 1;
...@@ -243,9 +243,10 @@ public class SrEroSubObject implements PcepValueType { ...@@ -243,9 +243,10 @@ public class SrEroSubObject implements PcepValueType {
243 @Override 243 @Override
244 public int write(ChannelBuffer c) { 244 public int write(ChannelBuffer c) {
245 int iLenStartIndex = c.writerIndex(); 245 int iLenStartIndex = c.writerIndex();
246 - 246 + c.writeByte(TYPE);
247 - c.writeShort(TYPE); 247 + // Store the position of object length
248 - c.writeShort(LENGTH); 248 + int objectLenIndex = c.writerIndex();
249 + c.writeByte(0);
249 250
250 short temp = 0; 251 short temp = 0;
251 if (bMFlag) { 252 if (bMFlag) {
...@@ -264,13 +265,14 @@ public class SrEroSubObject implements PcepValueType { ...@@ -264,13 +265,14 @@ public class SrEroSubObject implements PcepValueType {
264 temp = (short) (temp | tempST); 265 temp = (short) (temp | tempST);
265 c.writeShort(temp); 266 c.writeShort(temp);
266 if (bMFlag) { 267 if (bMFlag) {
267 - int tempSid = (int) sid << 12; 268 + int tempSid = sid << 12;
268 c.writeInt(tempSid); 269 c.writeInt(tempSid);
269 } else { 270 } else {
270 c.writeInt(sid); 271 c.writeInt(sid);
271 } 272 }
272 nai.write(c); 273 nai.write(c);
273 274
275 + c.setByte(objectLenIndex, (c.writerIndex() - iLenStartIndex));
274 return c.writerIndex() - iLenStartIndex; 276 return c.writerIndex() - iLenStartIndex;
275 } 277 }
276 278
......
...@@ -28,6 +28,8 @@ import org.onlab.packet.Ip4Address; ...@@ -28,6 +28,8 @@ import org.onlab.packet.Ip4Address;
28 import org.onlab.packet.IpAddress; 28 import org.onlab.packet.IpAddress;
29 import org.onosproject.cfg.ComponentConfigService; 29 import org.onosproject.cfg.ComponentConfigService;
30 import org.onosproject.core.DefaultGroupId; 30 import org.onosproject.core.DefaultGroupId;
31 +import org.onosproject.incubator.net.resource.label.LabelResourceId;
32 +import org.onosproject.incubator.net.tunnel.DefaultLabelStack;
31 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint; 33 import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
32 import org.onosproject.incubator.net.tunnel.DefaultTunnel; 34 import org.onosproject.incubator.net.tunnel.DefaultTunnel;
33 import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription; 35 import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
...@@ -59,6 +61,7 @@ import org.onosproject.net.DeviceId; ...@@ -59,6 +61,7 @@ import org.onosproject.net.DeviceId;
59 import org.onosproject.net.ElementId; 61 import org.onosproject.net.ElementId;
60 import org.onosproject.net.IpElementId; 62 import org.onosproject.net.IpElementId;
61 import org.onosproject.net.Link; 63 import org.onosproject.net.Link;
64 +import org.onosproject.net.NetworkResource;
62 import org.onosproject.net.Path; 65 import org.onosproject.net.Path;
63 import org.onosproject.net.PortNumber; 66 import org.onosproject.net.PortNumber;
64 import org.onosproject.net.SparseAnnotations; 67 import org.onosproject.net.SparseAnnotations;
...@@ -94,6 +97,7 @@ import org.onosproject.pcepio.protocol.PcepLspObject; ...@@ -94,6 +97,7 @@ import org.onosproject.pcepio.protocol.PcepLspObject;
94 import org.onosproject.pcepio.protocol.PcepMessage; 97 import org.onosproject.pcepio.protocol.PcepMessage;
95 import org.onosproject.pcepio.protocol.PcepMetricObject; 98 import org.onosproject.pcepio.protocol.PcepMetricObject;
96 import org.onosproject.pcepio.protocol.PcepMsgPath; 99 import org.onosproject.pcepio.protocol.PcepMsgPath;
100 +import org.onosproject.pcepio.protocol.PcepNai;
97 import org.onosproject.pcepio.protocol.PcepReportMsg; 101 import org.onosproject.pcepio.protocol.PcepReportMsg;
98 import org.onosproject.pcepio.protocol.PcepSrpObject; 102 import org.onosproject.pcepio.protocol.PcepSrpObject;
99 import org.onosproject.pcepio.protocol.PcepStateReport; 103 import org.onosproject.pcepio.protocol.PcepStateReport;
...@@ -101,7 +105,10 @@ import org.onosproject.pcepio.protocol.PcepUpdateMsg; ...@@ -101,7 +105,10 @@ import org.onosproject.pcepio.protocol.PcepUpdateMsg;
101 import org.onosproject.pcepio.protocol.PcepUpdateRequest; 105 import org.onosproject.pcepio.protocol.PcepUpdateRequest;
102 import org.onosproject.pcepio.types.IPv4SubObject; 106 import org.onosproject.pcepio.types.IPv4SubObject;
103 import org.onosproject.pcepio.types.PathSetupTypeTlv; 107 import org.onosproject.pcepio.types.PathSetupTypeTlv;
108 +import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency;
109 +import org.onosproject.pcepio.types.PcepNaiIpv4NodeId;
104 import org.onosproject.pcepio.types.PcepValueType; 110 import org.onosproject.pcepio.types.PcepValueType;
111 +import org.onosproject.pcepio.types.SrEroSubObject;
105 import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; 112 import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
106 import org.onosproject.pcepio.types.SymbolicPathNameTlv; 113 import org.onosproject.pcepio.types.SymbolicPathNameTlv;
107 import org.osgi.service.component.ComponentContext; 114 import org.osgi.service.component.ComponentContext;
...@@ -114,6 +121,7 @@ import java.util.Collection; ...@@ -114,6 +121,7 @@ import java.util.Collection;
114 import java.util.Collections; 121 import java.util.Collections;
115 import java.util.Dictionary; 122 import java.util.Dictionary;
116 import java.util.HashMap; 123 import java.util.HashMap;
124 +import java.util.Iterator;
117 import java.util.LinkedList; 125 import java.util.LinkedList;
118 import java.util.List; 126 import java.util.List;
119 import java.util.ListIterator; 127 import java.util.ListIterator;
...@@ -432,8 +440,13 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -432,8 +440,13 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
432 return; 440 return;
433 } 441 }
434 442
435 - // If delegation flag is set then only send update message[means delegated PCE can send update msg for that 443 + //PCInitiate tunnels are always have D flag set, else check for tunnels who are delegated via LspKey
436 - // LSP].If annotation is null D flag is not set else it is set. 444 + if (pc.capability().statefulPceCapability()) {
445 + if (tunnel.annotations().value(PCE_INIT) != null && tunnel.annotations().value(PCE_INIT).equals("true")) {
446 + pcepUpdateTunnel(tunnel, path, pc);
447 + } else {
448 + // If delegation flag is set then only send update message[means delegated PCE can send update msg for
449 + // that LSP. If annotation is null D flag is not set else it is set.
437 Short localLspId = 0; 450 Short localLspId = 0;
438 for (Tunnel t : tunnels) { 451 for (Tunnel t : tunnels) {
439 if (!t.tunnelId().equals(tunnel.tunnelId()) && t.tunnelName().equals(tunnel.tunnelName())) { 452 if (!t.tunnelId().equals(tunnel.tunnelId()) && t.tunnelName().equals(tunnel.tunnelName())) {
...@@ -446,17 +459,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -446,17 +459,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
446 return; 459 return;
447 } 460 }
448 461
449 - //PCInitiate tunnels are always have D flag set, else check for tunnels who are delegated via LspKey 462 + if (pc.delegationInfo(new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)),
450 - if (pc.capability().statefulPceCapability()) {
451 - if (tunnel.annotations().value(PCE_INIT) != null && tunnel.annotations().value(PCE_INIT).equals("true")) {
452 - pcepUpdateTunnel(tunnel, path, pc);
453 - } else if (pc.delegationInfo(
454 - new LspKey(Integer.valueOf(tunnel.annotations().value(PLSP_ID)),
455 localLspId.shortValue())) != null) { 463 localLspId.shortValue())) != null) {
464 +
456 pcepUpdateTunnel(tunnel, path, pc); 465 pcepUpdateTunnel(tunnel, path, pc);
457 } 466 }
458 } 467 }
459 } 468 }
469 + }
460 470
461 @Override 471 @Override
462 public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) { 472 public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) {
...@@ -844,7 +854,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -844,7 +854,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
844 * Creates list of hops for ERO object from Path. 854 * Creates list of hops for ERO object from Path.
845 * 855 *
846 * @param path network path 856 * @param path network path
847 - * @return list of ipv4 subobjects 857 + * @return list of ERO subobjects
848 */ 858 */
849 private LinkedList<PcepValueType> createPcepPath(Path path) { 859 private LinkedList<PcepValueType> createPcepPath(Path path) {
850 LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 860 LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
...@@ -879,6 +889,55 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -879,6 +889,55 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
879 } 889 }
880 890
881 /** 891 /**
892 + * Creates label stack for ERO object from network resource.
893 + *
894 + * @param labelStack
895 + * @param path (hop list)
896 + * @return list of ERO subobjects
897 + */
898 + private LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) {
899 + checkNotNull(labelStack);
900 +
901 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
902 + Iterator<Link> links = path.links().iterator();
903 + LabelResourceId label = null;
904 + Link link = null;
905 + PcepValueType subObj = null;
906 + PcepNai nai = null;
907 + Device dstNode = null;
908 + long srcPortNo, dstPortNo;
909 +
910 + ListIterator<LabelResourceId> labelListIterator = labelStack.labelResources().listIterator();
911 + while (labelListIterator.hasNext()) {
912 + label = labelListIterator.next();
913 + link = links.next();
914 +
915 + srcPortNo = link.src().port().toLong();
916 + srcPortNo = ((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? srcPortNo & SET : srcPortNo;
917 +
918 + dstPortNo = link.dst().port().toLong();
919 + dstPortNo = ((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? dstPortNo & SET : dstPortNo;
920 +
921 + nai = new PcepNaiIpv4Adjacency((int) srcPortNo, (int) dstPortNo);
922 + subObj = new SrEroSubObject(PcepNaiIpv4Adjacency.ST_TYPE, false, false, false, true, (int) label.labelId(),
923 + nai);
924 + llSubObjects.add(subObj);
925 +
926 + dstNode = deviceService.getDevice(link.dst().deviceId());
927 + nai = new PcepNaiIpv4NodeId(Ip4Address.valueOf(dstNode.annotations().value(LSRID)).toInt());
928 +
929 + if (!labelListIterator.hasNext()) {
930 + log.error("Malformed label stack.");
931 + }
932 + label = labelListIterator.next();
933 + subObj = new SrEroSubObject(PcepNaiIpv4NodeId.ST_TYPE, false, false, false, true, (int) label.labelId(),
934 + nai);
935 + llSubObjects.add(subObj);
936 + }
937 + return llSubObjects;
938 + }
939 +
940 + /**
882 * Creates PcInitiated lsp request list for setup tunnel. 941 * Creates PcInitiated lsp request list for setup tunnel.
883 * 942 *
884 * @param tunnel mpls tunnel 943 * @param tunnel mpls tunnel
...@@ -892,7 +951,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -892,7 +951,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
892 PcepClient pc, int srpId) 951 PcepClient pc, int srpId)
893 throws PcepParseException { 952 throws PcepParseException {
894 PcepValueType tlv; 953 PcepValueType tlv;
895 - LinkedList<PcepValueType> llSubObjects = createPcepPath(path); 954 + LinkedList<PcepValueType> llSubObjects = null;
955 +
956 + NetworkResource labelStack = tunnel.resource();
957 + if (labelStack != null && labelStack instanceof DefaultLabelStack) {
958 + llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path);
959 + } else {
960 + llSubObjects = createPcepPath(path);
961 + }
896 962
897 if (llSubObjects == null || llSubObjects.size() == 0) { 963 if (llSubObjects == null || llSubObjects.size() == 0) {
898 log.error("There is no link information to create tunnel"); 964 log.error("There is no link information to create tunnel");
...@@ -931,8 +997,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -931,8 +997,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
931 llOptionalTlv.add(tlv); 997 llOptionalTlv.add(tlv);
932 998
933 //build LSP object 999 //build LSP object
934 - PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setOFlag((byte) 0).setPlspId(0) 1000 + PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setDFlag(true).setOFlag((byte) 0)
935 - .setOptionalTlv(llOptionalTlv).build(); 1001 + .setPlspId(0).setOptionalTlv(llOptionalTlv).build();
936 1002
937 //build ENDPOINTS object 1003 //build ENDPOINTS object
938 PcepEndPointsObject endpointsobj = pc.factory().buildEndPointsObject() 1004 PcepEndPointsObject endpointsobj = pc.factory().buildEndPointsObject()
...@@ -1108,7 +1174,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1108,7 +1174,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1108 PcepValueType tlv; 1174 PcepValueType tlv;
1109 int plspId = 0; 1175 int plspId = 0;
1110 1176
1111 - LinkedList<PcepValueType> llSubObjects = createPcepPath(path); 1177 + LinkedList<PcepValueType> llSubObjects = null;
1178 + NetworkResource labelStack = tunnel.resource();
1179 + if (labelStack != null && labelStack instanceof DefaultLabelStack) {
1180 + llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path);
1181 + } else {
1182 + llSubObjects = createPcepPath(path);
1183 + }
1184 +
1112 LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 1185 LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
1113 LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>(); 1186 LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>();
1114 1187
...@@ -1318,7 +1391,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1318,7 +1391,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1318 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), 1391 DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(),
1319 tunnel.dst(), tunnel.type(), tunnel.groupId(), 1392 tunnel.dst(), tunnel.type(), tunnel.groupId(),
1320 providerId, tunnel.tunnelName(), path, 1393 providerId, tunnel.tunnelName(), path,
1321 - annotations); 1394 + tunnel.resource(), annotations);
1322 1395
1323 if (CREATE == pcepTunnelData.requestType()) { 1396 if (CREATE == pcepTunnelData.requestType()) {
1324 pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); 1397 pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
...@@ -1344,7 +1417,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1344,7 +1417,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1344 // though there are no labels to download for SR-TE. 1417 // though there are no labels to download for SR-TE.
1345 if ((pcepLspStatus == PcepLspStatus.GOING_UP) 1418 if ((pcepLspStatus == PcepLspStatus.GOING_UP)
1346 && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == SR_WITHOUT_SIGNALLING)) { 1419 && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == SR_WITHOUT_SIGNALLING)) {
1347 - updateTunnel(tunnel, tunnel.path()); 1420 + // Query again to get latest tunnel updated with protocol values from PCRpt msg.
1421 + updateTunnel(service.tunnelQueryById(tunnel.tunnelId()), tunnel.path());
1348 } 1422 }
1349 } 1423 }
1350 1424
...@@ -1380,12 +1454,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1380,12 +1454,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1380 1454
1381 while (listIterator.hasNext()) { 1455 while (listIterator.hasNext()) {
1382 PcepValueType tlv = listIterator.next(); 1456 PcepValueType tlv = listIterator.next();
1383 -
1384 switch (tlv.getType()) { 1457 switch (tlv.getType()) {
1385 case PathSetupTypeTlv.TYPE: 1458 case PathSetupTypeTlv.TYPE:
1386 lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())]; 1459 lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())];
1387 break; 1460 break;
1388 -
1389 default: 1461 default:
1390 break; 1462 break;
1391 } 1463 }
...@@ -1417,7 +1489,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1417,7 +1489,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1417 } else if (metricObj.getBType() == TE_METRIC) { 1489 } else if (metricObj.getBType() == TE_METRIC) {
1418 costType = "TE_COST"; 1490 costType = "TE_COST";
1419 } 1491 }
1420 -
1421 if (costType != null) { 1492 if (costType != null) {
1422 cost = metricObj.getMetricVal(); 1493 cost = metricObj.getMetricVal();
1423 log.debug("Path cost {}", cost); 1494 log.debug("Path cost {}", cost);
...@@ -1427,7 +1498,19 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1427,7 +1498,19 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1427 } 1498 }
1428 } 1499 }
1429 1500
1430 - Path path = buildPathFromEroObj(eroObj, providerId, cost); 1501 + List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId);
1502 + List<Link> links = new ArrayList<>();
1503 + List<LabelResourceId> labels = new ArrayList<>();
1504 + for (Object linkOrLabel : eroSubObjList) {
1505 + if (linkOrLabel instanceof Link) {
1506 + links.add((Link) linkOrLabel);
1507 + } else if (linkOrLabel instanceof Integer) {
1508 + labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue()));
1509 + }
1510 + }
1511 +
1512 + Path path = new DefaultPath(providerId, links, cost, EMPTY);
1513 + NetworkResource labelStack = new DefaultLabelStack(labels);
1431 1514
1432 float bandwidth = 0; 1515 float bandwidth = 0;
1433 if (msgPath.getBandwidthObject() != null) { 1516 if (msgPath.getBandwidthObject() != null) {
...@@ -1452,11 +1535,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1452,11 +1535,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1452 case StatefulIPv4LspIdentifiersTlv.TYPE: 1535 case StatefulIPv4LspIdentifiersTlv.TYPE:
1453 ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv; 1536 ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv;
1454 break; 1537 break;
1455 -
1456 case SymbolicPathNameTlv.TYPE: 1538 case SymbolicPathNameTlv.TYPE:
1457 pathNameTlv = (SymbolicPathNameTlv) tlv; 1539 pathNameTlv = (SymbolicPathNameTlv) tlv;
1458 break; 1540 break;
1459 -
1460 default: 1541 default:
1461 break; 1542 break;
1462 } 1543 }
...@@ -1529,7 +1610,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1529,7 +1610,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1529 annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); 1610 annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType);
1530 1611
1531 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( 1612 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
1532 - 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, 1613 + 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack,
1533 annotations); 1614 annotations);
1534 1615
1535 // Do not support PCC initiated LSP after LSP DB sync is completed. 1616 // Do not support PCC initiated LSP after LSP DB sync is completed.
...@@ -1562,7 +1643,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1562,7 +1643,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1562 TunnelId tId = tunnelAdded(td, tunnelState); 1643 TunnelId tId = tunnelAdded(td, tunnelState);
1563 Tunnel tunnelInserted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS, 1644 Tunnel tunnelInserted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS,
1564 tunnelState, new DefaultGroupId(0), tId, TunnelName.tunnelName(String.valueOf(pathNameTlv 1645 tunnelState, new DefaultGroupId(0), tId, TunnelName.tunnelName(String.valueOf(pathNameTlv
1565 - .getValue())), path, annotations); 1646 + .getValue())), path, labelStack, annotations);
1566 1647
1567 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelInserted, path, LSP_STATE_RPT); 1648 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelInserted, path, LSP_STATE_RPT);
1568 pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv); 1649 pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv);
...@@ -1578,7 +1659,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1578,7 +1659,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1578 if (lspObj.getDFlag()) { 1659 if (lspObj.getDFlag()) {
1579 annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); 1660 annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType);
1580 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( 1661 td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId(
1581 - 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, 1662 + 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack,
1582 annotations); 1663 annotations);
1583 tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); 1664 tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId);
1584 } 1665 }
...@@ -1618,15 +1699,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1618,15 +1699,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1618 * 1699 *
1619 * @param eroObj ERO object 1700 * @param eroObj ERO object
1620 * @param providerId provider id 1701 * @param providerId provider id
1621 - * @param cost cost of path 1702 + * @return list of links and labels
1622 - * @return path object
1623 */ 1703 */
1624 - private Path buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId, int cost) { 1704 + private List<Object> buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId) {
1625 checkNotNull(eroObj); 1705 checkNotNull(eroObj);
1626 - List<Link> links = new ArrayList<Link>(); 1706 + List<Object> subObjList = new ArrayList<>();
1627 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); 1707 LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects();
1628 if (0 == llSubObj.size()) { 1708 if (0 == llSubObj.size()) {
1629 - log.debug("ERO in report message does not have hop information"); 1709 + log.error("ERO in report message does not have hop information");
1630 return null; 1710 return null;
1631 } 1711 }
1632 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); 1712 ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator();
...@@ -1654,16 +1734,34 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid ...@@ -1654,16 +1734,34 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
1654 .dst(dst) 1734 .dst(dst)
1655 .type(Link.Type.DIRECT) 1735 .type(Link.Type.DIRECT)
1656 .build(); 1736 .build();
1657 - links.add(link); 1737 + subObjList.add(link);
1658 src = dst; 1738 src = dst;
1659 } 1739 }
1660 break; 1740 break;
1741 + case SrEroSubObject.TYPE:
1742 + SrEroSubObject srEroSubObj = (SrEroSubObject) subObj;
1743 + subObjList.add(srEroSubObj.getSid());
1744 +
1745 + if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) {
1746 + PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai());
1747 + IpAddress srcIp = IpAddress.valueOf(nai.getLocalIpv4Addr());
1748 + src = new ConnectPoint(IpElementId.ipElement(srcIp), PortNumber.portNumber(0));
1749 + IpAddress dstIp = IpAddress.valueOf(nai.getRemoteIpv4Addr());
1750 + dst = new ConnectPoint(IpElementId.ipElement(dstIp), PortNumber.portNumber(0));
1751 + Link link = DefaultLink.builder()
1752 + .providerId(providerId)
1753 + .src(src)
1754 + .dst(dst)
1755 + .type(Link.Type.DIRECT)
1756 + .build();
1757 + subObjList.add(link);
1758 + }
1661 default: 1759 default:
1662 // the other sub objects are not required 1760 // the other sub objects are not required
1663 } 1761 }
1664 } 1762 }
1665 1763
1666 - return new DefaultPath(providerId, links, cost, EMPTY); 1764 + return subObjList;
1667 } 1765 }
1668 1766
1669 @Override 1767 @Override
......