[ONOS-4722] cherry-picked GoldenEye:Fix exception on learning unknown PCE-initiated LSP from PCC
Change-Id: I8abc003aeb187f18e51de533f0c51e265dfd8661
Showing
14 changed files
with
617 additions
and
73 deletions
... | @@ -150,7 +150,7 @@ public final class BasicPceccHandler { | ... | @@ -150,7 +150,7 @@ public final class BasicPceccHandler { |
150 | 150 | ||
151 | // Push into destination device | 151 | // Push into destination device |
152 | // Destination device IN port is link.dst().port() | 152 | // Destination device IN port is link.dst().port() |
153 | - installLocalLabelRule(dstDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush, | 153 | + installLocalLabelRule(dstDeviceId, labelId, dstPort, tunnel.tunnelId(), false, |
154 | Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.ADD); | 154 | Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.ADD); |
155 | 155 | ||
156 | // Push into source device | 156 | // Push into source device | ... | ... |
... | @@ -116,6 +116,7 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | ... | @@ -116,6 +116,7 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; |
116 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; | 116 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; |
117 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; | 117 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; |
118 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; | 118 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; |
119 | +import static org.onosproject.incubator.net.tunnel.Tunnel.State.FAILED; | ||
119 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; | 120 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; |
120 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; | 121 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; |
121 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 122 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
... | @@ -603,6 +604,18 @@ public class PceManager implements PceService { | ... | @@ -603,6 +604,18 @@ public class PceManager implements PceService { |
603 | PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId); | 604 | PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId); |
604 | pceStore.addTunnelInfo(updatedTunnelId, pceccTunnelInfo); | 605 | pceStore.addTunnelInfo(updatedTunnelId, pceccTunnelInfo); |
605 | } | 606 | } |
607 | + | ||
608 | + // For CR cases, download labels and send update message. | ||
609 | + if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) { | ||
610 | + Tunnel tunnelForlabelDownload = new DefaultTunnel(null, tunnel.src(), tunnel.dst(), MPLS, INIT, null, | ||
611 | + updatedTunnelId, tunnel.tunnelName(), computedPath, | ||
612 | + labelStack, annotationBuilder.build()); | ||
613 | + | ||
614 | + if (!crHandler.allocateLabel(tunnelForlabelDownload)) { | ||
615 | + log.error("Unable to allocate labels for the tunnel {}.", tunnel.toString()); | ||
616 | + } | ||
617 | + } | ||
618 | + | ||
606 | return true; | 619 | return true; |
607 | } | 620 | } |
608 | 621 | ||
... | @@ -1154,6 +1167,11 @@ public class PceManager implements PceService { | ... | @@ -1154,6 +1167,11 @@ public class PceManager implements PceService { |
1154 | links.get(links.size() - 1).dst().deviceId(), | 1167 | links.get(links.size() - 1).dst().deviceId(), |
1155 | tunnel.tunnelName().value(), constraints, lspType)); | 1168 | tunnel.tunnelName().value(), constraints, lspType)); |
1156 | } | 1169 | } |
1170 | + | ||
1171 | + if (tunnel.state() == FAILED) { | ||
1172 | + // Check whether this ONOS instance is master, if yes, recompute and send update. | ||
1173 | + checkForMasterAndUpdateTunnel(tunnel.path().src().deviceId(), tunnel); | ||
1174 | + } | ||
1157 | break; | 1175 | break; |
1158 | 1176 | ||
1159 | case TUNNEL_REMOVED: | 1177 | case TUNNEL_REMOVED: | ... | ... |
... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | -package org.onosproject.provider.pcep.tunnel.impl; | 17 | +package org.onosproject.pcep.controller; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Representation of LSP type. | 20 | * Representation of LSP type. | ... | ... |
... | @@ -37,13 +37,4 @@ public interface PcepEventListener { | ... | @@ -37,13 +37,4 @@ public interface PcepEventListener { |
37 | * @param endOfSyncAction the action that needs to be taken for the tunnel | 37 | * @param endOfSyncAction the action that needs to be taken for the tunnel |
38 | */ | 38 | */ |
39 | void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction); | 39 | void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction); |
40 | - | ||
41 | - /** | ||
42 | - * Handles sending PCEP message to client on end of LSPDB sync. | ||
43 | - * | ||
44 | - * @param pccId id of the pcc | ||
45 | - * @param msg the message to be sent | ||
46 | - * @param endOfSyncAction the action that needs to be taken in the message | ||
47 | - */ | ||
48 | - void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction); | ||
49 | } | 40 | } | ... | ... |
... | @@ -49,6 +49,7 @@ import org.onosproject.pcep.controller.PcepLspStatus; | ... | @@ -49,6 +49,7 @@ import org.onosproject.pcep.controller.PcepLspStatus; |
49 | import org.onosproject.pcep.controller.PcepNodeListener; | 49 | import org.onosproject.pcep.controller.PcepNodeListener; |
50 | import org.onosproject.pcep.controller.PcepPacketListener; | 50 | import org.onosproject.pcep.controller.PcepPacketListener; |
51 | import org.onosproject.pcep.controller.PcepSyncStatus; | 51 | import org.onosproject.pcep.controller.PcepSyncStatus; |
52 | +import org.onosproject.pcep.controller.SrpIdGenerators; | ||
52 | import org.onosproject.pcep.controller.driver.PcepAgent; | 53 | import org.onosproject.pcep.controller.driver.PcepAgent; |
53 | import org.onosproject.pcepio.exceptions.PcepParseException; | 54 | import org.onosproject.pcepio.exceptions.PcepParseException; |
54 | import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; | 55 | import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; |
... | @@ -61,6 +62,7 @@ import org.onosproject.pcepio.protocol.PcepInitiateMsg; | ... | @@ -61,6 +62,7 @@ import org.onosproject.pcepio.protocol.PcepInitiateMsg; |
61 | import org.onosproject.pcepio.protocol.PcepLspObject; | 62 | import org.onosproject.pcepio.protocol.PcepLspObject; |
62 | import org.onosproject.pcepio.protocol.PcepMessage; | 63 | import org.onosproject.pcepio.protocol.PcepMessage; |
63 | import org.onosproject.pcepio.protocol.PcepReportMsg; | 64 | import org.onosproject.pcepio.protocol.PcepReportMsg; |
65 | +import org.onosproject.pcepio.protocol.PcepSrpObject; | ||
64 | import org.onosproject.pcepio.protocol.PcepStateReport; | 66 | import org.onosproject.pcepio.protocol.PcepStateReport; |
65 | import org.onosproject.pcepio.types.PcepValueType; | 67 | import org.onosproject.pcepio.types.PcepValueType; |
66 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | 68 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
... | @@ -74,7 +76,6 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -74,7 +76,6 @@ import static com.google.common.base.Preconditions.checkNotNull; |
74 | import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC; | 76 | import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC; |
75 | import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE; | 77 | import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE; |
76 | import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE; | 78 | import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE; |
77 | -import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_DELETE; | ||
78 | import static org.onosproject.pcep.controller.PcepLspSyncAction.UNSTABLE; | 79 | import static org.onosproject.pcep.controller.PcepLspSyncAction.UNSTABLE; |
79 | import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19; | 80 | import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19; |
80 | import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5; | 81 | import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5; |
... | @@ -487,8 +488,10 @@ public class PcepClientControllerImpl implements PcepClientController { | ... | @@ -487,8 +488,10 @@ public class PcepClientControllerImpl implements PcepClientController { |
487 | if (lspObj.getCFlag() && !lspObj.getRFlag()) { | 488 | if (lspObj.getCFlag() && !lspObj.getRFlag()) { |
488 | // For initiated LSP, need to send PCInit delete msg. | 489 | // For initiated LSP, need to send PCInit delete msg. |
489 | try { | 490 | try { |
491 | + PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(SrpIdGenerators.create()) | ||
492 | + .setRFlag(true).build(); | ||
490 | PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest() | 493 | PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest() |
491 | - .setLspObject(lspObj).build(); | 494 | + .setLspObject(lspObj).setSrpObject(srpobj).build(); |
492 | LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList | 495 | LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList |
493 | = new LinkedList<PcInitiatedLspRequest>(); | 496 | = new LinkedList<PcInitiatedLspRequest>(); |
494 | llPcInitiatedLspRequestList.add(releaseLspRequest); | 497 | llPcInitiatedLspRequestList.add(releaseLspRequest); |
... | @@ -496,10 +499,7 @@ public class PcepClientControllerImpl implements PcepClientController { | ... | @@ -496,10 +499,7 @@ public class PcepClientControllerImpl implements PcepClientController { |
496 | PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg() | 499 | PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg() |
497 | .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build(); | 500 | .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build(); |
498 | 501 | ||
499 | - for (PcepEventListener l : pcepEventListener) { | 502 | + pc.sendMessage(Collections.singletonList(pcInitiateMsg)); |
500 | - l.handleEndOfSyncAction(pccId, pcInitiateMsg, SEND_DELETE); | ||
501 | - } | ||
502 | - | ||
503 | } catch (PcepParseException e) { | 503 | } catch (PcepParseException e) { |
504 | log.error("Exception occured while sending initiate delete message {}", e.getMessage()); | 504 | log.error("Exception occured while sending initiate delete message {}", e.getMessage()); |
505 | } | 505 | } | ... | ... |
1 | +package org.onosproject.pcep.controller.impl; | ||
2 | + | ||
3 | +import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE; | ||
4 | +import static org.onosproject.pcep.controller.PcepLspSyncAction.UNSTABLE; | ||
5 | + | ||
6 | +import java.net.SocketAddress; | ||
7 | +import java.util.ArrayList; | ||
8 | +import java.util.Collection; | ||
9 | +import java.util.Collections; | ||
10 | +import java.util.HashMap; | ||
11 | +import java.util.HashSet; | ||
12 | +import java.util.List; | ||
13 | + | ||
14 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
15 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
16 | +import org.jboss.netty.channel.Channel; | ||
17 | +import org.jboss.netty.channel.ChannelConfig; | ||
18 | +import org.jboss.netty.channel.ChannelFactory; | ||
19 | +import org.jboss.netty.channel.ChannelFuture; | ||
20 | +import org.jboss.netty.channel.ChannelPipeline; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | +import org.onlab.packet.IpAddress; | ||
25 | +import org.onosproject.core.ApplicationId; | ||
26 | +import org.onosproject.incubator.net.tunnel.DefaultTunnel; | ||
27 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
28 | +import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | ||
29 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
30 | +import org.onosproject.incubator.net.tunnel.TunnelListener; | ||
31 | +import org.onosproject.incubator.net.tunnel.TunnelName; | ||
32 | +import org.onosproject.incubator.net.tunnel.TunnelService; | ||
33 | +import org.onosproject.incubator.net.tunnel.TunnelSubscription; | ||
34 | +import org.onosproject.incubator.net.tunnel.Tunnel.Type; | ||
35 | +import org.onosproject.net.Annotations; | ||
36 | +import org.onosproject.net.DeviceId; | ||
37 | +import org.onosproject.net.ElementId; | ||
38 | +import org.onosproject.net.Path; | ||
39 | +import org.onosproject.pcep.controller.ClientCapability; | ||
40 | +import org.onosproject.pcep.controller.PccId; | ||
41 | +import org.onosproject.pcep.controller.PcepEventListener; | ||
42 | +import org.onosproject.pcep.controller.PcepLspSyncAction; | ||
43 | +import org.onosproject.pcep.controller.PcepPacketStats; | ||
44 | +import org.onosproject.pcep.controller.PcepSyncStatus; | ||
45 | +import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException; | ||
46 | +import org.onosproject.pcepio.exceptions.PcepParseException; | ||
47 | +import org.onosproject.pcepio.protocol.PcepFactories; | ||
48 | +import org.onosproject.pcepio.protocol.PcepInitiateMsg; | ||
49 | +import org.onosproject.pcepio.protocol.PcepMessage; | ||
50 | +import org.onosproject.pcepio.protocol.PcepMessageReader; | ||
51 | +import org.onosproject.pcepio.protocol.PcepVersion; | ||
52 | +import com.google.common.collect.ImmutableSet; | ||
53 | + | ||
54 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
55 | +import static org.hamcrest.core.Is.is; | ||
56 | + | ||
57 | +public class PcepClientControllerImplTest { | ||
58 | + PcepClientControllerImpl controllerImpl = new PcepClientControllerImpl(); | ||
59 | + TunnelService tunnelService = new MockTunnelService(); | ||
60 | + private PcepEventListener listener; | ||
61 | + private Channel channel; | ||
62 | + | ||
63 | + @Before | ||
64 | + public void startUp() { | ||
65 | + controllerImpl.tunnelService = tunnelService; | ||
66 | + listener = new PcepEventListenerAdapter(); | ||
67 | + controllerImpl.addEventListener(listener); | ||
68 | + channel = new MockChannel(); | ||
69 | + } | ||
70 | + | ||
71 | + @After | ||
72 | + public void tearDown() { | ||
73 | + controllerImpl.removeEventListener(listener); | ||
74 | + listener = null; | ||
75 | + controllerImpl.tunnelService = null; | ||
76 | + } | ||
77 | + | ||
78 | + @Test | ||
79 | + public void tunnelProviderAddedTest1() throws PcepParseException, PcepOutOfBoundMessageException { | ||
80 | + PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); | ||
81 | + | ||
82 | + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, | ||
83 | + 0x00, 0x00, 0x00, 0x01, // SRP object | ||
84 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
85 | + 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x24, // LSP object | ||
86 | + 0x00, 0x00, 0x10, (byte) 0xAB, | ||
87 | + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path tlv | ||
88 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
89 | + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, | ||
90 | + 0x05, 0x05, 0x05, | ||
91 | + | ||
92 | + 0x07, 0x10, 0x00, 0x14, // ERO object | ||
93 | + 0x01, 0x08, (byte) 0x01, 0x01, // ERO IPv4 sub objects | ||
94 | + 0x01, 0x01, 0x04, 0x00, | ||
95 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, }; | ||
96 | + | ||
97 | + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); | ||
98 | + buffer.writeBytes(reportMsg); | ||
99 | + | ||
100 | + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | ||
101 | + PcepMessage message = reader.readFrom(buffer); | ||
102 | + | ||
103 | + PcepClientImpl pc = new PcepClientImpl(); | ||
104 | + PcepPacketStats pktStats = new PcepPacketStatsImpl(); | ||
105 | + | ||
106 | + pc.init(pccId, PcepVersion.PCEP_1, pktStats); | ||
107 | + pc.setChannel(channel); | ||
108 | + pc.setAgent(controllerImpl.agent); | ||
109 | + pc.setConnected(true); | ||
110 | + pc.setCapability(new ClientCapability(true, true, true, true, true)); | ||
111 | + | ||
112 | + controllerImpl.agent.addConnectedClient(pccId, pc); | ||
113 | + controllerImpl.processClientMessage(pccId, message); | ||
114 | + | ||
115 | + pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED); | ||
116 | + pc.setLabelDbSyncStatus(PcepSyncStatus.IN_SYNC); | ||
117 | + pc.setLabelDbSyncStatus(PcepSyncStatus.SYNCED); | ||
118 | + | ||
119 | + List<PcepMessage> deleteMsgs = ((MockChannel) channel).msgsWritten(); | ||
120 | + assertThat(deleteMsgs.size(), is(1)); | ||
121 | + | ||
122 | + for (PcepMessage msg : deleteMsgs) { | ||
123 | + assertThat(((PcepInitiateMsg) msg).getPcInitiatedLspRequestList().getFirst().getSrpObject().getRFlag(), | ||
124 | + is(true)); | ||
125 | + } | ||
126 | + } | ||
127 | + | ||
128 | + @Test | ||
129 | + public void tunnelProviderAddedTest2() throws PcepParseException, PcepOutOfBoundMessageException { | ||
130 | + PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); | ||
131 | + | ||
132 | + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, | ||
133 | + 0x00, 0x00, 0x00, 0x01, // SRP object | ||
134 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
135 | + 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x24, 0x00, // LSP object | ||
136 | + 0x00, 0x10, (byte) 0xAB, | ||
137 | + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path tlv | ||
138 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
139 | + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, | ||
140 | + 0x05, 0x05, 0x05, | ||
141 | + | ||
142 | + 0x07, 0x10, 0x00, 0x14, // ERO object | ||
143 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
144 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, }; | ||
145 | + | ||
146 | + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); | ||
147 | + buffer.writeBytes(reportMsg); | ||
148 | + | ||
149 | + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | ||
150 | + PcepMessage message = reader.readFrom(buffer); | ||
151 | + | ||
152 | + PcepClientImpl pc = new PcepClientImpl(); | ||
153 | + PcepPacketStats pktStats = new PcepPacketStatsImpl(); | ||
154 | + | ||
155 | + pc.init(pccId, PcepVersion.PCEP_1, pktStats); | ||
156 | + pc.setChannel(channel); | ||
157 | + pc.setAgent(controllerImpl.agent); | ||
158 | + pc.setConnected(true); | ||
159 | + pc.setCapability(new ClientCapability(true, true, true, true, true)); | ||
160 | + | ||
161 | + controllerImpl.agent.addConnectedClient(pccId, pc); | ||
162 | + controllerImpl.processClientMessage(pccId, message); | ||
163 | + | ||
164 | + pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED); | ||
165 | + pc.setLabelDbSyncStatus(PcepSyncStatus.IN_SYNC); | ||
166 | + pc.setLabelDbSyncStatus(PcepSyncStatus.SYNCED); | ||
167 | + } | ||
168 | + | ||
169 | + class PcepEventListenerAdapter implements PcepEventListener { | ||
170 | + | ||
171 | + public List<PcepMessage> handledMsg = new ArrayList<>(); | ||
172 | + public List<Tunnel> tunnelsToBeUpdatedToNw = new ArrayList<>(); | ||
173 | + public List<Tunnel> deletedFromNwTunnels = new ArrayList<>(); | ||
174 | + | ||
175 | + @Override | ||
176 | + public void handleMessage(PccId pccId, PcepMessage msg) { | ||
177 | + handledMsg.add(msg); | ||
178 | + } | ||
179 | + | ||
180 | + @Override | ||
181 | + public void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction) { | ||
182 | + if (endOfSyncAction == SEND_UPDATE) { | ||
183 | + tunnelsToBeUpdatedToNw.add(tunnel); | ||
184 | + return; | ||
185 | + } else if (endOfSyncAction == UNSTABLE) { | ||
186 | + deletedFromNwTunnels.add(tunnel); | ||
187 | + } | ||
188 | + } | ||
189 | + } | ||
190 | + | ||
191 | + class MockChannel implements Channel { | ||
192 | + private List<PcepMessage> msgOnWire = new ArrayList<>(); | ||
193 | + | ||
194 | + @Override | ||
195 | + public ChannelFuture write(Object o) { | ||
196 | + if (o instanceof List<?>) { | ||
197 | + @SuppressWarnings("unchecked") | ||
198 | + List<PcepMessage> msgs = (List<PcepMessage>) o; | ||
199 | + for (PcepMessage msg : msgs) { | ||
200 | + if (msg instanceof PcepInitiateMsg) { | ||
201 | + msgOnWire.add(msg); | ||
202 | + } | ||
203 | + } | ||
204 | + } | ||
205 | + return null; | ||
206 | + } | ||
207 | + | ||
208 | + public List<PcepMessage> msgsWritten() { | ||
209 | + return msgOnWire; | ||
210 | + } | ||
211 | + | ||
212 | + @Override | ||
213 | + public int compareTo(Channel o) { | ||
214 | + // TODO Auto-generated method stub | ||
215 | + return 0; | ||
216 | + } | ||
217 | + | ||
218 | + @Override | ||
219 | + public Integer getId() { | ||
220 | + // TODO Auto-generated method stub | ||
221 | + return null; | ||
222 | + } | ||
223 | + | ||
224 | + @Override | ||
225 | + public ChannelFactory getFactory() { | ||
226 | + // TODO Auto-generated method stub | ||
227 | + return null; | ||
228 | + } | ||
229 | + | ||
230 | + @Override | ||
231 | + public Channel getParent() { | ||
232 | + // TODO Auto-generated method stub | ||
233 | + return null; | ||
234 | + } | ||
235 | + | ||
236 | + @Override | ||
237 | + public ChannelConfig getConfig() { | ||
238 | + // TODO Auto-generated method stub | ||
239 | + return null; | ||
240 | + } | ||
241 | + | ||
242 | + @Override | ||
243 | + public ChannelPipeline getPipeline() { | ||
244 | + // TODO Auto-generated method stub | ||
245 | + return null; | ||
246 | + } | ||
247 | + | ||
248 | + @Override | ||
249 | + public boolean isOpen() { | ||
250 | + // TODO Auto-generated method stub | ||
251 | + return false; | ||
252 | + } | ||
253 | + | ||
254 | + @Override | ||
255 | + public boolean isBound() { | ||
256 | + // TODO Auto-generated method stub | ||
257 | + return false; | ||
258 | + } | ||
259 | + | ||
260 | + @Override | ||
261 | + public boolean isConnected() { | ||
262 | + // TODO Auto-generated method stub | ||
263 | + return false; | ||
264 | + } | ||
265 | + | ||
266 | + @Override | ||
267 | + public SocketAddress getLocalAddress() { | ||
268 | + // TODO Auto-generated method stub | ||
269 | + return null; | ||
270 | + } | ||
271 | + | ||
272 | + @Override | ||
273 | + public SocketAddress getRemoteAddress() { | ||
274 | + // TODO Auto-generated method stub | ||
275 | + return null; | ||
276 | + } | ||
277 | + | ||
278 | + @Override | ||
279 | + public ChannelFuture write(Object message, SocketAddress remoteAddress) { | ||
280 | + // TODO Auto-generated method stub | ||
281 | + return null; | ||
282 | + } | ||
283 | + | ||
284 | + @Override | ||
285 | + public ChannelFuture bind(SocketAddress localAddress) { | ||
286 | + // TODO Auto-generated method stub | ||
287 | + return null; | ||
288 | + } | ||
289 | + | ||
290 | + @Override | ||
291 | + public ChannelFuture connect(SocketAddress remoteAddress) { | ||
292 | + // TODO Auto-generated method stub | ||
293 | + return null; | ||
294 | + } | ||
295 | + | ||
296 | + @Override | ||
297 | + public ChannelFuture disconnect() { | ||
298 | + // TODO Auto-generated method stub | ||
299 | + return null; | ||
300 | + } | ||
301 | + | ||
302 | + @Override | ||
303 | + public ChannelFuture unbind() { | ||
304 | + // TODO Auto-generated method stub | ||
305 | + return null; | ||
306 | + } | ||
307 | + | ||
308 | + @Override | ||
309 | + public ChannelFuture close() { | ||
310 | + // TODO Auto-generated method stub | ||
311 | + return null; | ||
312 | + } | ||
313 | + | ||
314 | + @Override | ||
315 | + public ChannelFuture getCloseFuture() { | ||
316 | + // TODO Auto-generated method stub | ||
317 | + return null; | ||
318 | + } | ||
319 | + | ||
320 | + @Override | ||
321 | + public int getInterestOps() { | ||
322 | + // TODO Auto-generated method stub | ||
323 | + return 0; | ||
324 | + } | ||
325 | + | ||
326 | + @Override | ||
327 | + public boolean isReadable() { | ||
328 | + // TODO Auto-generated method stub | ||
329 | + return false; | ||
330 | + } | ||
331 | + | ||
332 | + @Override | ||
333 | + public boolean isWritable() { | ||
334 | + // TODO Auto-generated method stub | ||
335 | + return false; | ||
336 | + } | ||
337 | + | ||
338 | + @Override | ||
339 | + public ChannelFuture setInterestOps(int interestOps) { | ||
340 | + // TODO Auto-generated method stub | ||
341 | + return null; | ||
342 | + } | ||
343 | + | ||
344 | + @Override | ||
345 | + public ChannelFuture setReadable(boolean readable) { | ||
346 | + // TODO Auto-generated method stub | ||
347 | + return null; | ||
348 | + } | ||
349 | + | ||
350 | + @Override | ||
351 | + public boolean getUserDefinedWritability(int index) { | ||
352 | + // TODO Auto-generated method stub | ||
353 | + return false; | ||
354 | + } | ||
355 | + | ||
356 | + @Override | ||
357 | + public void setUserDefinedWritability(int index, boolean isWritable) { | ||
358 | + // TODO Auto-generated method stub | ||
359 | + | ||
360 | + } | ||
361 | + | ||
362 | + @Override | ||
363 | + public Object getAttachment() { | ||
364 | + // TODO Auto-generated method stub | ||
365 | + return null; | ||
366 | + } | ||
367 | + | ||
368 | + @Override | ||
369 | + public void setAttachment(Object attachment) { | ||
370 | + // TODO Auto-generated method stub | ||
371 | + | ||
372 | + } | ||
373 | + } | ||
374 | + | ||
375 | + class MockTunnelService implements TunnelService { | ||
376 | + private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<TunnelId, Tunnel>(); | ||
377 | + private int tunnelIdCounter = 0; | ||
378 | + | ||
379 | + @Override | ||
380 | + public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { | ||
381 | + TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | ||
382 | + Tunnel tunnelToInsert = new DefaultTunnel(tunnel.providerId(), tunnel.src(), tunnel.dst(), tunnel.type(), | ||
383 | + tunnel.state(), tunnel.groupId(), tunnelId, tunnel.tunnelName(), | ||
384 | + path, tunnel.annotations()); | ||
385 | + tunnelIdAsKeyStore.put(tunnelId, tunnelToInsert); | ||
386 | + return tunnelId; | ||
387 | + } | ||
388 | + | ||
389 | + @Override | ||
390 | + public Tunnel queryTunnel(TunnelId tunnelId) { | ||
391 | + for (TunnelId tunnelIdKey : tunnelIdAsKeyStore.keySet()) { | ||
392 | + if (tunnelIdKey.equals(tunnelId)) { | ||
393 | + return tunnelIdAsKeyStore.get(tunnelId); | ||
394 | + } | ||
395 | + } | ||
396 | + return null; | ||
397 | + } | ||
398 | + | ||
399 | + @Override | ||
400 | + public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { | ||
401 | + Collection<Tunnel> result = new HashSet<Tunnel>(); | ||
402 | + Tunnel tunnel = null; | ||
403 | + for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) { | ||
404 | + tunnel = tunnelIdAsKeyStore.get(tunnelId); | ||
405 | + | ||
406 | + if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) { | ||
407 | + result.add(tunnel); | ||
408 | + } | ||
409 | + } | ||
410 | + | ||
411 | + return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result); | ||
412 | + } | ||
413 | + | ||
414 | + @Override | ||
415 | + public Collection<Tunnel> queryTunnel(Tunnel.Type type) { | ||
416 | + Collection<Tunnel> result = new HashSet<Tunnel>(); | ||
417 | + | ||
418 | + for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) { | ||
419 | + result.add(tunnelIdAsKeyStore.get(tunnelId)); | ||
420 | + } | ||
421 | + | ||
422 | + return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result); | ||
423 | + } | ||
424 | + | ||
425 | + @Override | ||
426 | + public Collection<Tunnel> queryAllTunnels() { | ||
427 | + Collection<Tunnel> result = new HashSet<Tunnel>(); | ||
428 | + | ||
429 | + for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) { | ||
430 | + result.add(tunnelIdAsKeyStore.get(tunnelId)); | ||
431 | + } | ||
432 | + | ||
433 | + return result.size() == 0 ? Collections.emptySet() : ImmutableSet.copyOf(result); | ||
434 | + } | ||
435 | + | ||
436 | + @Override | ||
437 | + public void addListener(TunnelListener listener) { | ||
438 | + // TODO Auto-generated method stub | ||
439 | + | ||
440 | + } | ||
441 | + | ||
442 | + @Override | ||
443 | + public void removeListener(TunnelListener listener) { | ||
444 | + // TODO Auto-generated method stub | ||
445 | + | ||
446 | + } | ||
447 | + | ||
448 | + @Override | ||
449 | + public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { | ||
450 | + // TODO Auto-generated method stub | ||
451 | + return null; | ||
452 | + } | ||
453 | + | ||
454 | + @Override | ||
455 | + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName, | ||
456 | + Annotations... annotations) { | ||
457 | + // TODO Auto-generated method stub | ||
458 | + return null; | ||
459 | + } | ||
460 | + | ||
461 | + @Override | ||
462 | + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, | ||
463 | + Annotations... annotations) { | ||
464 | + // TODO Auto-generated method stub | ||
465 | + return null; | ||
466 | + } | ||
467 | + | ||
468 | + @Override | ||
469 | + public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, | ||
470 | + Type type, Annotations... annotations) { | ||
471 | + // TODO Auto-generated method stub | ||
472 | + return null; | ||
473 | + } | ||
474 | + | ||
475 | + @Override | ||
476 | + public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) { | ||
477 | + // TODO Auto-generated method stub | ||
478 | + return false; | ||
479 | + } | ||
480 | + | ||
481 | + @Override | ||
482 | + public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) { | ||
483 | + // TODO Auto-generated method stub | ||
484 | + return false; | ||
485 | + } | ||
486 | + | ||
487 | + @Override | ||
488 | + public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) { | ||
489 | + // TODO Auto-generated method stub | ||
490 | + return false; | ||
491 | + } | ||
492 | + | ||
493 | + @Override | ||
494 | + public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type, | ||
495 | + Annotations... annotations) { | ||
496 | + // TODO Auto-generated method stub | ||
497 | + return false; | ||
498 | + } | ||
499 | + | ||
500 | + @Override | ||
501 | + public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, | ||
502 | + Annotations... annotations) { | ||
503 | + // TODO Auto-generated method stub | ||
504 | + return false; | ||
505 | + } | ||
506 | + | ||
507 | + @Override | ||
508 | + public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) { | ||
509 | + // TODO Auto-generated method stub | ||
510 | + return null; | ||
511 | + } | ||
512 | + | ||
513 | + @Override | ||
514 | + public int tunnelCount() { | ||
515 | + // TODO Auto-generated method stub | ||
516 | + return 0; | ||
517 | + } | ||
518 | + | ||
519 | + @Override | ||
520 | + public Iterable<Tunnel> getTunnels(DeviceId deviceId) { | ||
521 | + // TODO Auto-generated method stub | ||
522 | + return null; | ||
523 | + } | ||
524 | + } | ||
525 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -36,7 +36,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { | ... | @@ -36,7 +36,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { |
36 | 0 1 2 3 | 36 | 0 1 2 3 |
37 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 37 | 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
38 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 38 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
39 | - | Type=TBD | Length = 8 | | 39 | + | Type=TBD | Length = 4 | |
40 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 40 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
41 | | nexthop IPv4 address | | 41 | | nexthop IPv4 address | |
42 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 42 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
... | @@ -46,7 +46,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { | ... | @@ -46,7 +46,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { |
46 | */ | 46 | */ |
47 | protected static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class); | 47 | protected static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class); |
48 | 48 | ||
49 | - public static final short TYPE = 2; //to be defined | 49 | + public static final short TYPE = (short) 65289; //to be defined |
50 | //Length is header + value | 50 | //Length is header + value |
51 | public static final short LENGTH = 8; | 51 | public static final short LENGTH = 8; |
52 | public static final short VALUE_LENGTH = 4; | 52 | public static final short VALUE_LENGTH = 4; |
... | @@ -93,7 +93,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { | ... | @@ -93,7 +93,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { |
93 | 93 | ||
94 | @Override | 94 | @Override |
95 | public short getLength() { | 95 | public short getLength() { |
96 | - return LENGTH; | 96 | + return VALUE_LENGTH; |
97 | } | 97 | } |
98 | 98 | ||
99 | @Override | 99 | @Override |
... | @@ -117,7 +117,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { | ... | @@ -117,7 +117,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { |
117 | public int write(ChannelBuffer c) { | 117 | public int write(ChannelBuffer c) { |
118 | int iStartIndex = c.writerIndex(); | 118 | int iStartIndex = c.writerIndex(); |
119 | c.writeShort(TYPE); | 119 | c.writeShort(TYPE); |
120 | - c.writeShort(LENGTH); | 120 | + c.writeShort(VALUE_LENGTH); |
121 | c.writeInt(rawValue); | 121 | c.writeInt(rawValue); |
122 | return c.writerIndex() - iStartIndex; | 122 | return c.writerIndex() - iStartIndex; |
123 | } | 123 | } |
... | @@ -136,7 +136,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { | ... | @@ -136,7 +136,7 @@ public class NexthopIPv4addressTlv implements PcepValueType { |
136 | public String toString() { | 136 | public String toString() { |
137 | return MoreObjects.toStringHelper(getClass()) | 137 | return MoreObjects.toStringHelper(getClass()) |
138 | .add("Type", TYPE) | 138 | .add("Type", TYPE) |
139 | - .add("Length", LENGTH) | 139 | + .add("Length", VALUE_LENGTH) |
140 | .add("Ipv4Address ", rawValue) | 140 | .add("Ipv4Address ", rawValue) |
141 | .toString(); | 141 | .toString(); |
142 | } | 142 | } | ... | ... |
... | @@ -82,15 +82,21 @@ import org.onosproject.pcepio.protocol.PcepUpdateMsg; | ... | @@ -82,15 +82,21 @@ import org.onosproject.pcepio.protocol.PcepUpdateMsg; |
82 | import org.onosproject.pcepio.protocol.PcepUpdateRequest; | 82 | import org.onosproject.pcepio.protocol.PcepUpdateRequest; |
83 | import org.onosproject.pcepio.types.IPv4SubObject; | 83 | import org.onosproject.pcepio.types.IPv4SubObject; |
84 | import org.onosproject.pcepio.types.NexthopIPv4addressTlv; | 84 | import org.onosproject.pcepio.types.NexthopIPv4addressTlv; |
85 | +import org.onosproject.pcepio.types.PathSetupTypeTlv; | ||
85 | import org.onosproject.pcepio.types.PcepLabelDownload; | 86 | import org.onosproject.pcepio.types.PcepLabelDownload; |
86 | import org.onosproject.pcepio.types.PcepLabelMap; | 87 | import org.onosproject.pcepio.types.PcepLabelMap; |
87 | import org.onosproject.pcepio.types.PcepValueType; | 88 | import org.onosproject.pcepio.types.PcepValueType; |
88 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | 89 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
90 | +import org.onosproject.pcepio.types.SymbolicPathNameTlv; | ||
91 | +import org.onosproject.pcep.controller.LspType; | ||
89 | import org.onosproject.pcep.controller.SrpIdGenerators; | 92 | import org.onosproject.pcep.controller.SrpIdGenerators; |
90 | import org.onosproject.pcep.controller.PcepAnnotationKeys; | 93 | import org.onosproject.pcep.controller.PcepAnnotationKeys; |
91 | import org.osgi.service.component.ComponentContext; | 94 | import org.osgi.service.component.ComponentContext; |
92 | import org.slf4j.Logger; | 95 | import org.slf4j.Logger; |
93 | 96 | ||
97 | +import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; | ||
98 | +import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; | ||
99 | +import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCE_INIT; | ||
94 | import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC; | 100 | import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC; |
95 | import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; | 101 | import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; |
96 | import static org.onosproject.net.flow.criteria.Criterion.Type.EXTENSION; | 102 | import static org.onosproject.net.flow.criteria.Criterion.Type.EXTENSION; |
... | @@ -447,20 +453,34 @@ public class BgpcepFlowRuleProvider extends AbstractProvider | ... | @@ -447,20 +453,34 @@ public class BgpcepFlowRuleProvider extends AbstractProvider |
447 | 453 | ||
448 | srpObj = getSrpObject(pc, type, false); | 454 | srpObj = getSrpObject(pc, type, false); |
449 | 455 | ||
450 | - String lspId = tunnel.annotations().value(PcepAnnotationKeys.PLSP_ID); | 456 | + String lspId = tunnel.annotations().value(PcepAnnotationKeys.LOCAL_LSP_ID); |
451 | - String plspId = tunnel.annotations().value(PcepAnnotationKeys.LOCAL_LSP_ID); | 457 | + String plspId = tunnel.annotations().value(PcepAnnotationKeys.PLSP_ID); |
452 | String tunnelIdentifier = tunnel.annotations().value(PcepAnnotationKeys.PCC_TUNNEL_ID); | 458 | String tunnelIdentifier = tunnel.annotations().value(PcepAnnotationKeys.PCC_TUNNEL_ID); |
453 | 459 | ||
454 | LinkedList<PcepValueType> tlvs = new LinkedList<>(); | 460 | LinkedList<PcepValueType> tlvs = new LinkedList<>(); |
455 | StatefulIPv4LspIdentifiersTlv lspIdTlv = new StatefulIPv4LspIdentifiersTlv(((IpTunnelEndPoint) tunnel.src()) | 461 | StatefulIPv4LspIdentifiersTlv lspIdTlv = new StatefulIPv4LspIdentifiersTlv(((IpTunnelEndPoint) tunnel.src()) |
456 | - .ip().getIp4Address().toInt(), Short.valueOf(lspId), Short.valueOf(tunnelIdentifier), 0, | 462 | + .ip().getIp4Address().toInt(), Short.valueOf(lspId), Short.valueOf(tunnelIdentifier), |
463 | + ((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt(), | ||
457 | ((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt()); | 464 | ((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt()); |
458 | tlvs.add(lspIdTlv); | 465 | tlvs.add(lspIdTlv); |
459 | 466 | ||
467 | + if (tunnel.tunnelName().value() != null) { | ||
468 | + SymbolicPathNameTlv pathNameTlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); | ||
469 | + tlvs.add(pathNameTlv); | ||
470 | + } | ||
471 | + | ||
472 | + boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false | ||
473 | + : Boolean.valueOf(tunnel.annotations() | ||
474 | + .value(DELEGATE)); | ||
475 | + boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false | ||
476 | + : Boolean.valueOf(tunnel.annotations() | ||
477 | + .value(PCE_INIT)); | ||
478 | + | ||
460 | lspObj = pc.factory().buildLspObject() | 479 | lspObj = pc.factory().buildLspObject() |
461 | .setRFlag(false) | 480 | .setRFlag(false) |
462 | .setAFlag(true) | 481 | .setAFlag(true) |
463 | - .setDFlag(true) | 482 | + .setDFlag(delegated) |
483 | + .setCFlag(initiated) | ||
464 | .setPlspId(Integer.valueOf(plspId)) | 484 | .setPlspId(Integer.valueOf(plspId)) |
465 | .setOptionalTlv(tlvs) | 485 | .setOptionalTlv(tlvs) |
466 | .build(); | 486 | .build(); |
... | @@ -495,9 +515,15 @@ public class BgpcepFlowRuleProvider extends AbstractProvider | ... | @@ -495,9 +515,15 @@ public class BgpcepFlowRuleProvider extends AbstractProvider |
495 | return; | 515 | return; |
496 | } | 516 | } |
497 | 517 | ||
518 | + // set PathSetupTypeTlv of SRP object | ||
519 | + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); | ||
520 | + LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)); | ||
521 | + llOptionalTlv.add(new PathSetupTypeTlv(lspSigType.type())); | ||
522 | + | ||
498 | PcepSrpObject srpObj = pc.factory().buildSrpObject() | 523 | PcepSrpObject srpObj = pc.factory().buildSrpObject() |
499 | .setRFlag(false) | 524 | .setRFlag(false) |
500 | .setSrpID(SrpIdGenerators.create()) | 525 | .setSrpID(SrpIdGenerators.create()) |
526 | + .setOptionalTlv(llOptionalTlv) | ||
501 | .build(); | 527 | .build(); |
502 | 528 | ||
503 | PcepEroObject eroObj = pc.factory().buildEroObject() | 529 | PcepEroObject eroObj = pc.factory().buildEroObject() | ... | ... |
... | @@ -78,6 +78,7 @@ import org.onosproject.pcep.api.PcepTunnel.PathType; | ... | @@ -78,6 +78,7 @@ import org.onosproject.pcep.api.PcepTunnel.PathType; |
78 | import org.onosproject.pcep.api.PcepTunnelListener; | 78 | import org.onosproject.pcep.api.PcepTunnelListener; |
79 | import org.onosproject.pcep.api.PcepTunnelStatistics; | 79 | import org.onosproject.pcep.api.PcepTunnelStatistics; |
80 | import org.onosproject.pcep.controller.LspKey; | 80 | import org.onosproject.pcep.controller.LspKey; |
81 | +import org.onosproject.pcep.controller.LspType; | ||
81 | import org.onosproject.pcep.controller.PccId; | 82 | import org.onosproject.pcep.controller.PccId; |
82 | import org.onosproject.pcep.controller.PcepClient; | 83 | import org.onosproject.pcep.controller.PcepClient; |
83 | import org.onosproject.pcep.controller.PcepClientController; | 84 | import org.onosproject.pcep.controller.PcepClientController; |
... | @@ -140,8 +141,9 @@ import static org.onosproject.net.DefaultAnnotations.EMPTY; | ... | @@ -140,8 +141,9 @@ import static org.onosproject.net.DefaultAnnotations.EMPTY; |
140 | import static org.onosproject.net.DeviceId.deviceId; | 141 | import static org.onosproject.net.DeviceId.deviceId; |
141 | import static org.onosproject.net.PortNumber.portNumber; | 142 | import static org.onosproject.net.PortNumber.portNumber; |
142 | import static org.onosproject.pcep.api.PcepDpid.uri; | 143 | import static org.onosproject.pcep.api.PcepDpid.uri; |
143 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | 144 | +import static org.onosproject.pcep.controller.LspType.WITH_SIGNALLING; |
144 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING; | 145 | +import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING; |
146 | +import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | ||
145 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH; | 147 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH; |
146 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID; | 148 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID; |
147 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; | 149 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; |
... | @@ -157,7 +159,6 @@ import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE; | ... | @@ -157,7 +159,6 @@ import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE; |
157 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; | 159 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; |
158 | import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE; | 160 | import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE; |
159 | import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE; | 161 | import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE; |
160 | -import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_DELETE; | ||
161 | import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.IGP_METRIC; | 162 | import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.IGP_METRIC; |
162 | import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.TE_METRIC; | 163 | import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.TE_METRIC; |
163 | import static org.slf4j.LoggerFactory.getLogger; | 164 | import static org.slf4j.LoggerFactory.getLogger; |
... | @@ -311,7 +312,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -311,7 +312,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
311 | 312 | ||
312 | //TODO: tunnel which is passed doesn't have tunnelID | 313 | //TODO: tunnel which is passed doesn't have tunnelID |
313 | if (tunnel.annotations().value(PLSP_ID) != null) { | 314 | if (tunnel.annotations().value(PLSP_ID) != null) { |
314 | - updateTunnel(tunnel, path); | 315 | + if (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) != WITHOUT_SIGNALLING_AND_WITHOUT_SR) { |
316 | + // For CR LSPs, BGP flow provider will send update message after pushing labels. | ||
317 | + updateTunnel(tunnel, path); | ||
318 | + } | ||
315 | return; | 319 | return; |
316 | } | 320 | } |
317 | 321 | ||
... | @@ -1219,8 +1223,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1219,8 +1223,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1219 | 1223 | ||
1220 | tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()) | 1224 | tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()) |
1221 | .ip().getIp4Address().toInt()), | 1225 | .ip().getIp4Address().toInt()), |
1222 | - localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip() | 1226 | + localLspId, pccTunnelId, |
1223 | - .getIp4Address().toInt())); | 1227 | + ((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt(), |
1228 | + (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())); | ||
1224 | llOptionalTlv.add(tlv); | 1229 | llOptionalTlv.add(tlv); |
1225 | } | 1230 | } |
1226 | 1231 | ||
... | @@ -1229,9 +1234,18 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1229,9 +1234,18 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1229 | llOptionalTlv.add(tlv); | 1234 | llOptionalTlv.add(tlv); |
1230 | } | 1235 | } |
1231 | 1236 | ||
1237 | + boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false | ||
1238 | + : Boolean.valueOf(tunnel.annotations() | ||
1239 | + .value(DELEGATE)); | ||
1240 | + boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false | ||
1241 | + : Boolean.valueOf(tunnel.annotations() | ||
1242 | + .value(PCE_INIT)); | ||
1243 | + | ||
1232 | // build lsp object | 1244 | // build lsp object |
1233 | PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true) | 1245 | PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true) |
1234 | .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID))) | 1246 | .setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID))) |
1247 | + .setDFlag(delegated) | ||
1248 | + .setCFlag(initiated) | ||
1235 | .setOptionalTlv(llOptionalTlv).build(); | 1249 | .setOptionalTlv(llOptionalTlv).build(); |
1236 | // build ero object | 1250 | // build ero object |
1237 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); | 1251 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); |
... | @@ -1818,36 +1832,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1818,36 +1832,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1818 | tunnelRemoved(td); | 1832 | tunnelRemoved(td); |
1819 | } | 1833 | } |
1820 | } | 1834 | } |
1821 | - | ||
1822 | - @Override | ||
1823 | - public void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction) { | ||
1824 | - try { | ||
1825 | - if ((msg instanceof PcepInitiateMsg) && (endOfSyncAction == SEND_DELETE)) { | ||
1826 | - PcepClient pc = pcepClientController.getClient(pccId); | ||
1827 | - LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = ((PcepInitiateMsg) msg) | ||
1828 | - .getPcInitiatedLspRequestList(); | ||
1829 | - PcInitiatedLspRequest pcInitMsg = llPcInitiatedLspRequestList.iterator().next(); | ||
1830 | - | ||
1831 | - if (pcInitMsg != null) { | ||
1832 | - PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(SrpIdGenerators.create()) | ||
1833 | - .setRFlag(true).build(); | ||
1834 | - | ||
1835 | - PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest() | ||
1836 | - .setLspObject(pcInitMsg.getLspObject()).setSrpObject(srpobj).build(); | ||
1837 | - | ||
1838 | - llPcInitiatedLspRequestList.remove(pcInitMsg); | ||
1839 | - llPcInitiatedLspRequestList.add(releaseLspRequest); | ||
1840 | - | ||
1841 | - PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg() | ||
1842 | - .setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build(); | ||
1843 | - | ||
1844 | - pc.sendMessage(Collections.singletonList(pcInitiateMsg)); | ||
1845 | - } | ||
1846 | - } | ||
1847 | - } catch (PcepParseException e) { | ||
1848 | - log.error("Exception occured while sending initiate delete message {}", e.getMessage()); | ||
1849 | - } | ||
1850 | - } | ||
1851 | } | 1835 | } |
1852 | @Override | 1836 | @Override |
1853 | public Tunnel tunnelQueryById(TunnelId tunnelId) { | 1837 | public Tunnel tunnelQueryById(TunnelId tunnelId) { | ... | ... |
... | @@ -20,9 +20,9 @@ import static org.hamcrest.Matchers.nullValue; | ... | @@ -20,9 +20,9 @@ import static org.hamcrest.Matchers.nullValue; |
20 | import static org.hamcrest.core.Is.is; | 20 | import static org.hamcrest.core.Is.is; |
21 | import static org.hamcrest.core.IsNot.not; | 21 | import static org.hamcrest.core.IsNot.not; |
22 | import static org.onosproject.net.DefaultAnnotations.EMPTY; | 22 | import static org.onosproject.net.DefaultAnnotations.EMPTY; |
23 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | 23 | +import static org.onosproject.pcep.controller.LspType.WITH_SIGNALLING; |
24 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING; | 24 | +import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING; |
25 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 25 | +import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
26 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; | 26 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; |
27 | 27 | ||
28 | import java.io.IOException; | 28 | import java.io.IOException; | ... | ... |
... | @@ -20,9 +20,9 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -20,9 +20,9 @@ import static org.hamcrest.MatcherAssert.assertThat; |
20 | import static org.hamcrest.core.Is.is; | 20 | import static org.hamcrest.core.Is.is; |
21 | import static org.hamcrest.core.IsNot.not; | 21 | import static org.hamcrest.core.IsNot.not; |
22 | import static org.hamcrest.Matchers.nullValue; | 22 | import static org.hamcrest.Matchers.nullValue; |
23 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | 23 | +import static org.onosproject.pcep.controller.LspType.WITH_SIGNALLING; |
24 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING; | 24 | +import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING; |
25 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 25 | +import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
26 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; | 26 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; |
27 | 27 | ||
28 | import java.io.IOException; | 28 | import java.io.IOException; | ... | ... |
... | @@ -25,7 +25,7 @@ import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; | ... | @@ -25,7 +25,7 @@ import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; |
25 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID; | 25 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID; |
26 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID; | 26 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID; |
27 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; | 27 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; |
28 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 28 | +import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
29 | import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; | 29 | import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; |
30 | import static org.onosproject.net.Device.Type.ROUTER; | 30 | import static org.onosproject.net.Device.Type.ROUTER; |
31 | import static org.onosproject.net.MastershipRole.MASTER; | 31 | import static org.onosproject.net.MastershipRole.MASTER; | ... | ... |
... | @@ -19,7 +19,7 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -19,7 +19,7 @@ import static org.hamcrest.MatcherAssert.assertThat; |
19 | import static org.hamcrest.Matchers.nullValue; | 19 | import static org.hamcrest.Matchers.nullValue; |
20 | import static org.hamcrest.core.IsNot.not; | 20 | import static org.hamcrest.core.IsNot.not; |
21 | import static org.onosproject.net.DefaultAnnotations.EMPTY; | 21 | import static org.onosproject.net.DefaultAnnotations.EMPTY; |
22 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | 22 | +import static org.onosproject.pcep.controller.LspType.WITH_SIGNALLING; |
23 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; | 23 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; |
24 | 24 | ||
25 | import java.io.IOException; | 25 | import java.io.IOException; | ... | ... |
... | @@ -55,9 +55,9 @@ import org.onosproject.pcep.controller.PccId; | ... | @@ -55,9 +55,9 @@ import org.onosproject.pcep.controller.PccId; |
55 | import org.onosproject.pcepio.protocol.PcepVersion; | 55 | import org.onosproject.pcepio.protocol.PcepVersion; |
56 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | 56 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
57 | 57 | ||
58 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | 58 | +import static org.onosproject.pcep.controller.LspType.WITH_SIGNALLING; |
59 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING; | 59 | +import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING; |
60 | -import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 60 | +import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
61 | /** | 61 | /** |
62 | * Test for PCEP update tunnel. | 62 | * Test for PCEP update tunnel. |
63 | */ | 63 | */ | ... | ... |
-
Please register or login to post a comment