Committed by
Gerrit Code Review
[ONOS-4170] PCEP provider changes for LSPDB sync
Change-Id: I9229fec9d97dd46343cc809e33c92b9722ab7ed3
Showing
10 changed files
with
693 additions
and
195 deletions
... | @@ -95,18 +95,32 @@ public interface PcepClient { | ... | @@ -95,18 +95,32 @@ public interface PcepClient { |
95 | String channelId(); | 95 | String channelId(); |
96 | 96 | ||
97 | /** | 97 | /** |
98 | - * To set the status of state synchronization. | 98 | + * Sets the status of LSP state synchronization. |
99 | * | 99 | * |
100 | - * @param value to set the synchronization status | 100 | + * @param syncStatus LSP synchronization status to be set |
101 | */ | 101 | */ |
102 | - void setIsSyncComplete(boolean value); | 102 | + void setLspDbSyncStatus(PcepSyncStatus syncStatus); |
103 | 103 | ||
104 | /** | 104 | /** |
105 | - * Indicates the state synchronization status of this pcc. | 105 | + * Indicates the LSP state synchronization status of this pcc. |
106 | * | 106 | * |
107 | - * @return true/false if the synchronization is completed/not completed | 107 | + * @return LSP state synchronization status. |
108 | */ | 108 | */ |
109 | - boolean isSyncComplete(); | 109 | + PcepSyncStatus lspDbSyncStatus(); |
110 | + | ||
111 | + /** | ||
112 | + * Sets the status of label DB synchronization. | ||
113 | + * | ||
114 | + * @param syncStatus label DB synchronization status to be set | ||
115 | + */ | ||
116 | + void setLabelDbSyncStatus(PcepSyncStatus syncStatus); | ||
117 | + | ||
118 | + /** | ||
119 | + * Indicates the label DB synchronization status of this pcc. | ||
120 | + * | ||
121 | + * @return label DB synchronization status. | ||
122 | + */ | ||
123 | + PcepSyncStatus labelDbSyncStatus(); | ||
110 | 124 | ||
111 | /** | 125 | /** |
112 | * Sets capability negotiated during open message exchange. | 126 | * Sets capability negotiated during open message exchange. | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.pcep.controller; | ||
17 | + | ||
18 | +/** | ||
19 | + * Representation of PCEP database sync status on session establishment. | ||
20 | + */ | ||
21 | +public enum PcepSyncStatus { | ||
22 | + | ||
23 | + /** | ||
24 | + * Specifies that the DB state is not synchronized. | ||
25 | + */ | ||
26 | + NOT_SYNCED(0), | ||
27 | + | ||
28 | + /** | ||
29 | + * Specifies that the DB state is currently undergoing synchronization. | ||
30 | + */ | ||
31 | + IN_SYNC(1), | ||
32 | + | ||
33 | + /** | ||
34 | + * Specifies that the DB state synchronization is completed. | ||
35 | + */ | ||
36 | + SYNCED(2); | ||
37 | + | ||
38 | + int value; | ||
39 | + | ||
40 | + /** | ||
41 | + * Assign val with the value as the sync status. | ||
42 | + * | ||
43 | + * @param val sync status | ||
44 | + */ | ||
45 | + PcepSyncStatus(int val) { | ||
46 | + value = val; | ||
47 | + } | ||
48 | +} |
... | @@ -169,6 +169,12 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -169,6 +169,12 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | + /* | ||
173 | + * If MPLS LSR id and PCEP session socket IP addresses are not same, | ||
174 | + * the MPLS LSR id will be encoded in separate TLV. | ||
175 | + * We always maintain session information based on LSR ids. | ||
176 | + * The socket IP is stored in channel. | ||
177 | + */ | ||
172 | LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv(); | 178 | LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv(); |
173 | for (PcepValueType optionalTlv : optionalTlvs) { | 179 | for (PcepValueType optionalTlv : optionalTlvs) { |
174 | if (optionalTlv instanceof NodeAttributesTlv) { | 180 | if (optionalTlv instanceof NodeAttributesTlv) { | ... | ... |
... | @@ -27,6 +27,7 @@ import org.onlab.packet.IpAddress; | ... | @@ -27,6 +27,7 @@ import org.onlab.packet.IpAddress; |
27 | import org.onosproject.pcep.controller.ClientCapability; | 27 | import org.onosproject.pcep.controller.ClientCapability; |
28 | import org.onosproject.pcep.controller.PccId; | 28 | import org.onosproject.pcep.controller.PccId; |
29 | import org.onosproject.pcep.controller.PcepPacketStats; | 29 | import org.onosproject.pcep.controller.PcepPacketStats; |
30 | +import org.onosproject.pcep.controller.PcepSyncStatus; | ||
30 | import org.onosproject.pcep.controller.driver.PcepAgent; | 31 | import org.onosproject.pcep.controller.driver.PcepAgent; |
31 | import org.onosproject.pcep.controller.driver.PcepClientDriver; | 32 | import org.onosproject.pcep.controller.driver.PcepClientDriver; |
32 | import org.onosproject.pcepio.protocol.PcepFactories; | 33 | import org.onosproject.pcepio.protocol.PcepFactories; |
... | @@ -52,9 +53,10 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -52,9 +53,10 @@ public class PcepClientImpl implements PcepClientDriver { |
52 | protected String channelId; | 53 | protected String channelId; |
53 | 54 | ||
54 | private boolean connected; | 55 | private boolean connected; |
55 | - protected boolean startDriverHandshakeCalled = false; | 56 | + protected boolean startDriverHandshakeCalled; |
56 | - protected boolean isHandShakeComplete = false; | 57 | + protected boolean isHandShakeComplete; |
57 | - protected boolean isSyncComplete = false; | 58 | + private PcepSyncStatus lspDbSyncStatus; |
59 | + private PcepSyncStatus labelDbSyncStatus; | ||
58 | private PccId pccId; | 60 | private PccId pccId; |
59 | private PcepAgent agent; | 61 | private PcepAgent agent; |
60 | 62 | ||
... | @@ -175,13 +177,23 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -175,13 +177,23 @@ public class PcepClientImpl implements PcepClientDriver { |
175 | } | 177 | } |
176 | 178 | ||
177 | @Override | 179 | @Override |
178 | - public void setIsSyncComplete(boolean value) { | 180 | + public void setLspDbSyncStatus(PcepSyncStatus syncStatus) { |
179 | - this.isSyncComplete = value; | 181 | + this.lspDbSyncStatus = syncStatus; |
180 | } | 182 | } |
181 | 183 | ||
182 | @Override | 184 | @Override |
183 | - public boolean isSyncComplete() { | 185 | + public PcepSyncStatus lspDbSyncStatus() { |
184 | - return isSyncComplete; | 186 | + return lspDbSyncStatus; |
187 | + } | ||
188 | + | ||
189 | + @Override | ||
190 | + public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { | ||
191 | + this.labelDbSyncStatus = syncStatus; | ||
192 | + } | ||
193 | + | ||
194 | + @Override | ||
195 | + public PcepSyncStatus labelDbSyncStatus() { | ||
196 | + return labelDbSyncStatus; | ||
185 | } | 197 | } |
186 | 198 | ||
187 | @Override | 199 | @Override | ... | ... |
... | @@ -48,7 +48,7 @@ public class PcepLspObjectVer1 implements PcepLspObject { | ... | @@ -48,7 +48,7 @@ public class PcepLspObjectVer1 implements PcepLspObject { |
48 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 48 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
49 | | Object-Class | OT |Res|P|I| Object Length (bytes) | | 49 | | Object-Class | OT |Res|P|I| Object Length (bytes) | |
50 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 50 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
51 | - | PLSP-ID | Flag C| O|A|R|S|D| | 51 | + | PLSP-ID | Flag |C| O|A|R|S|D| |
52 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 52 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
53 | // TLVs // | 53 | // TLVs // |
54 | | | | 54 | | | |
... | @@ -116,6 +116,7 @@ public class PcepLspObjectVer1 implements PcepLspObject { | ... | @@ -116,6 +116,7 @@ public class PcepLspObjectVer1 implements PcepLspObject { |
116 | * @param bRFlag R flag | 116 | * @param bRFlag R flag |
117 | * @param bSFlag S flag | 117 | * @param bSFlag S flag |
118 | * @param bDFlag D flag | 118 | * @param bDFlag D flag |
119 | + * @param bCFlag C flag | ||
119 | * @param llOptionalTlv list of optional tlv | 120 | * @param llOptionalTlv list of optional tlv |
120 | */ | 121 | */ |
121 | public PcepLspObjectVer1(PcepObjectHeader lspObjHeader, int iPlspId, byte yOFlag, boolean bAFlag, boolean bRFlag, | 122 | public PcepLspObjectVer1(PcepObjectHeader lspObjHeader, int iPlspId, byte yOFlag, boolean bAFlag, boolean bRFlag, |
... | @@ -294,6 +295,9 @@ public class PcepLspObjectVer1 implements PcepLspObject { | ... | @@ -294,6 +295,9 @@ public class PcepLspObjectVer1 implements PcepLspObject { |
294 | } | 295 | } |
295 | 296 | ||
296 | int iTemp = iPlspId << PLSPID_SHIFT_VALUE; | 297 | int iTemp = iPlspId << PLSPID_SHIFT_VALUE; |
298 | + | ||
299 | + iTemp = iTemp | (((bCFlag) ? BIT_SET : BIT_RESET) << CFLAG_SHIFT_VALUE); | ||
300 | + | ||
297 | iTemp = iTemp | (yOFlag << OFLAG_SHIFT_VALUE); | 301 | iTemp = iTemp | (yOFlag << OFLAG_SHIFT_VALUE); |
298 | byte bFlag; | 302 | byte bFlag; |
299 | iTemp = bAFlag ? (iTemp | AFLAG_TEMP_SHIFT_VALUE) : iTemp; | 303 | iTemp = bAFlag ? (iTemp | AFLAG_TEMP_SHIFT_VALUE) : iTemp; | ... | ... |
... | @@ -51,4 +51,9 @@ public final class PcepAnnotationKeys { | ... | @@ -51,4 +51,9 @@ public final class PcepAnnotationKeys { |
51 | * Annotation key for the LSP id assigned per tunnel. | 51 | * Annotation key for the LSP id assigned per tunnel. |
52 | */ | 52 | */ |
53 | public static final String LOCAL_LSP_ID = "localLspId"; | 53 | public static final String LOCAL_LSP_ID = "localLspId"; |
54 | + | ||
55 | + /** | ||
56 | + * Annotation key for the identification of initiated LSP. | ||
57 | + */ | ||
58 | + public static final String PCE_INIT = "pceInit"; | ||
54 | } | 59 | } | ... | ... |
... | @@ -18,7 +18,6 @@ package org.onosproject.provider.pcep.tunnel.impl; | ... | @@ -18,7 +18,6 @@ package org.onosproject.provider.pcep.tunnel.impl; |
18 | import java.util.HashMap; | 18 | import java.util.HashMap; |
19 | import java.util.Map; | 19 | import java.util.Map; |
20 | 20 | ||
21 | -import org.apache.commons.collections.map.MultiKeyMap; | ||
22 | import org.onosproject.incubator.net.tunnel.TunnelId; | 21 | import org.onosproject.incubator.net.tunnel.TunnelId; |
23 | import org.onosproject.incubator.net.tunnel.TunnelProviderService; | 22 | import org.onosproject.incubator.net.tunnel.TunnelProviderService; |
24 | import org.slf4j.Logger; | 23 | import org.slf4j.Logger; |
... | @@ -40,8 +39,6 @@ public class PcepTunnelApiMapper { | ... | @@ -40,8 +39,6 @@ public class PcepTunnelApiMapper { |
40 | private Map<Integer, PcepTunnelData> tunnelDB; | 39 | private Map<Integer, PcepTunnelData> tunnelDB; |
41 | // Map to store the tunnel ids, given by core and given by pcc. | 40 | // Map to store the tunnel ids, given by core and given by pcc. |
42 | private Map<TunnelId, Integer> tunnelIdMap; | 41 | private Map<TunnelId, Integer> tunnelIdMap; |
43 | - //Map to store all the learnt tunnels. | ||
44 | - private MultiKeyMap pccTunnelDB = new MultiKeyMap(); | ||
45 | 42 | ||
46 | TunnelProviderService tunnelApiMapperservice; | 43 | TunnelProviderService tunnelApiMapperservice; |
47 | 44 | ||
... | @@ -193,14 +190,4 @@ public class PcepTunnelApiMapper { | ... | @@ -193,14 +190,4 @@ public class PcepTunnelApiMapper { |
193 | boolean retValue = tunnelDB.containsKey((new Integer(value))); | 190 | boolean retValue = tunnelDB.containsKey((new Integer(value))); |
194 | return retValue; | 191 | return retValue; |
195 | } | 192 | } |
196 | - | ||
197 | - /** | ||
198 | - * Add Learnt tunnels to pcc tunnel DB. | ||
199 | - * | ||
200 | - * @param pcepTunnelData pcep tunnel data | ||
201 | - */ | ||
202 | - public void addPccTunnelDB(PcepTunnelData pcepTunnelData) { | ||
203 | - pccTunnelDB.put(pcepTunnelData.statefulIpv4IndentifierTlv().getTunnelId() & 0xFFFFL, | ||
204 | - pcepTunnelData.statefulIpv4IndentifierTlv().getIpv4IngressAddress(), pcepTunnelData); | ||
205 | - } | ||
206 | } | 193 | } | ... | ... |
... | @@ -73,6 +73,7 @@ import org.onosproject.pcep.controller.PcepClient; | ... | @@ -73,6 +73,7 @@ import org.onosproject.pcep.controller.PcepClient; |
73 | import org.onosproject.pcep.controller.PcepClientController; | 73 | import org.onosproject.pcep.controller.PcepClientController; |
74 | import org.onosproject.pcep.controller.PcepClientListener; | 74 | import org.onosproject.pcep.controller.PcepClientListener; |
75 | import org.onosproject.pcep.controller.PcepEventListener; | 75 | import org.onosproject.pcep.controller.PcepEventListener; |
76 | +import org.onosproject.pcep.controller.PcepSyncStatus; | ||
76 | import org.onosproject.pcepio.exceptions.PcepParseException; | 77 | import org.onosproject.pcepio.exceptions.PcepParseException; |
77 | import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; | 78 | import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; |
78 | import org.onosproject.pcepio.protocol.PcepAttribute; | 79 | import org.onosproject.pcepio.protocol.PcepAttribute; |
... | @@ -98,6 +99,7 @@ import org.osgi.service.component.annotations.Modified; | ... | @@ -98,6 +99,7 @@ import org.osgi.service.component.annotations.Modified; |
98 | import org.slf4j.Logger; | 99 | import org.slf4j.Logger; |
99 | 100 | ||
100 | import java.util.ArrayList; | 101 | import java.util.ArrayList; |
102 | +import java.util.Arrays; | ||
101 | import java.util.Collection; | 103 | import java.util.Collection; |
102 | import java.util.Collections; | 104 | import java.util.Collections; |
103 | import java.util.Dictionary; | 105 | import java.util.Dictionary; |
... | @@ -105,6 +107,7 @@ import java.util.HashMap; | ... | @@ -105,6 +107,7 @@ import java.util.HashMap; |
105 | import java.util.LinkedList; | 107 | import java.util.LinkedList; |
106 | import java.util.List; | 108 | import java.util.List; |
107 | import java.util.ListIterator; | 109 | import java.util.ListIterator; |
110 | +import java.util.Map; | ||
108 | import java.util.Optional; | 111 | import java.util.Optional; |
109 | 112 | ||
110 | import static com.google.common.base.Preconditions.checkNotNull; | 113 | import static com.google.common.base.Preconditions.checkNotNull; |
... | @@ -116,15 +119,20 @@ import static org.onosproject.net.DeviceId.deviceId; | ... | @@ -116,15 +119,20 @@ import static org.onosproject.net.DeviceId.deviceId; |
116 | import static org.onosproject.net.PortNumber.portNumber; | 119 | import static org.onosproject.net.PortNumber.portNumber; |
117 | import static org.onosproject.pcep.api.PcepDpid.uri; | 120 | import static org.onosproject.pcep.api.PcepDpid.uri; |
118 | import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | 121 | import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; |
122 | +import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING; | ||
119 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH; | 123 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH; |
120 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID; | 124 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID; |
121 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE; | 125 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE; |
122 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID; | 126 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID; |
123 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID; | 127 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID; |
128 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCE_INIT; | ||
124 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE; | 129 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE; |
125 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE; | 130 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE; |
126 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT; | 131 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT; |
127 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE; | 132 | import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE; |
133 | +import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC; | ||
134 | +import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; | ||
135 | +import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; | ||
128 | import static org.slf4j.LoggerFactory.getLogger; | 136 | import static org.slf4j.LoggerFactory.getLogger; |
129 | 137 | ||
130 | /** | 138 | /** |
... | @@ -174,6 +182,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -174,6 +182,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
174 | protected PcepTunnelApiMapper pcepTunnelApiMapper = new PcepTunnelApiMapper(); | 182 | protected PcepTunnelApiMapper pcepTunnelApiMapper = new PcepTunnelApiMapper(); |
175 | private static final int DEFAULT_BANDWIDTH_VALUE = 10; | 183 | private static final int DEFAULT_BANDWIDTH_VALUE = 10; |
176 | 184 | ||
185 | + private Map<IpAddress, Map<TunnelId, Tunnel>> preSyncLspDbMap = new HashMap<>(); | ||
186 | + private Map<IpAddress, List<Tunnel>> syncCompleteDeleteList = new HashMap<>(); | ||
187 | + private Map<IpAddress, List<Tunnel>> syncCompleteUpdateList = new HashMap<>(); | ||
188 | + | ||
177 | /** | 189 | /** |
178 | * Creates a Tunnel provider. | 190 | * Creates a Tunnel provider. |
179 | */ | 191 | */ |
... | @@ -1089,13 +1101,39 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1089,13 +1101,39 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1089 | 1101 | ||
1090 | // Check the sync status | 1102 | // Check the sync status |
1091 | if (lspObj.getSFlag()) { | 1103 | if (lspObj.getSFlag()) { |
1092 | - handleSyncReport(stateRpt); | 1104 | + if (pcepClientController.getClient(pccId).lspDbSyncStatus() != IN_SYNC) { |
1105 | + pcepClientController.getClient(pccId).setLspDbSyncStatus(IN_SYNC); | ||
1106 | + | ||
1107 | + // On starting LSP-DB sync, store LSP DB locally for this PCC. | ||
1108 | + Map<TunnelId, Tunnel> preSyncLspDb = new HashMap<>(); | ||
1109 | + Collection<Tunnel> queriedTunnels = tunnelService.queryTunnel(MPLS); | ||
1110 | + | ||
1111 | + for (Tunnel tunnel : queriedTunnels) { | ||
1112 | + if (((IpTunnelEndPoint) tunnel.src()).ip().equals(pccId.ipAddress())) { | ||
1113 | + preSyncLspDb.put(tunnel.tunnelId(), tunnel); | ||
1114 | + } | ||
1115 | + } | ||
1116 | + | ||
1117 | + preSyncLspDbMap.put(pccId.ipAddress(), preSyncLspDb); | ||
1118 | + syncCompleteDeleteList.put(pccId.ipAddress(), new LinkedList<>()); | ||
1119 | + syncCompleteUpdateList.put(pccId.ipAddress(), new LinkedList<>()); | ||
1120 | + } | ||
1121 | + handleRptWithoutSrpId(stateRpt, pccId, IN_SYNC); | ||
1093 | continue; | 1122 | continue; |
1094 | - } else if (!pcepClientController.getClient(pccId).isSyncComplete()) { | 1123 | + |
1095 | - // sync is done | 1124 | + } else if (pcepClientController.getClient(pccId).lspDbSyncStatus() == IN_SYNC) { |
1096 | - pcepClientController.getClient(pccId).setIsSyncComplete(true); | 1125 | + // If sync flag is not set in the msg, and the |
1126 | + // previous state was "in sync" means this is | ||
1127 | + // end of sync message. PCRpt for end of sync | ||
1128 | + // does not carry any LSP report. | ||
1129 | + pcepClientController.getClient(pccId).setLspDbSyncStatus(SYNCED); | ||
1130 | + handleEndOfSyncAction(pccId); | ||
1097 | continue; | 1131 | continue; |
1098 | } | 1132 | } |
1133 | + | ||
1134 | + // For PCRpt without matching SRP id not during LSPDB sync. | ||
1135 | + handleRptWithoutSrpId(stateRpt, pccId, SYNCED); | ||
1136 | + continue; | ||
1099 | } | 1137 | } |
1100 | 1138 | ||
1101 | handleReportMessage(srpId, lspObj, stateRpt); | 1139 | handleReportMessage(srpId, lspObj, stateRpt); |
... | @@ -1121,11 +1159,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1121,11 +1159,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1121 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); | 1159 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); |
1122 | PcepTunnelData pcepTunnelData = pcepTunnelApiMapper.getDataFromTunnelRequestQueue(srpId); | 1160 | PcepTunnelData pcepTunnelData = pcepTunnelApiMapper.getDataFromTunnelRequestQueue(srpId); |
1123 | 1161 | ||
1124 | - if (pcepTunnelData == null) { | ||
1125 | - handleRptWithoutSrpId(stateRpt); | ||
1126 | - return; | ||
1127 | - } | ||
1128 | - | ||
1129 | // store the values required from report message | 1162 | // store the values required from report message |
1130 | pcepTunnelData.setPlspId(lspObj.getPlspId()); | 1163 | pcepTunnelData.setPlspId(lspObj.getPlspId()); |
1131 | pcepTunnelData.setLspAFlag(lspObj.getAFlag()); | 1164 | pcepTunnelData.setLspAFlag(lspObj.getAFlag()); |
... | @@ -1176,139 +1209,222 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1176,139 +1209,222 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1176 | pcepTunnelApiMapper.handleUpdateTunnelRequestQueue(srpId, pcepTunnelData); | 1209 | pcepTunnelApiMapper.handleUpdateTunnelRequestQueue(srpId, pcepTunnelData); |
1177 | } | 1210 | } |
1178 | 1211 | ||
1212 | + PcepLspStatus pcepLspStatus = PcepLspStatus.values()[lspObj.getOFlag()]; | ||
1213 | + | ||
1179 | if (lspObj.getRFlag()) { | 1214 | if (lspObj.getRFlag()) { |
1180 | tunnelRemoved(td); | 1215 | tunnelRemoved(td); |
1181 | } else { | 1216 | } else { |
1182 | - State tunnelState = PcepLspStatus | 1217 | + State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(pcepLspStatus); |
1183 | - .getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); | ||
1184 | tunnelUpdated(td, tunnelState); | 1218 | tunnelUpdated(td, tunnelState); |
1185 | } | 1219 | } |
1220 | + | ||
1221 | + // SR-TE also needs PCUpd msg after receiving PCRpt with status GOING-UP even | ||
1222 | + // though there are no labels to download for SR-TE. | ||
1223 | + if ((pcepLspStatus == PcepLspStatus.GOING_UP) | ||
1224 | + && (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) == SR_WITHOUT_SIGNALLING)) { | ||
1225 | + updateTunnel(tunnel, tunnel.path()); | ||
1226 | + } | ||
1186 | } | 1227 | } |
1187 | 1228 | ||
1188 | - /** | 1229 | + private void handleRptWithoutSrpId(PcepStateReport stateRpt, PccId pccId, PcepSyncStatus syncStatus) { |
1189 | - * Handles asynchronous report messages from PCC when LSPDB sync is not in progress. | ||
1190 | - * | ||
1191 | - * @param stateRpt parsed PCEP report msg. | ||
1192 | - */ | ||
1193 | - private void handleRptWithoutSrpId(PcepStateReport stateRpt) { | ||
1194 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); | 1230 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); |
1195 | - StatefulIPv4LspIdentifiersTlv ipv4LspTlv = null; | 1231 | + PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath(); |
1232 | + checkNotNull(msgPath); | ||
1233 | + PcepEroObject eroObj = msgPath.getEroObject(); | ||
1234 | + if (eroObj == null) { | ||
1235 | + log.error("ERO object is null in report message."); | ||
1236 | + return; | ||
1237 | + } | ||
1238 | + Path path = buildPathFromEroObj(eroObj, providerId); | ||
1239 | + | ||
1240 | + int bandwidth = 0; | ||
1241 | + if (msgPath.getBandwidthObject() != null) { | ||
1242 | + bandwidth = msgPath.getBandwidthObject().getBandwidth(); | ||
1243 | + } | ||
1244 | + | ||
1245 | + /* | ||
1246 | + * To carry PST TLV, SRP object can be present with value 0 even when PCRpt is not in response to any action | ||
1247 | + * from PCE. | ||
1248 | + */ | ||
1249 | + PcepSrpObject srpObj = stateRpt.getSrpObject(); | ||
1250 | + LspType lspType = WITH_SIGNALLING; | ||
1251 | + | ||
1252 | + if (null != srpObj) { | ||
1253 | + LinkedList<PcepValueType> llOptionalTlv = srpObj.getOptionalTlv(); | ||
1254 | + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); | ||
1255 | + | ||
1256 | + while (listIterator.hasNext()) { | ||
1257 | + PcepValueType tlv = listIterator.next(); | ||
1258 | + | ||
1259 | + switch (tlv.getType()) { | ||
1260 | + case PathSetupTypeTlv.TYPE: | ||
1261 | + lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())]; | ||
1262 | + break; | ||
1263 | + | ||
1264 | + default: | ||
1265 | + break; | ||
1266 | + } | ||
1267 | + } | ||
1268 | + } | ||
1196 | 1269 | ||
1197 | PcepLspObject lspObj = stateRpt.getLspObject(); | 1270 | PcepLspObject lspObj = stateRpt.getLspObject(); |
1198 | ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); | 1271 | ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); |
1272 | + StatefulIPv4LspIdentifiersTlv ipv4LspIdenTlv = null; | ||
1273 | + SymbolicPathNameTlv pathNameTlv = null; | ||
1199 | 1274 | ||
1200 | while (listTlvIterator.hasNext()) { | 1275 | while (listTlvIterator.hasNext()) { |
1201 | PcepValueType tlv = listTlvIterator.next(); | 1276 | PcepValueType tlv = listTlvIterator.next(); |
1202 | - if (tlv.getType() == StatefulIPv4LspIdentifiersTlv.TYPE) { | 1277 | + switch (tlv.getType()) { |
1203 | - ipv4LspTlv = (StatefulIPv4LspIdentifiersTlv) tlv; | 1278 | + case StatefulIPv4LspIdentifiersTlv.TYPE: |
1279 | + ipv4LspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv; | ||
1280 | + break; | ||
1281 | + | ||
1282 | + case SymbolicPathNameTlv.TYPE: | ||
1283 | + pathNameTlv = (SymbolicPathNameTlv) tlv; | ||
1284 | + break; | ||
1285 | + | ||
1286 | + default: | ||
1204 | break; | 1287 | break; |
1205 | } | 1288 | } |
1206 | } | 1289 | } |
1207 | 1290 | ||
1208 | - checkNotNull(ipv4LspTlv); | 1291 | + /* |
1209 | - | 1292 | + * Draft says: The LSP-IDENTIFIERS TLV MUST be included in the LSP object in PCRpt messages for |
1210 | - IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(ipv4LspTlv | 1293 | + * RSVP-signaled LSPs. For ONOS PCECC implementation, it is mandatory. |
1211 | - .getIpv4IngressAddress())); | 1294 | + */ |
1212 | - IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(ipv4LspTlv | 1295 | + if (ipv4LspIdenTlv == null) { |
1213 | - .getIpv4EgressAddress())); | 1296 | + log.error("Stateful IPv4 identifier TLV is null in PCRpt msg."); |
1297 | + return; | ||
1298 | + } | ||
1214 | 1299 | ||
1300 | + IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint | ||
1301 | + .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4IngressAddress())); | ||
1302 | + IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint | ||
1303 | + .ipTunnelPoint(IpAddress.valueOf(ipv4LspIdenTlv.getIpv4EgressAddress())); | ||
1215 | Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst); | 1304 | Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst); |
1216 | 1305 | ||
1217 | Tunnel tunnel = null; | 1306 | Tunnel tunnel = null; |
1218 | // Asynchronous status change message from PCC for LSP reported earlier. | 1307 | // Asynchronous status change message from PCC for LSP reported earlier. |
1219 | for (Tunnel tunnelObj : tunnelQueryResult) { | 1308 | for (Tunnel tunnelObj : tunnelQueryResult) { |
1220 | - if ((tunnelObj.annotations().value(PLSP_ID) == null) | 1309 | + if (tunnelObj.annotations().value(PLSP_ID) == null) { |
1221 | - || (tunnelObj.annotations().value(LOCAL_LSP_ID) == null)) { | ||
1222 | /* | 1310 | /* |
1223 | - * Can skip this tunnel as this is one for which PCE has | 1311 | + * PLSP_ID is null while Tunnel is created at PCE and PCInit msg carries it as 0. It is allocated by |
1224 | - * sent PCInit/PCUpd msg and waiting for a PCRpt. | 1312 | + * PCC and in that case it becomes the first PCRpt msg from PCC for this LSP, and hence symbolic |
1313 | + * path name must be carried in the PCRpt msg. Draft says: The SYMBOLIC-PATH-NAME TLV "MUST" be | ||
1314 | + * included in the LSP object in the LSP State Report (PCRpt) message when during a given PCEP | ||
1315 | + * session an LSP is "first" reported to a PCE. | ||
1225 | */ | 1316 | */ |
1317 | + if ((pathNameTlv != null) | ||
1318 | + && Arrays.equals(tunnelObj.tunnelName().value().getBytes(), pathNameTlv.getValue())) { | ||
1319 | + tunnel = tunnelObj; | ||
1320 | + break; | ||
1321 | + } | ||
1226 | continue; | 1322 | continue; |
1227 | } | 1323 | } |
1228 | 1324 | ||
1229 | - if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId()) | 1325 | + if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId()) && (Integer |
1230 | - && (Integer.valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) | 1326 | + .valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) == ipv4LspIdenTlv.getLspId())) { |
1231 | - == ipv4LspTlv.getLspId())) { | ||
1232 | tunnel = tunnelObj; | 1327 | tunnel = tunnelObj; |
1233 | break; | 1328 | break; |
1234 | } | 1329 | } |
1235 | } | 1330 | } |
1236 | 1331 | ||
1237 | - // Status report for a new LSP when LSPDB sync was already completed sometime. | 1332 | + DefaultTunnelDescription td; |
1238 | - // No need to add the tunnel if msg is for remove but store doesn't have an entry. | 1333 | + State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); |
1239 | if (tunnel == null) { | 1334 | if (tunnel == null) { |
1240 | - if (!lspObj.getRFlag()) { | 1335 | + if (lspObj.getRFlag()) { |
1241 | - handleSyncReport(stateRpt); | 1336 | + /* |
1337 | + * If PCC sends remove message and for any reason PCE does not have that entry, simply discard the | ||
1338 | + * message. Or if PCRpt for initiated LSP received and PCE doesn't know, then too discard. | ||
1339 | + */ | ||
1340 | + return; | ||
1242 | } | 1341 | } |
1243 | - return; | ||
1244 | - } | ||
1245 | - | ||
1246 | - DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), | ||
1247 | - tunnel.dst(), tunnel.type(), tunnel.groupId(), | ||
1248 | - providerId, tunnel.tunnelName(), tunnel.path(), | ||
1249 | - (SparseAnnotations) tunnel.annotations()); | ||
1250 | 1342 | ||
1251 | - if (lspObj.getRFlag()) { | 1343 | + if (lspObj.getCFlag()) { |
1252 | - tunnelRemoved(td); // This will happen only for PCC initiated tunnels. | 1344 | + /* |
1253 | - } else { | 1345 | + * While in sync, if PCRpt is received for PCE init LSP and PCE doesn't have entry, mark to send |
1254 | - State tunnelState = PcepLspStatus | 1346 | + * delete message on end of sync. |
1255 | - .getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); | 1347 | + */ |
1256 | - tunnelUpdated(td, tunnelState); | 1348 | + SparseAnnotations annotations = DefaultAnnotations.builder() |
1257 | - } | 1349 | + .set(BANDWIDTH, (new Integer(bandwidth)).toString()) |
1258 | - } | 1350 | + .set(LSP_SIG_TYPE, lspType.name()) |
1351 | + .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) | ||
1352 | + .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) | ||
1353 | + .set(LOCAL_LSP_ID, String.valueOf(ipv4LspIdenTlv.getLspId())).build(); | ||
1354 | + | ||
1355 | + // Gnenerate tunnel id for the temporary tunnel. | ||
1356 | + String onosTunnelId = "PCC" + String.valueOf(ipv4LspIdenTlv.getTunnelId()); | ||
1357 | + Tunnel tunnelToBeDeleted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS, | ||
1358 | + new DefaultGroupId(0), TunnelId.valueOf(onosTunnelId), | ||
1359 | + TunnelName.tunnelName(String | ||
1360 | + .valueOf(pathNameTlv.getValue())), | ||
1361 | + path, annotations); | ||
1259 | 1362 | ||
1260 | - /** | 1363 | + /* |
1261 | - * Handles sync report received from pcc. | 1364 | + * Need to send PCInitiate delete msg for a tunnel which does not exist at PCE. For that some dummy |
1262 | - * | 1365 | + * data-structures need to be populated. |
1263 | - * @param stateRpt pcep state report | 1366 | + */ |
1264 | - */ | 1367 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelToBeDeleted, path, RequestType.DELETE); |
1265 | - private void handleSyncReport(PcepStateReport stateRpt) { | 1368 | + pcepTunnelData.setPlspId(lspObj.getPlspId()); |
1266 | - PcepLspObject lspObj = stateRpt.getLspObject(); | 1369 | + pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv); |
1267 | - PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath(); | 1370 | + pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
1268 | - checkNotNull(msgPath); | 1371 | + pcepTunnelApiMapper.handleCreateTunnelRequestQueue(0, pcepTunnelData); |
1269 | - PcepEroObject eroObj = msgPath.getEroObject(); | ||
1270 | - if (eroObj == null) { | ||
1271 | - log.debug("ERO object is null in sate report"); | ||
1272 | - return; | ||
1273 | - } | ||
1274 | - int bandwidth = 0; | ||
1275 | 1372 | ||
1276 | - log.debug("Handle Sync report received from PCC."); | 1373 | + /* |
1374 | + * Add to the list of tunnels for which PCInit delete will be sent at the end of sync. | ||
1375 | + */ | ||
1376 | + List<Tunnel> tunnelToBeDeletedList = syncCompleteDeleteList.get(pccId.ipAddress()); | ||
1377 | + tunnelToBeDeletedList.add(tunnelToBeDeleted); | ||
1378 | + syncCompleteDeleteList.put(pccId.ipAddress(), tunnelToBeDeletedList); | ||
1379 | + return; | ||
1380 | + } | ||
1277 | 1381 | ||
1278 | - if (0 == lspObj.getOFlag()) { | 1382 | + SparseAnnotations annotations = DefaultAnnotations.builder() |
1279 | - log.warn("The PCC reported tunnel is in down state"); | 1383 | + .set(BANDWIDTH, (new Integer(bandwidth)).toString()) |
1384 | + .set(LSP_SIG_TYPE, lspType.name()) | ||
1385 | + .set(PCC_TUNNEL_ID, String.valueOf(ipv4LspIdenTlv.getTunnelId())) | ||
1386 | + .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) | ||
1387 | + .set(LOCAL_LSP_ID, String.valueOf(ipv4LspIdenTlv.getLspId())).build(); | ||
1388 | + | ||
1389 | + td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, | ||
1390 | + new DefaultGroupId(0), providerId, | ||
1391 | + TunnelName.tunnelName(String.valueOf(pathNameTlv.getValue())), path, | ||
1392 | + annotations); | ||
1393 | + | ||
1394 | + TunnelId tId = tunnelAdded(td, tunnelState); | ||
1395 | + Tunnel tunnelInserted = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS, | ||
1396 | + tunnelState, new DefaultGroupId(0), tId, | ||
1397 | + TunnelName.tunnelName(String.valueOf(pathNameTlv.getValue())), | ||
1398 | + path, annotations); | ||
1399 | + | ||
1400 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnelInserted, path, LSP_STATE_RPT); | ||
1401 | + pcepTunnelData.setStatefulIpv4IndentifierTlv(ipv4LspIdenTlv); | ||
1402 | + pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | ||
1403 | + return; | ||
1280 | } | 1404 | } |
1281 | - log.debug("Sync report received"); | ||
1282 | 1405 | ||
1283 | - if (msgPath.getBandwidthObject() != null) { | 1406 | + if ((syncStatus == IN_SYNC) && (lspObj.getCFlag()) && (tunnelState != tunnel.state())) { |
1284 | - bandwidth = msgPath.getBandwidthObject().getBandwidth(); | 1407 | + // Mark to send PCUpd msg with state known at PCE. |
1408 | + List<Tunnel> tunnelToBeUpdateList = syncCompleteUpdateList.get(pccId.ipAddress()); | ||
1409 | + tunnelToBeUpdateList.add(tunnel); | ||
1410 | + syncCompleteUpdateList.put(pccId.ipAddress(), tunnelToBeUpdateList); | ||
1411 | + return; | ||
1285 | } | 1412 | } |
1286 | 1413 | ||
1287 | - // To carry PST TLV, SRP object can be present with value 0 even | 1414 | + td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), tunnel.dst(), |
1288 | - // when PCRpt is | 1415 | + tunnel.type(), tunnel.groupId(), providerId, |
1289 | - // not in response to any action from PCE. | 1416 | + tunnel.tunnelName(), tunnel.path(), |
1290 | - PcepSrpObject srpObj = stateRpt.getSrpObject(); | 1417 | + (SparseAnnotations) tunnel.annotations()); |
1291 | - LspType lspType = WITH_SIGNALLING; | ||
1292 | - | ||
1293 | - if (null != srpObj) { | ||
1294 | - LinkedList<PcepValueType> llOptionalTlv = srpObj.getOptionalTlv(); | ||
1295 | - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); | ||
1296 | - | ||
1297 | - while (listIterator.hasNext()) { | ||
1298 | - PcepValueType tlv = listIterator.next(); | ||
1299 | - | ||
1300 | - switch (tlv.getType()) { | ||
1301 | - case PathSetupTypeTlv.TYPE: | ||
1302 | - lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())]; | ||
1303 | - break; | ||
1304 | 1418 | ||
1305 | - default: | 1419 | + if (lspObj.getRFlag()) { |
1306 | - break; | 1420 | + tunnelRemoved(td); |
1307 | - } | 1421 | + } else { |
1422 | + if (syncStatus == IN_SYNC) { | ||
1423 | + markLspDbEntryAsLatest(pccId, tunnel.tunnelId()); | ||
1308 | } | 1424 | } |
1425 | + tunnelUpdated(td, tunnelState); | ||
1309 | } | 1426 | } |
1310 | - | 1427 | + return; |
1311 | - buildAndStorePcepTunnelData(lspObj, eroObj, bandwidth, lspType); | ||
1312 | } | 1428 | } |
1313 | 1429 | ||
1314 | /** | 1430 | /** |
... | @@ -1323,7 +1439,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1323,7 +1439,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1323 | List<Link> links = new ArrayList<Link>(); | 1439 | List<Link> links = new ArrayList<Link>(); |
1324 | LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); | 1440 | LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); |
1325 | if (0 == llSubObj.size()) { | 1441 | if (0 == llSubObj.size()) { |
1326 | - log.error("RRO in report message does not have hop information"); | 1442 | + log.error("ERO in report message does not have hop information"); |
1327 | } | 1443 | } |
1328 | ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); | 1444 | ListIterator<PcepValueType> tlvIterator = llSubObj.listIterator(); |
1329 | 1445 | ||
... | @@ -1361,71 +1477,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1361,71 +1477,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1361 | return new DefaultPath(providerId, links, 0, EMPTY); | 1477 | return new DefaultPath(providerId, links, 0, EMPTY); |
1362 | } | 1478 | } |
1363 | 1479 | ||
1364 | - /** | ||
1365 | - * To build pcepTunnelData and informs core about the PCC reported | ||
1366 | - * tunnel. | ||
1367 | - * | ||
1368 | - * @param lspObj PCEP LSP object | ||
1369 | - * @param eroObj PCEP ERO object | ||
1370 | - * @param bandwidth bandwidth of tunnel | ||
1371 | - * @param lspType path setup type/signaling type of the LSP. | ||
1372 | - */ | ||
1373 | - private void buildAndStorePcepTunnelData(PcepLspObject lspObj, PcepEroObject eroObj, int bandwidth, | ||
1374 | - LspType lspType) { | ||
1375 | - | ||
1376 | - ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); | ||
1377 | - | ||
1378 | - // StatefulIPv4LspIdentidiersTlv in LSP object will have the source and destination address. | ||
1379 | - StatefulIPv4LspIdentifiersTlv lspIdenTlv = null; | ||
1380 | - SymbolicPathNameTlv pathNameTlv = null; | ||
1381 | - LinkedList<PcepValueType> llOptionalTlv = lspObj.getOptionalTlv(); | ||
1382 | - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); | ||
1383 | - while (listIterator.hasNext()) { | ||
1384 | - PcepValueType tlv = listIterator.next(); | ||
1385 | - switch (tlv.getType()) { | ||
1386 | - case StatefulIPv4LspIdentifiersTlv.TYPE: | ||
1387 | - lspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv; | ||
1388 | - break; | ||
1389 | - case SymbolicPathNameTlv.TYPE: | ||
1390 | - pathNameTlv = (SymbolicPathNameTlv) tlv; | ||
1391 | - break; | ||
1392 | - default: | ||
1393 | - // currently this tlv is not required | ||
1394 | - } | ||
1395 | - } | ||
1396 | - | ||
1397 | - IpTunnelEndPoint tunnelEndPointSrc; | ||
1398 | - tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(lspIdenTlv.getIpv4IngressAddress())); | ||
1399 | - IpTunnelEndPoint tunnelEndPointDst; | ||
1400 | - tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(lspIdenTlv.getIpv4EgressAddress())); | ||
1401 | - | ||
1402 | - Path path = buildPathFromEroObj(eroObj, providerId); | ||
1403 | - | ||
1404 | - SparseAnnotations annotations = DefaultAnnotations.builder() | ||
1405 | - .set(BANDWIDTH, (new Integer(bandwidth)).toString()) | ||
1406 | - .set(LSP_SIG_TYPE, lspType.name()) | ||
1407 | - .set(PCC_TUNNEL_ID, String.valueOf(lspIdenTlv.getTunnelId())) | ||
1408 | - .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) | ||
1409 | - .set(LOCAL_LSP_ID, String.valueOf(lspIdenTlv.getLspId())).build(); | ||
1410 | - | ||
1411 | - DefaultTunnelDescription td = new DefaultTunnelDescription(null, tunnelEndPointSrc, | ||
1412 | - tunnelEndPointDst, MPLS, | ||
1413 | - new DefaultGroupId(0), providerId, | ||
1414 | - TunnelName.tunnelName(pathNameTlv.toString()), | ||
1415 | - path, annotations); | ||
1416 | - State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); | ||
1417 | - TunnelId tId = tunnelAdded(td, tunnelState); | ||
1418 | - | ||
1419 | - Tunnel tunnel = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS, | ||
1420 | - new DefaultGroupId(0), tId, | ||
1421 | - TunnelName.tunnelName(pathNameTlv.toString()), path, annotations); | ||
1422 | - | ||
1423 | - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, LSP_STATE_RPT); | ||
1424 | - pcepTunnelData.setStatefulIpv4IndentifierTlv(lspIdenTlv); | ||
1425 | - pcepTunnelApiMapper.addPccTunnelDB(pcepTunnelData); | ||
1426 | - pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | ||
1427 | - } | ||
1428 | - | ||
1429 | @Override | 1480 | @Override |
1430 | public void clientConnected(PccId pccId) { | 1481 | public void clientConnected(PccId pccId) { |
1431 | // TODO | 1482 | // TODO |
... | @@ -1448,4 +1499,83 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1448,4 +1499,83 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1448 | public Tunnel tunnelQueryById(TunnelId tunnelId) { | 1499 | public Tunnel tunnelQueryById(TunnelId tunnelId) { |
1449 | return service.tunnelQueryById(tunnelId); | 1500 | return service.tunnelQueryById(tunnelId); |
1450 | } | 1501 | } |
1502 | + | ||
1503 | + /** | ||
1504 | + * Removes the entry from temporary copy of LSPDB, signifying its status as upto date. | ||
1505 | + * | ||
1506 | + * @param pccId the key for temporary LSPDB | ||
1507 | + * @param tunnelId the tunnel id for which information is updated. | ||
1508 | + */ | ||
1509 | + private void markLspDbEntryAsLatest(PccId pccId, TunnelId tunnelId) { | ||
1510 | + checkNotNull(pccId); | ||
1511 | + checkNotNull(tunnelId); | ||
1512 | + | ||
1513 | + Map<TunnelId, Tunnel> preSyncLspDb = preSyncLspDbMap.get(pccId.ipAddress()); | ||
1514 | + checkNotNull(preSyncLspDb); | ||
1515 | + | ||
1516 | + preSyncLspDb.remove(tunnelId); | ||
1517 | + preSyncLspDbMap.put(pccId.ipAddress(), preSyncLspDb); | ||
1518 | + } | ||
1519 | + | ||
1520 | + /** | ||
1521 | + * Sends PCInit, PCInit(R) or PCUpd messages for initiated LSPs at the end | ||
1522 | + * of LSP DB sync based on actions decided while sync was in progress. Also | ||
1523 | + * triggers label DB sync. | ||
1524 | + * | ||
1525 | + * @param pccId the key for temporary DBs storing required end of sync | ||
1526 | + * actions. | ||
1527 | + */ | ||
1528 | + private void handleEndOfSyncAction(PccId pccId) { | ||
1529 | + | ||
1530 | + Map<TunnelId, Tunnel> preSyncLspDb = preSyncLspDbMap.get(pccId.ipAddress()); | ||
1531 | + checkNotNull(preSyncLspDb); | ||
1532 | + | ||
1533 | + for (Tunnel tunnel : preSyncLspDb.values()) { | ||
1534 | + | ||
1535 | + TunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), | ||
1536 | + tunnel.src(), tunnel.dst(), | ||
1537 | + tunnel.type(), | ||
1538 | + tunnel.groupId(), | ||
1539 | + tunnel.providerId(), | ||
1540 | + tunnel.tunnelName(), | ||
1541 | + tunnel.path(), | ||
1542 | + (SparseAnnotations) tunnel.annotations()); | ||
1543 | + | ||
1544 | + if ((tunnel.annotations().value(PCE_INIT) == null) | ||
1545 | + || (tunnel.annotations().value(PCE_INIT).equals("false"))) { | ||
1546 | + | ||
1547 | + tunnelRemoved(td); | ||
1548 | + } else { | ||
1549 | + // Send PCInit msg again after global reoptimization. | ||
1550 | + tunnelUpdated(td, UNSTABLE); | ||
1551 | + | ||
1552 | + // To remove the old tunnel from store whose PLSPID is not | ||
1553 | + // recognized by ingress PCC. | ||
1554 | + tunnelRemoved(td); | ||
1555 | + } | ||
1556 | + } | ||
1557 | + | ||
1558 | + List<Tunnel> tunnelsToBeDeletedList = syncCompleteDeleteList.get(pccId.ipAddress()); | ||
1559 | + checkNotNull(tunnelsToBeDeletedList); | ||
1560 | + for (Tunnel tunnel: tunnelsToBeDeletedList) { | ||
1561 | + releaseTunnel(tunnel); | ||
1562 | + } | ||
1563 | + | ||
1564 | + List<Tunnel> tunnelsToBeUpdatedList = syncCompleteUpdateList.get(pccId.ipAddress()); | ||
1565 | + checkNotNull(tunnelsToBeUpdatedList); | ||
1566 | + for (Tunnel tunnel: tunnelsToBeUpdatedList) { | ||
1567 | + updateTunnel(tunnel, tunnel.path()); | ||
1568 | + } | ||
1569 | + | ||
1570 | + /* On end of sync, empty all temporary data structures. */ | ||
1571 | + preSyncLspDbMap.remove(pccId.ipAddress()); | ||
1572 | + syncCompleteDeleteList.remove(pccId.ipAddress()); | ||
1573 | + syncCompleteUpdateList.remove(pccId.ipAddress()); | ||
1574 | + | ||
1575 | + // TODO: If SR capable, send a notification to | ||
1576 | + // PCE APP to start label DB sync. | ||
1577 | + if (true) { | ||
1578 | + pcepClientController.getClient(pccId).setLabelDbSyncStatus(IN_SYNC); | ||
1579 | + } | ||
1580 | + } | ||
1451 | } | 1581 | } | ... | ... |
providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java
... | @@ -24,6 +24,7 @@ import org.jboss.netty.channel.Channel; | ... | @@ -24,6 +24,7 @@ import org.jboss.netty.channel.Channel; |
24 | import org.onosproject.pcep.controller.ClientCapability; | 24 | import org.onosproject.pcep.controller.ClientCapability; |
25 | import org.onosproject.pcep.controller.PccId; | 25 | import org.onosproject.pcep.controller.PccId; |
26 | import org.onosproject.pcep.controller.PcepClient; | 26 | import org.onosproject.pcep.controller.PcepClient; |
27 | +import org.onosproject.pcep.controller.PcepSyncStatus; | ||
27 | import org.onosproject.pcepio.protocol.PcepFactories; | 28 | import org.onosproject.pcepio.protocol.PcepFactories; |
28 | import org.onosproject.pcepio.protocol.PcepFactory; | 29 | import org.onosproject.pcepio.protocol.PcepFactory; |
29 | import org.onosproject.pcepio.protocol.PcepMessage; | 30 | import org.onosproject.pcepio.protocol.PcepMessage; |
... | @@ -42,7 +43,8 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -42,7 +43,8 @@ public class PcepClientAdapter implements PcepClient { |
42 | private ClientCapability capability; | 43 | private ClientCapability capability; |
43 | 44 | ||
44 | private PcepVersion pcepVersion; | 45 | private PcepVersion pcepVersion; |
45 | - private boolean syncCompleted; | 46 | + private PcepSyncStatus lspDbSyncStatus; |
47 | + private PcepSyncStatus labelDbSyncStatus; | ||
46 | 48 | ||
47 | /** | 49 | /** |
48 | * Initialize instance with specified parameters. | 50 | * Initialize instance with specified parameters. |
... | @@ -109,13 +111,23 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -109,13 +111,23 @@ public class PcepClientAdapter implements PcepClient { |
109 | } | 111 | } |
110 | 112 | ||
111 | @Override | 113 | @Override |
112 | - public final boolean isSyncComplete() { | 114 | + public void setLspDbSyncStatus(PcepSyncStatus syncStatus) { |
113 | - return syncCompleted; | 115 | + this.lspDbSyncStatus = syncStatus; |
114 | } | 116 | } |
115 | 117 | ||
116 | @Override | 118 | @Override |
117 | - public final void setIsSyncComplete(boolean value) { | 119 | + public PcepSyncStatus lspDbSyncStatus() { |
118 | - syncCompleted = value; | 120 | + return lspDbSyncStatus; |
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { | ||
125 | + this.labelDbSyncStatus = syncStatus; | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public PcepSyncStatus labelDbSyncStatus() { | ||
130 | + return labelDbSyncStatus; | ||
119 | } | 131 | } |
120 | 132 | ||
121 | @Override | 133 | @Override | ... | ... |
... | @@ -25,6 +25,8 @@ import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_S | ... | @@ -25,6 +25,8 @@ import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_S |
25 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID; | 25 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID; |
26 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID; | 26 | import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID; |
27 | import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 27 | import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
28 | +import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; | ||
29 | +import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC; | ||
28 | 30 | ||
29 | import java.io.IOException; | 31 | import java.io.IOException; |
30 | import java.util.Collection; | 32 | import java.util.Collection; |
... | @@ -260,7 +262,7 @@ public class PcepTunnelAddedTest { | ... | @@ -260,7 +262,7 @@ public class PcepTunnelAddedTest { |
260 | 262 | ||
261 | PccId pccId = PccId.pccId(IpAddress.valueOf(0x4e1f0400)); | 263 | PccId pccId = PccId.pccId(IpAddress.valueOf(0x4e1f0400)); |
262 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); | 264 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); |
263 | - controller.getClient(pccId).setIsSyncComplete(true); | 265 | + controller.getClient(pccId).setLspDbSyncStatus(SYNCED); |
264 | 266 | ||
265 | // Process update message. | 267 | // Process update message. |
266 | controller.processClientMessage(pccId, message); | 268 | controller.processClientMessage(pccId, message); |
... | @@ -307,13 +309,291 @@ public class PcepTunnelAddedTest { | ... | @@ -307,13 +309,291 @@ public class PcepTunnelAddedTest { |
307 | PcepMessage message = reader.readFrom(buffer); | 309 | PcepMessage message = reader.readFrom(buffer); |
308 | 310 | ||
309 | PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); | 311 | PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); |
310 | - controller.getClient(pccId).setIsSyncComplete(true); | 312 | + controller.getClient(pccId).setLspDbSyncStatus(SYNCED); |
311 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); | 313 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); |
312 | controller.processClientMessage(pccId, message); | 314 | controller.processClientMessage(pccId, message); |
313 | 315 | ||
314 | assertThat(registry.tunnelIdCounter, is((long) 1)); | 316 | assertThat(registry.tunnelIdCounter, is((long) 1)); |
315 | } | 317 | } |
316 | 318 | ||
319 | + /** | ||
320 | + * Tests LSPDB sync where PCC reports less LSPs than known by PCE and PCE deletes at the end of DB sync. | ||
321 | + */ | ||
322 | + @Test | ||
323 | + public void testCaseLspDbSync1() throws PcepParseException, PcepOutOfBoundMessageException { | ||
324 | + /* Step 1 create 2 LSPs */ | ||
325 | + byte[] reportMsg1 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
326 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
327 | + 0x00, 0x00, 0x00, 0x00, | ||
328 | + 0x00, 0x00, 0x00, 0x00, | ||
329 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
330 | + 0x00, 0x00, 0x00, 0x00, | ||
331 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object | ||
332 | + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV | ||
333 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
334 | + 0x01, 0x01, 0x01, 0x01, | ||
335 | + 0x00, 0x01, 0x00, 0x01, | ||
336 | + 0x01, 0x01, 0x01, 0x01, | ||
337 | + 0x05, 0x05, 0x05, 0x05, | ||
338 | + | ||
339 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
340 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
341 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
342 | + | ||
343 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
344 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
345 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
346 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
347 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
348 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
349 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
350 | + }; | ||
351 | + | ||
352 | + ChannelBuffer buffer1 = ChannelBuffers.dynamicBuffer(); | ||
353 | + buffer1.writeBytes(reportMsg1); | ||
354 | + | ||
355 | + PcepMessageReader<PcepMessage> reader1 = PcepFactories.getGenericReader(); | ||
356 | + PcepMessage message1 = reader1.readFrom(buffer1); | ||
357 | + | ||
358 | + PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); | ||
359 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); | ||
360 | + controller.processClientMessage(pccId, message1); | ||
361 | + | ||
362 | + /* create 2nd LSP */ | ||
363 | + byte[] reportMsg2 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
364 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
365 | + 0x00, 0x00, 0x00, 0x00, | ||
366 | + 0x00, 0x00, 0x00, 0x00, | ||
367 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
368 | + 0x00, 0x00, 0x00, 0x00, | ||
369 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x19, // LSP object | ||
370 | + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV | ||
371 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
372 | + 0x01, 0x01, 0x01, 0x01, | ||
373 | + 0x00, 0x02, 0x00, 0x02, | ||
374 | + 0x01, 0x01, 0x01, 0x01, | ||
375 | + 0x05, 0x05, 0x05, 0x05, | ||
376 | + | ||
377 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
378 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
379 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
380 | + | ||
381 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
382 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
383 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
384 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
385 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
386 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
387 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
388 | + }; | ||
389 | + | ||
390 | + ChannelBuffer buffer2 = ChannelBuffers.dynamicBuffer(); | ||
391 | + buffer2.writeBytes(reportMsg2); | ||
392 | + | ||
393 | + PcepMessageReader<PcepMessage> reader2 = PcepFactories.getGenericReader(); | ||
394 | + PcepMessage message2 = reader2.readFrom(buffer2); | ||
395 | + | ||
396 | + controller.processClientMessage(pccId, message2); | ||
397 | + | ||
398 | + /* Assert number of LSPs in DB to be 2. */ | ||
399 | + assertThat(registry.tunnelIdCounter, is((long) 2)); | ||
400 | + | ||
401 | + /* Step 2 send sync begin message and LSP 1. */ | ||
402 | + byte[] reportMsg3 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
403 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
404 | + 0x00, 0x00, 0x00, 0x00, | ||
405 | + 0x00, 0x00, 0x00, 0x00, | ||
406 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
407 | + 0x00, 0x00, 0x00, 0x00, | ||
408 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x1B, // LSP object | ||
409 | + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV | ||
410 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
411 | + 0x01, 0x01, 0x01, 0x01, | ||
412 | + 0x00, 0x01, 0x00, 0x01, | ||
413 | + 0x01, 0x01, 0x01, 0x01, | ||
414 | + 0x05, 0x05, 0x05, 0x05, | ||
415 | + | ||
416 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
417 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
418 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
419 | + | ||
420 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
421 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
422 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
423 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
424 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
425 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
426 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
427 | + }; | ||
428 | + | ||
429 | + ChannelBuffer buffer3 = ChannelBuffers.dynamicBuffer(); | ||
430 | + buffer3.writeBytes(reportMsg3); | ||
431 | + PcepMessageReader<PcepMessage> reader3 = PcepFactories.getGenericReader(); | ||
432 | + PcepMessage message3 = reader3.readFrom(buffer3); | ||
433 | + controller.processClientMessage(pccId, message3); | ||
434 | + | ||
435 | + assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(IN_SYNC)); | ||
436 | + | ||
437 | + /* Step 3 send end of sync marker */ | ||
438 | + byte[] reportMsg4 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x24, | ||
439 | + 0x20, 0x10, 0x00, 0x1C, // LSP object | ||
440 | + 0x00, 0x00, 0x10, 0x19, | ||
441 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
442 | + 0x00, 0x00, 0x00, 0x00, | ||
443 | + 0x00, 0x00, 0x00, 0x00, | ||
444 | + 0x00, 0x00, 0x00, 0x00, | ||
445 | + 0x00, 0x00, 0x00, 0x00, | ||
446 | + 0x07, 0x10, 0x00, 0x04, //ERO object | ||
447 | + }; | ||
448 | + | ||
449 | + ChannelBuffer buffer4 = ChannelBuffers.dynamicBuffer(); | ||
450 | + buffer4.writeBytes(reportMsg4); | ||
451 | + PcepMessageReader<PcepMessage> reader4 = PcepFactories.getGenericReader(); | ||
452 | + PcepMessage message4 = reader4.readFrom(buffer4); | ||
453 | + controller.processClientMessage(pccId, message4); | ||
454 | + | ||
455 | + assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(SYNCED)); | ||
456 | + } | ||
457 | + | ||
458 | + /** | ||
459 | + * Tests PCC PCRpt PCE initiated LSP which PCE doesn't know and hence should send PCInit delete msg. | ||
460 | + */ | ||
461 | + @Test | ||
462 | + public void testCaseLspDbSync2() throws PcepParseException, PcepOutOfBoundMessageException { | ||
463 | + /* Step 1 create 2 LSPs */ | ||
464 | + byte[] reportMsg1 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
465 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
466 | + 0x00, 0x00, 0x00, 0x00, | ||
467 | + 0x00, 0x00, 0x00, 0x00, | ||
468 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
469 | + 0x00, 0x00, 0x00, 0x00, | ||
470 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object | ||
471 | + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV | ||
472 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
473 | + 0x01, 0x01, 0x01, 0x01, | ||
474 | + 0x00, 0x01, 0x00, 0x01, | ||
475 | + 0x01, 0x01, 0x01, 0x01, | ||
476 | + 0x05, 0x05, 0x05, 0x05, | ||
477 | + | ||
478 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
479 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
480 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
481 | + | ||
482 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
483 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
484 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
485 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
486 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
487 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
488 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
489 | + }; | ||
490 | + | ||
491 | + ChannelBuffer buffer1 = ChannelBuffers.dynamicBuffer(); | ||
492 | + buffer1.writeBytes(reportMsg1); | ||
493 | + | ||
494 | + PcepMessageReader<PcepMessage> reader1 = PcepFactories.getGenericReader(); | ||
495 | + PcepMessage message1 = reader1.readFrom(buffer1); | ||
496 | + | ||
497 | + PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); | ||
498 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); | ||
499 | + controller.processClientMessage(pccId, message1); | ||
500 | + | ||
501 | + /* create 2nd LSP */ | ||
502 | + byte[] reportMsg2 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
503 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
504 | + 0x00, 0x00, 0x00, 0x00, | ||
505 | + 0x00, 0x00, 0x00, 0x00, | ||
506 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
507 | + 0x00, 0x00, 0x00, 0x00, | ||
508 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x19, // LSP object | ||
509 | + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV | ||
510 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
511 | + 0x01, 0x01, 0x01, 0x01, | ||
512 | + 0x00, 0x02, 0x00, 0x02, | ||
513 | + 0x01, 0x01, 0x01, 0x01, | ||
514 | + 0x05, 0x05, 0x05, 0x05, | ||
515 | + | ||
516 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
517 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
518 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
519 | + | ||
520 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
521 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
522 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
523 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
524 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
525 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
526 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
527 | + }; | ||
528 | + | ||
529 | + ChannelBuffer buffer2 = ChannelBuffers.dynamicBuffer(); | ||
530 | + buffer2.writeBytes(reportMsg2); | ||
531 | + | ||
532 | + PcepMessageReader<PcepMessage> reader2 = PcepFactories.getGenericReader(); | ||
533 | + PcepMessage message2 = reader2.readFrom(buffer2); | ||
534 | + | ||
535 | + controller.processClientMessage(pccId, message2); | ||
536 | + | ||
537 | + /* Assert number of LSPs in DB to be 2. */ | ||
538 | + assertThat(registry.tunnelIdCounter, is((long) 2)); | ||
539 | + | ||
540 | + /* Step 2 send sync begin message and LSP 1. */ | ||
541 | + byte[] reportMsg3 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
542 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
543 | + 0x00, 0x00, 0x00, 0x00, | ||
544 | + 0x00, 0x00, 0x00, 0x00, | ||
545 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
546 | + 0x00, 0x00, 0x00, 0x00, | ||
547 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, (byte) 0x9B, // LSP object | ||
548 | + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV | ||
549 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
550 | + 0x01, 0x01, 0x01, 0x01, | ||
551 | + 0x00, 0x01, 0x00, 0x03, | ||
552 | + 0x01, 0x01, 0x01, 0x01, | ||
553 | + 0x05, 0x05, 0x05, 0x05, | ||
554 | + | ||
555 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
556 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
557 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
558 | + | ||
559 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
560 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
561 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
562 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
563 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
564 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
565 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
566 | + }; | ||
567 | + | ||
568 | + ChannelBuffer buffer3 = ChannelBuffers.dynamicBuffer(); | ||
569 | + buffer3.writeBytes(reportMsg3); | ||
570 | + PcepMessageReader<PcepMessage> reader3 = PcepFactories.getGenericReader(); | ||
571 | + PcepMessage message3 = reader3.readFrom(buffer3); | ||
572 | + controller.processClientMessage(pccId, message3); | ||
573 | + | ||
574 | + assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(IN_SYNC)); | ||
575 | + | ||
576 | + /* Step 3 send end of sync marker */ | ||
577 | + byte[] reportMsg4 = new byte[] {0x20, 0x0a, 0x00, (byte) 0x24, | ||
578 | + 0x20, 0x10, 0x00, 0x1C, // LSP object | ||
579 | + 0x00, 0x00, 0x10, 0x19, | ||
580 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
581 | + 0x00, 0x00, 0x00, 0x00, | ||
582 | + 0x00, 0x00, 0x00, 0x00, | ||
583 | + 0x00, 0x00, 0x00, 0x00, | ||
584 | + 0x00, 0x00, 0x00, 0x00, | ||
585 | + 0x07, 0x10, 0x00, 0x04, //ERO object | ||
586 | + }; | ||
587 | + | ||
588 | + ChannelBuffer buffer4 = ChannelBuffers.dynamicBuffer(); | ||
589 | + buffer4.writeBytes(reportMsg4); | ||
590 | + PcepMessageReader<PcepMessage> reader4 = PcepFactories.getGenericReader(); | ||
591 | + PcepMessage message4 = reader4.readFrom(buffer4); | ||
592 | + controller.processClientMessage(pccId, message4); | ||
593 | + | ||
594 | + assertThat(controller.getClient(pccId).lspDbSyncStatus(), is(SYNCED)); | ||
595 | + } | ||
596 | + | ||
317 | @After | 597 | @After |
318 | public void tearDown() throws IOException { | 598 | public void tearDown() throws IOException { |
319 | tunnelProvider.deactivate(); | 599 | tunnelProvider.deactivate(); | ... | ... |
-
Please register or login to post a comment