Cherry picks from 1.6 branch
Change-Id: I596247425802fc759463bcf77ea3c885f3161581
Showing
9 changed files
with
170 additions
and
78 deletions
... | @@ -254,6 +254,7 @@ public class PceManager implements PceService { | ... | @@ -254,6 +254,7 @@ public class PceManager implements PceService { |
254 | 254 | ||
255 | tunnelConsumerIdGen = coreService.getIdGenerator(TUNNEL_CONSUMER_ID_GEN_TOPIC); | 255 | tunnelConsumerIdGen = coreService.getIdGenerator(TUNNEL_CONSUMER_ID_GEN_TOPIC); |
256 | localLspIdIdGen = coreService.getIdGenerator(LOCAL_LSP_ID_GEN_TOPIC); | 256 | localLspIdIdGen = coreService.getIdGenerator(LOCAL_LSP_ID_GEN_TOPIC); |
257 | + localLspIdIdGen.getNewId(); // To prevent 0, the 1st value generated from being used in protocol. | ||
257 | localLspIdFreeList = storageService.<Short>setBuilder() | 258 | localLspIdFreeList = storageService.<Short>setBuilder() |
258 | .withName("pcepLocalLspIdDeletedList") | 259 | .withName("pcepLocalLspIdDeletedList") |
259 | .withSerializer(Serializer.using(KryoNamespaces.API)) | 260 | .withSerializer(Serializer.using(KryoNamespaces.API)) | ... | ... |
... | @@ -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(); | ... | ... |
... | @@ -438,6 +438,7 @@ public class PcepClientControllerImpl implements PcepClientController { | ... | @@ -438,6 +438,7 @@ public class PcepClientControllerImpl implements PcepClientController { |
438 | // When there are no LSPs to sync, directly end-of-sync PCRpt will come and the | 438 | // When there are no LSPs to sync, directly end-of-sync PCRpt will come and the |
439 | // list will be null. | 439 | // list will be null. |
440 | syncStateRptList = Collections.EMPTY_LIST; | 440 | syncStateRptList = Collections.EMPTY_LIST; |
441 | + log.debug("No LSPs reported from PCC during sync."); | ||
441 | } | 442 | } |
442 | 443 | ||
443 | Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator(); | 444 | Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator(); |
... | @@ -502,8 +503,8 @@ public class PcepClientControllerImpl implements PcepClientController { | ... | @@ -502,8 +503,8 @@ public class PcepClientControllerImpl implements PcepClientController { |
502 | } catch (PcepParseException e) { | 503 | } catch (PcepParseException e) { |
503 | log.error("Exception occured while sending initiate delete message {}", e.getMessage()); | 504 | log.error("Exception occured while sending initiate delete message {}", e.getMessage()); |
504 | } | 505 | } |
506 | + continue; | ||
505 | } | 507 | } |
506 | - continue; | ||
507 | } | 508 | } |
508 | 509 | ||
509 | if (!lspObj.getCFlag()) { | 510 | if (!lspObj.getCFlag()) { | ... | ... |
... | @@ -186,6 +186,7 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -186,6 +186,7 @@ public class PcepClientImpl implements PcepClientDriver { |
186 | 186 | ||
187 | @Override | 187 | @Override |
188 | public void setLspDbSyncStatus(PcepSyncStatus syncStatus) { | 188 | public void setLspDbSyncStatus(PcepSyncStatus syncStatus) { |
189 | + log.debug("LSP DB sync status set from {} to {}", this.lspDbSyncStatus, syncStatus); | ||
189 | this.lspDbSyncStatus = syncStatus; | 190 | this.lspDbSyncStatus = syncStatus; |
190 | } | 191 | } |
191 | 192 | ||
... | @@ -199,7 +200,7 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -199,7 +200,7 @@ public class PcepClientImpl implements PcepClientDriver { |
199 | 200 | ||
200 | PcepSyncStatus syncOldStatus = labelDbSyncStatus(); | 201 | PcepSyncStatus syncOldStatus = labelDbSyncStatus(); |
201 | this.labelDbSyncStatus = syncStatus; | 202 | this.labelDbSyncStatus = syncStatus; |
202 | - | 203 | + log.debug("Label DB sync status set from {} to {}", syncOldStatus, syncStatus); |
203 | if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) { | 204 | if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) { |
204 | // Perform end of LSP DB sync actions. | 205 | // Perform end of LSP DB sync actions. |
205 | this.agent.analyzeSyncMsgList(pccId); | 206 | this.agent.analyzeSyncMsgList(pccId); | ... | ... |
... | @@ -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 | ... | ... |
... | @@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
10 | import org.apache.felix.scr.annotations.Service; | 10 | import org.apache.felix.scr.annotations.Service; |
11 | import org.onlab.packet.Ethernet; | 11 | import org.onlab.packet.Ethernet; |
12 | import org.onlab.packet.IPv4; | 12 | import org.onlab.packet.IPv4; |
13 | +import org.onlab.packet.MacAddress; | ||
13 | import org.onlab.packet.TCP; | 14 | import org.onlab.packet.TCP; |
14 | import org.onosproject.net.AnnotationKeys; | 15 | import org.onosproject.net.AnnotationKeys; |
15 | import org.onosproject.net.ConnectPoint; | 16 | import org.onosproject.net.ConnectPoint; |
... | @@ -90,6 +91,7 @@ public class PcepPacketProvider extends AbstractProvider implements PacketProvid | ... | @@ -90,6 +91,7 @@ public class PcepPacketProvider extends AbstractProvider implements PacketProvid |
90 | 91 | ||
91 | Ethernet eth = new Ethernet(); | 92 | Ethernet eth = new Ethernet(); |
92 | eth.setEtherType(Ethernet.TYPE_IPV4); | 93 | eth.setEtherType(Ethernet.TYPE_IPV4); |
94 | + eth.setDestinationMACAddress(MacAddress.NONE); | ||
93 | eth.setPayload(ipv4); | 95 | eth.setPayload(ipv4); |
94 | 96 | ||
95 | // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. | 97 | // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. | ... | ... |
... | @@ -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; |
... | @@ -95,6 +98,7 @@ import org.onosproject.pcepio.protocol.PcepLspObject; | ... | @@ -95,6 +98,7 @@ import org.onosproject.pcepio.protocol.PcepLspObject; |
95 | import org.onosproject.pcepio.protocol.PcepMessage; | 98 | import org.onosproject.pcepio.protocol.PcepMessage; |
96 | import org.onosproject.pcepio.protocol.PcepMetricObject; | 99 | import org.onosproject.pcepio.protocol.PcepMetricObject; |
97 | import org.onosproject.pcepio.protocol.PcepMsgPath; | 100 | import org.onosproject.pcepio.protocol.PcepMsgPath; |
101 | +import org.onosproject.pcepio.protocol.PcepNai; | ||
98 | import org.onosproject.pcepio.protocol.PcepReportMsg; | 102 | import org.onosproject.pcepio.protocol.PcepReportMsg; |
99 | import org.onosproject.pcepio.protocol.PcepSrpObject; | 103 | import org.onosproject.pcepio.protocol.PcepSrpObject; |
100 | import org.onosproject.pcepio.protocol.PcepStateReport; | 104 | import org.onosproject.pcepio.protocol.PcepStateReport; |
... | @@ -102,7 +106,10 @@ import org.onosproject.pcepio.protocol.PcepUpdateMsg; | ... | @@ -102,7 +106,10 @@ import org.onosproject.pcepio.protocol.PcepUpdateMsg; |
102 | import org.onosproject.pcepio.protocol.PcepUpdateRequest; | 106 | import org.onosproject.pcepio.protocol.PcepUpdateRequest; |
103 | import org.onosproject.pcepio.types.IPv4SubObject; | 107 | import org.onosproject.pcepio.types.IPv4SubObject; |
104 | import org.onosproject.pcepio.types.PathSetupTypeTlv; | 108 | import org.onosproject.pcepio.types.PathSetupTypeTlv; |
109 | +import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency; | ||
110 | +import org.onosproject.pcepio.types.PcepNaiIpv4NodeId; | ||
105 | import org.onosproject.pcepio.types.PcepValueType; | 111 | import org.onosproject.pcepio.types.PcepValueType; |
112 | +import org.onosproject.pcepio.types.SrEroSubObject; | ||
106 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | 113 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
107 | import org.onosproject.pcepio.types.SymbolicPathNameTlv; | 114 | import org.onosproject.pcepio.types.SymbolicPathNameTlv; |
108 | import org.osgi.service.component.ComponentContext; | 115 | import org.osgi.service.component.ComponentContext; |
... | @@ -115,6 +122,7 @@ import java.util.Collection; | ... | @@ -115,6 +122,7 @@ import java.util.Collection; |
115 | import java.util.Collections; | 122 | import java.util.Collections; |
116 | import java.util.Dictionary; | 123 | import java.util.Dictionary; |
117 | import java.util.HashMap; | 124 | import java.util.HashMap; |
125 | +import java.util.Iterator; | ||
118 | import java.util.LinkedList; | 126 | import java.util.LinkedList; |
119 | import java.util.List; | 127 | import java.util.List; |
120 | import java.util.ListIterator; | 128 | import java.util.ListIterator; |
... | @@ -845,7 +853,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -845,7 +853,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
845 | * Creates list of hops for ERO object from Path. | 853 | * Creates list of hops for ERO object from Path. |
846 | * | 854 | * |
847 | * @param path network path | 855 | * @param path network path |
848 | - * @return list of ipv4 subobjects | 856 | + * @return list of ERO subobjects |
849 | */ | 857 | */ |
850 | private LinkedList<PcepValueType> createPcepPath(Path path) { | 858 | private LinkedList<PcepValueType> createPcepPath(Path path) { |
851 | LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); | 859 | LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); |
... | @@ -880,6 +888,55 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -880,6 +888,55 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
880 | } | 888 | } |
881 | 889 | ||
882 | /** | 890 | /** |
891 | + * Creates label stack for ERO object from network resource. | ||
892 | + * | ||
893 | + * @param labelStack | ||
894 | + * @param path (hop list) | ||
895 | + * @return list of ERO subobjects | ||
896 | + */ | ||
897 | + private LinkedList<PcepValueType> createPcepLabelStack(DefaultLabelStack labelStack, Path path) { | ||
898 | + checkNotNull(labelStack); | ||
899 | + | ||
900 | + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); | ||
901 | + Iterator<Link> links = path.links().iterator(); | ||
902 | + LabelResourceId label = null; | ||
903 | + Link link = null; | ||
904 | + PcepValueType subObj = null; | ||
905 | + PcepNai nai = null; | ||
906 | + Device dstNode = null; | ||
907 | + long srcPortNo, dstPortNo; | ||
908 | + | ||
909 | + ListIterator<LabelResourceId> labelListIterator = labelStack.labelResources().listIterator(); | ||
910 | + while (labelListIterator.hasNext()) { | ||
911 | + label = labelListIterator.next(); | ||
912 | + link = links.next(); | ||
913 | + | ||
914 | + srcPortNo = link.src().port().toLong(); | ||
915 | + srcPortNo = ((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? srcPortNo & SET : srcPortNo; | ||
916 | + | ||
917 | + dstPortNo = link.dst().port().toLong(); | ||
918 | + dstPortNo = ((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? dstPortNo & SET : dstPortNo; | ||
919 | + | ||
920 | + nai = new PcepNaiIpv4Adjacency((int) srcPortNo, (int) dstPortNo); | ||
921 | + subObj = new SrEroSubObject(PcepNaiIpv4Adjacency.ST_TYPE, false, false, false, true, (int) label.labelId(), | ||
922 | + nai); | ||
923 | + llSubObjects.add(subObj); | ||
924 | + | ||
925 | + dstNode = deviceService.getDevice(link.dst().deviceId()); | ||
926 | + nai = new PcepNaiIpv4NodeId(Ip4Address.valueOf(dstNode.annotations().value(LSRID)).toInt()); | ||
927 | + | ||
928 | + if (!labelListIterator.hasNext()) { | ||
929 | + log.error("Malformed label stack."); | ||
930 | + } | ||
931 | + label = labelListIterator.next(); | ||
932 | + subObj = new SrEroSubObject(PcepNaiIpv4NodeId.ST_TYPE, false, false, false, true, (int) label.labelId(), | ||
933 | + nai); | ||
934 | + llSubObjects.add(subObj); | ||
935 | + } | ||
936 | + return llSubObjects; | ||
937 | + } | ||
938 | + | ||
939 | + /** | ||
883 | * Creates PcInitiated lsp request list for setup tunnel. | 940 | * Creates PcInitiated lsp request list for setup tunnel. |
884 | * | 941 | * |
885 | * @param tunnel mpls tunnel | 942 | * @param tunnel mpls tunnel |
... | @@ -893,7 +950,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -893,7 +950,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
893 | PcepClient pc, int srpId) | 950 | PcepClient pc, int srpId) |
894 | throws PcepParseException { | 951 | throws PcepParseException { |
895 | PcepValueType tlv; | 952 | PcepValueType tlv; |
896 | - LinkedList<PcepValueType> llSubObjects = createPcepPath(path); | 953 | + LinkedList<PcepValueType> llSubObjects = null; |
954 | + | ||
955 | + NetworkResource labelStack = tunnel.resource(); | ||
956 | + if (labelStack != null && labelStack instanceof DefaultLabelStack) { | ||
957 | + llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path); | ||
958 | + } else { | ||
959 | + llSubObjects = createPcepPath(path); | ||
960 | + } | ||
897 | 961 | ||
898 | if (llSubObjects == null || llSubObjects.size() == 0) { | 962 | if (llSubObjects == null || llSubObjects.size() == 0) { |
899 | log.error("There is no link information to create tunnel"); | 963 | log.error("There is no link information to create tunnel"); |
... | @@ -932,8 +996,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -932,8 +996,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
932 | llOptionalTlv.add(tlv); | 996 | llOptionalTlv.add(tlv); |
933 | 997 | ||
934 | //build LSP object | 998 | //build LSP object |
935 | - PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setOFlag((byte) 0).setPlspId(0) | 999 | + PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true).setDFlag(true).setOFlag((byte) 0) |
936 | - .setOptionalTlv(llOptionalTlv).build(); | 1000 | + .setPlspId(0).setOptionalTlv(llOptionalTlv).build(); |
937 | 1001 | ||
938 | //build ENDPOINTS object | 1002 | //build ENDPOINTS object |
939 | PcepEndPointsObject endpointsobj = pc.factory().buildEndPointsObject() | 1003 | PcepEndPointsObject endpointsobj = pc.factory().buildEndPointsObject() |
... | @@ -1036,15 +1100,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1036,15 +1100,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1036 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); | 1100 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); |
1037 | int srpId = SrpIdGenerators.create(); | 1101 | int srpId = SrpIdGenerators.create(); |
1038 | TunnelId tunnelId = tunnel.tunnelId(); | 1102 | TunnelId tunnelId = tunnel.tunnelId(); |
1039 | - int plspId = 0; | ||
1040 | - | ||
1041 | - if (!(pcepTunnelApiMapper.checkFromTunnelDBQueue(tunnelId))) { | ||
1042 | - log.error("Tunnel doesnot exists. Tunnel id {}" + tunnelId.toString()); | ||
1043 | - return; | ||
1044 | - } else { | ||
1045 | - PcepTunnelData pcepTunnelDbData = pcepTunnelApiMapper.getDataFromTunnelDBQueue(tunnelId); | ||
1046 | - plspId = pcepTunnelDbData.plspId(); | ||
1047 | - } | ||
1048 | 1103 | ||
1049 | PcepValueType tlv; | 1104 | PcepValueType tlv; |
1050 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); | 1105 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); |
... | @@ -1066,8 +1121,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1066,8 +1121,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1066 | 1121 | ||
1067 | String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID); | 1122 | String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID); |
1068 | String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID); | 1123 | String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID); |
1124 | + String pLspIdString = tunnel.annotations().value(PLSP_ID); | ||
1125 | + | ||
1069 | short localLspId = 0; | 1126 | short localLspId = 0; |
1070 | short pccTunnelId = 0; | 1127 | short pccTunnelId = 0; |
1128 | + int plspId = 0; | ||
1071 | 1129 | ||
1072 | if (localLspIdString != null) { | 1130 | if (localLspIdString != null) { |
1073 | localLspId = Short.valueOf(localLspIdString); | 1131 | localLspId = Short.valueOf(localLspIdString); |
... | @@ -1077,6 +1135,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1077,6 +1135,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1077 | pccTunnelId = Short.valueOf(pccTunnelIdString); | 1135 | pccTunnelId = Short.valueOf(pccTunnelIdString); |
1078 | } | 1136 | } |
1079 | 1137 | ||
1138 | + if (pLspIdString != null) { | ||
1139 | + plspId = Integer.valueOf(pLspIdString); | ||
1140 | + } | ||
1141 | + | ||
1080 | tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()) | 1142 | tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()) |
1081 | .ip().getIp4Address().toInt()), | 1143 | .ip().getIp4Address().toInt()), |
1082 | localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip() | 1144 | localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip() |
... | @@ -1119,7 +1181,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1119,7 +1181,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1119 | PcepValueType tlv; | 1181 | PcepValueType tlv; |
1120 | int plspId = 0; | 1182 | int plspId = 0; |
1121 | 1183 | ||
1122 | - LinkedList<PcepValueType> llSubObjects = createPcepPath(path); | 1184 | + LinkedList<PcepValueType> llSubObjects = null; |
1185 | + NetworkResource labelStack = tunnel.resource(); | ||
1186 | + if (labelStack != null && labelStack instanceof DefaultLabelStack) { | ||
1187 | + llSubObjects = createPcepLabelStack((DefaultLabelStack) labelStack, path); | ||
1188 | + } else { | ||
1189 | + llSubObjects = createPcepPath(path); | ||
1190 | + } | ||
1191 | + | ||
1123 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); | 1192 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); |
1124 | LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>(); | 1193 | LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>(); |
1125 | 1194 | ||
... | @@ -1329,7 +1398,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1329,7 +1398,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1329 | DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), | 1398 | DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), |
1330 | tunnel.dst(), tunnel.type(), tunnel.groupId(), | 1399 | tunnel.dst(), tunnel.type(), tunnel.groupId(), |
1331 | providerId, tunnel.tunnelName(), path, | 1400 | providerId, tunnel.tunnelName(), path, |
1332 | - annotations); | 1401 | + tunnel.resource(), annotations); |
1333 | 1402 | ||
1334 | if (CREATE == pcepTunnelData.requestType()) { | 1403 | if (CREATE == pcepTunnelData.requestType()) { |
1335 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 1404 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
... | @@ -1355,7 +1424,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1355,7 +1424,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1355 | // though there are no labels to download for SR-TE. | 1424 | // though there are no labels to download for SR-TE. |
1356 | if ((pcepLspStatus == PcepLspStatus.GOING_UP) | 1425 | if ((pcepLspStatus == PcepLspStatus.GOING_UP) |
1357 | && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == SR_WITHOUT_SIGNALLING)) { | 1426 | && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == SR_WITHOUT_SIGNALLING)) { |
1358 | - updateTunnel(tunnel, tunnel.path()); | 1427 | + // Query again to get latest tunnel updated with protocol values from PCRpt msg. |
1428 | + updateTunnel(service.tunnelQueryById(tunnel.tunnelId()), tunnel.path()); | ||
1359 | } | 1429 | } |
1360 | } | 1430 | } |
1361 | 1431 | ||
... | @@ -1391,12 +1461,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1391,12 +1461,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1391 | 1461 | ||
1392 | while (listIterator.hasNext()) { | 1462 | while (listIterator.hasNext()) { |
1393 | PcepValueType tlv = listIterator.next(); | 1463 | PcepValueType tlv = listIterator.next(); |
1394 | - | ||
1395 | switch (tlv.getType()) { | 1464 | switch (tlv.getType()) { |
1396 | case PathSetupTypeTlv.TYPE: | 1465 | case PathSetupTypeTlv.TYPE: |
1397 | lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())]; | 1466 | lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())]; |
1398 | break; | 1467 | break; |
1399 | - | ||
1400 | default: | 1468 | default: |
1401 | break; | 1469 | break; |
1402 | } | 1470 | } |
... | @@ -1417,38 +1485,48 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1417,38 +1485,48 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1417 | } | 1485 | } |
1418 | 1486 | ||
1419 | PcepAttribute attributes = msgPath.getPcepAttribute(); | 1487 | PcepAttribute attributes = msgPath.getPcepAttribute(); |
1488 | + float bandwidth = 0; | ||
1420 | int cost = 0; | 1489 | int cost = 0; |
1421 | - if (attributes != null && attributes.getMetricObjectList() != null) { | 1490 | + if (attributes != null) { |
1422 | - ListIterator<PcepMetricObject> iterator = attributes.getMetricObjectList().listIterator(); | 1491 | + if (attributes.getMetricObjectList() != null) { |
1423 | - PcepMetricObject metricObj = iterator.next(); | 1492 | + ListIterator<PcepMetricObject> iterator = attributes.getMetricObjectList().listIterator(); |
1424 | - | 1493 | + PcepMetricObject metricObj = iterator.next(); |
1425 | - while (metricObj != null) { | 1494 | + |
1426 | - if (metricObj.getBType() == IGP_METRIC) { | 1495 | + while (metricObj != null) { |
1427 | - costType = "COST"; | 1496 | + if (metricObj.getBType() == IGP_METRIC) { |
1428 | - } else if (metricObj.getBType() == TE_METRIC) { | 1497 | + costType = "COST"; |
1429 | - costType = "TE_COST"; | 1498 | + } else if (metricObj.getBType() == TE_METRIC) { |
1430 | - } | 1499 | + costType = "TE_COST"; |
1431 | - | 1500 | + } |
1432 | - if (costType != null) { | 1501 | + if (costType != null) { |
1433 | - cost = metricObj.getMetricVal(); | 1502 | + cost = metricObj.getMetricVal(); |
1434 | - log.debug("Path cost {}", cost); | 1503 | + log.debug("Path cost {}", cost); |
1435 | - break; | 1504 | + break; |
1505 | + } | ||
1506 | + metricObj = iterator.next(); | ||
1436 | } | 1507 | } |
1437 | - metricObj = iterator.next(); | 1508 | + } |
1509 | + if (attributes.getBandwidthObject() != null) { | ||
1510 | + bandwidth = attributes.getBandwidthObject().getBandwidth(); | ||
1438 | } | 1511 | } |
1439 | } | 1512 | } |
1440 | 1513 | ||
1441 | - Path path = buildPathFromEroObj(eroObj, providerId, cost); | 1514 | + List<Object> eroSubObjList = buildPathFromEroObj(eroObj, providerId); |
1442 | - | 1515 | + List<Link> links = new ArrayList<>(); |
1443 | - float bandwidth = 0; | 1516 | + List<LabelResourceId> labels = new ArrayList<>(); |
1444 | - if (msgPath.getBandwidthObject() != null) { | 1517 | + for (Object linkOrLabel : eroSubObjList) { |
1445 | - bandwidth = msgPath.getBandwidthObject().getBandwidth(); | 1518 | + if (linkOrLabel instanceof Link) { |
1519 | + links.add((Link) linkOrLabel); | ||
1520 | + } else if (linkOrLabel instanceof Integer) { | ||
1521 | + labels.add(LabelResourceId.labelResourceId(((Integer) linkOrLabel).longValue())); | ||
1522 | + } | ||
1446 | } | 1523 | } |
1447 | 1524 | ||
1448 | - /* | 1525 | + Path path = new DefaultPath(providerId, links, cost, EMPTY); |
1449 | - * To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action | 1526 | + NetworkResource labelStack = new DefaultLabelStack(labels); |
1450 | - * from PCE. | 1527 | + |
1451 | - */ | 1528 | + // To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action |
1529 | + // from PCE. | ||
1452 | PcepSrpObject srpObj = stateRpt.getSrpObject(); | 1530 | PcepSrpObject srpObj = stateRpt.getSrpObject(); |
1453 | LspType lspType = getLspType(srpObj); | 1531 | LspType lspType = getLspType(srpObj); |
1454 | 1532 | ||
... | @@ -1463,11 +1541,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1463,11 +1541,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1463 | case StatefulIPv4LspIdentifiersTlv.TYPE: | 1541 | case StatefulIPv4LspIdentifiersTlv.TYPE: |
1464 | ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv; | 1542 | ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv; |
1465 | break; | 1543 | break; |
1466 | - | ||
1467 | case SymbolicPathNameTlv.TYPE: | 1544 | case SymbolicPathNameTlv.TYPE: |
1468 | pathNameTlv = (SymbolicPathNameTlv) tlv; | 1545 | pathNameTlv = (SymbolicPathNameTlv) tlv; |
1469 | break; | 1546 | break; |
1470 | - | ||
1471 | default: | 1547 | default: |
1472 | break; | 1548 | break; |
1473 | } | 1549 | } |
... | @@ -1540,7 +1616,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1540,7 +1616,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1540 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); | 1616 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); |
1541 | 1617 | ||
1542 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( | 1618 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( |
1543 | - 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, | 1619 | + 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, |
1544 | annotations); | 1620 | annotations); |
1545 | 1621 | ||
1546 | // Do not support PCC initiated LSP after LSP DB sync is completed. | 1622 | // Do not support PCC initiated LSP after LSP DB sync is completed. |
... | @@ -1573,7 +1649,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1573,7 +1649,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1573 | TunnelId tId = tunnelAdded(td, tunnelState); | 1649 | TunnelId tId = tunnelAdded(td, tunnelState); |
1574 | Tunnel tunnelInserted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS, | 1650 | Tunnel tunnelInserted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS, |
1575 | tunnelState, new DefaultGroupId(0), tId, TunnelName.tunnelName(String.valueOf(pathNameTlv | 1651 | tunnelState, new DefaultGroupId(0), tId, TunnelName.tunnelName(String.valueOf(pathNameTlv |
1576 | - .getValue())), path, annotations); | 1652 | + .getValue())), path, labelStack, annotations); |
1577 | 1653 | ||
1578 | PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelInserted, path, LSP_STATE_RPT); | 1654 | PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelInserted, path, LSP_STATE_RPT); |
1579 | pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv); | 1655 | pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv); |
... | @@ -1589,7 +1665,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1589,7 +1665,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1589 | if (lspObj.getDFlag()) { | 1665 | if (lspObj.getDFlag()) { |
1590 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); | 1666 | annotations = getAnnotations(lspObj, ipv4LspIdenTlv, bandwidth, lspType, costType); |
1591 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( | 1667 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( |
1592 | - 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, | 1668 | + 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, |
1593 | annotations); | 1669 | annotations); |
1594 | tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); | 1670 | tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); |
1595 | } | 1671 | } |
... | @@ -1629,15 +1705,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1629,15 +1705,14 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1629 | * | 1705 | * |
1630 | * @param eroObj ERO object | 1706 | * @param eroObj ERO object |
1631 | * @param providerId provider id | 1707 | * @param providerId provider id |
1632 | - * @param cost cost of path | 1708 | + * @return list of links and labels |
1633 | - * @return path object | ||
1634 | */ | 1709 | */ |
1635 | - private Path buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId, int cost) { | 1710 | + private List<Object> buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId) { |
1636 | checkNotNull(eroObj); | 1711 | checkNotNull(eroObj); |
1637 | - List<Link> links = new ArrayList<Link>(); | 1712 | + List<Object> subObjList = new ArrayList<>(); |
1638 | LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); | 1713 | LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); |
1639 | if (0 == llSubObj.size()) { | 1714 | if (0 == llSubObj.size()) { |
1640 | - log.debug("ERO in report message does not have hop information"); | 1715 | + log.error("ERO in report message does not have hop information"); |
1641 | return null; | 1716 | return null; |
1642 | } | 1717 | } |
1643 | ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); | 1718 | ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); |
... | @@ -1665,16 +1740,34 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1665,16 +1740,34 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1665 | .dst(dst) | 1740 | .dst(dst) |
1666 | .type(Link.Type.DIRECT) | 1741 | .type(Link.Type.DIRECT) |
1667 | .build(); | 1742 | .build(); |
1668 | - links.add(link); | 1743 | + subObjList.add(link); |
1669 | src = dst; | 1744 | src = dst; |
1670 | } | 1745 | } |
1671 | break; | 1746 | break; |
1747 | + case SrEroSubObject.TYPE: | ||
1748 | + SrEroSubObject srEroSubObj = (SrEroSubObject) subObj; | ||
1749 | + subObjList.add(srEroSubObj.getSid()); | ||
1750 | + | ||
1751 | + if (srEroSubObj.getSt() == PcepNaiIpv4Adjacency.ST_TYPE) { | ||
1752 | + PcepNaiIpv4Adjacency nai = (PcepNaiIpv4Adjacency) (srEroSubObj.getNai()); | ||
1753 | + IpAddress srcIp = IpAddress.valueOf(nai.getLocalIpv4Addr()); | ||
1754 | + src = new ConnectPoint(IpElementId.ipElement(srcIp), PortNumber.portNumber(0)); | ||
1755 | + IpAddress dstIp = IpAddress.valueOf(nai.getRemoteIpv4Addr()); | ||
1756 | + dst = new ConnectPoint(IpElementId.ipElement(dstIp), PortNumber.portNumber(0)); | ||
1757 | + Link link = DefaultLink.builder() | ||
1758 | + .providerId(providerId) | ||
1759 | + .src(src) | ||
1760 | + .dst(dst) | ||
1761 | + .type(Link.Type.DIRECT) | ||
1762 | + .build(); | ||
1763 | + subObjList.add(link); | ||
1764 | + } | ||
1672 | default: | 1765 | default: |
1673 | // the other sub objects are not required | 1766 | // the other sub objects are not required |
1674 | } | 1767 | } |
1675 | } | 1768 | } |
1676 | 1769 | ||
1677 | - return new DefaultPath(providerId, links, cost, EMPTY); | 1770 | + return subObjList; |
1678 | } | 1771 | } |
1679 | 1772 | ||
1680 | @Override | 1773 | @Override | ... | ... |
-
Please register or login to post a comment