Avantika-Huawei

[ONOS-4687] GoldenEye - Label map download issues.

Change-Id: I5b56ccc6b8bad3c585f4d33ddd6d9094751c8797
Showing 15 changed files with 99 additions and 86 deletions
......@@ -893,9 +893,7 @@ public class PceManager implements PceService {
// Check whether device has SR-TE Capability
if (cfg.labelStackCap()) {
if (!srTeHandler.allocateNodeLabel(deviceId, lsrId)) {
log.error("Node label allocation for a device id {} has failed.", deviceId.toString());
}
srTeHandler.allocateNodeLabel(deviceId, lsrId);
}
}
......@@ -974,10 +972,7 @@ public class PceManager implements PceService {
// Check whether device has SR-TE Capability
if (cfg.labelStackCap()) {
if (!srTeHandler.allocateAdjacencyLabel(link)) {
log.error("Unable to allocate adjacency label for a link {}.", link.toString());
return;
}
srTeHandler.allocateAdjacencyLabel(link);
}
return;
......@@ -1209,16 +1204,13 @@ public class PceManager implements PceService {
if (cfg.labelStackCap()) {
if (mastershipService.getLocalRole(deviceId) == MastershipRole.MASTER) {
// Allocate node-label
if (!srTeHandler.allocateNodeLabel(deviceId, lsrId)) {
log.error("Node label allocation for a device id {} has failed.", deviceId.toString());
}
srTeHandler.allocateNodeLabel(deviceId, lsrId);
// Allocate adjacency label to links which are
// originated from this specific device id
Set<Link> links = linkService.getDeviceEgressLinks(deviceId);
for (Link link : links) {
if (!srTeHandler.allocateAdjacencyLabel(link)) {
log.debug("Unable to allocate adjacency labels for a link {}.", link.toString());
return;
}
}
......@@ -1240,40 +1232,42 @@ public class PceManager implements PceService {
return false;
}
Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
if (pceStore.getGlobalNodeLabel(deviceId) != null) {
Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
// Convert from DeviceId to TunnelEndPoint
Device srcDevice = deviceService.getDevice(entry.getKey());
// Convert from DeviceId to TunnelEndPoint
Device srcDevice = deviceService.getDevice(entry.getKey());
/*
* If there is a slight difference in timing such that if device subsystem has removed the device but PCE
* store still has it, just ignore such devices.
*/
if (srcDevice == null) {
continue;
}
/*
* If there is a slight difference in timing such that if device subsystem has removed the device but
* PCE store still has it, just ignore such devices.
*/
if (srcDevice == null) {
continue;
}
String srcLsrId = srcDevice.annotations().value(LSRID);
if (srcLsrId == null) {
continue;
}
String srcLsrId = srcDevice.annotations().value(LSRID);
if (srcLsrId == null) {
continue;
}
srTeHandler.advertiseNodeLabelRule(deviceId,
entry.getValue(),
IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
}
srTeHandler.advertiseNodeLabelRule(deviceId,
entry.getValue(),
IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
}
Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
if (entry.getKey().src().deviceId().equals(deviceId)) {
srTeHandler.installAdjLabelRule(deviceId,
entry.getValue(),
entry.getKey().src().port(),
entry.getKey().dst().port(),
Objective.Operation.ADD);
Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
if (entry.getKey().src().deviceId().equals(deviceId)) {
srTeHandler.installAdjLabelRule(deviceId,
entry.getValue(),
entry.getKey().src().port(),
entry.getKey().dst().port(),
Objective.Operation.ADD);
}
}
}
......
......@@ -28,7 +28,6 @@ import java.util.Set;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MplsLabel;
import org.onlab.packet.TpPort;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
import org.onosproject.incubator.net.resource.label.LabelResource;
......@@ -184,7 +183,7 @@ public final class PceccSrTeBeHandler {
// Check whether node-label was already configured for this specific device.
if (pceStore.getGlobalNodeLabel(specificDeviceId) != null) {
log.error("Node label was already configured for device {}.", specificDeviceId.toString());
log.debug("Node label was already configured for device {}.", specificDeviceId.toString());
return false;
}
......@@ -228,12 +227,15 @@ public final class PceccSrTeBeHandler {
// Push to device
// Push label information of specificDeviceId to otherDevId in list and vice versa.
advertiseNodeLabelRule(otherDevId, specificLabelId,
IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
advertiseNodeLabelRule(specificDeviceId, otherLabelId,
IpPrefix.valueOf(IpAddress.valueOf(otherLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
if (!otherDevId.equals(specificDeviceId)) {
advertiseNodeLabelRule(otherDevId, specificLabelId,
IpPrefix.valueOf(IpAddress.valueOf(specificLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
advertiseNodeLabelRule(specificDeviceId, otherLabelId,
IpPrefix.valueOf(IpAddress.valueOf(otherLsrId), PREFIX_LENGTH),
Objective.Operation.ADD, false);
}
}
return true;
......@@ -519,8 +521,8 @@ public final class PceccSrTeBeHandler {
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
selectorBuilder.matchTcpSrc(TpPort.tpPort((int) srcPortNum.toLong()));
selectorBuilder.matchTcpDst(TpPort.tpPort((int) dstPortNum.toLong()));
selectorBuilder.matchIPSrc(IpPrefix.valueOf((int) srcPortNum.toLong(), 32));
selectorBuilder.matchIPDst(IpPrefix.valueOf((int) dstPortNum.toLong(), 32));
TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
......
......@@ -219,19 +219,19 @@ public class DistributedPceStore implements PceStore {
@Override
public LabelResourceId getGlobalNodeLabel(DeviceId id) {
checkNotNull(id, DEVICE_ID_NULL);
return globalNodeLabelMap.get(id).value();
return globalNodeLabelMap.get(id) == null ? null : globalNodeLabelMap.get(id).value();
}
@Override
public LabelResourceId getAdjLabel(Link link) {
checkNotNull(link, LINK_NULL);
return adjLabelMap.get(link).value();
return adjLabelMap.get(link) == null ? null : adjLabelMap.get(link).value();
}
@Override
public PceccTunnelInfo getTunnelInfo(TunnelId tunnelId) {
checkNotNull(tunnelId, TUNNEL_ID_NULL);
return tunnelInfoMap.get(tunnelId).value();
return tunnelInfoMap.get(tunnelId) == null ? null : tunnelInfoMap.get(tunnelId).value();
}
@Override
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.pcep.tunnel.impl;
package org.onosproject.pcep.controller;
/**
* Collection of keys for annotation for PCEP tunnels.
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.provider.pcep.tunnel.impl;
package org.onosproject.pcep.controller;
import static org.slf4j.LoggerFactory.getLogger;
......
......@@ -62,6 +62,8 @@ import org.onosproject.pcepio.types.PcepValueType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.onosproject.pcep.controller.PcepSyncStatus.NOT_SYNCED;
/**
* Channel handler deals with the pcc client connection and dispatches
* messages from client to the appropriate locations.
......@@ -233,6 +235,11 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
h.pcepPacketStats);
//Get pc instance and set capabilities
h.pc.setCapability(h.capability);
// Initilialize DB sync status.
h.pc.setLspDbSyncStatus(NOT_SYNCED);
h.pc.setLabelDbSyncStatus(NOT_SYNCED);
// set the status of pcc as connected
h.pc.setConnected(true);
h.pc.setChannel(h.channel);
......@@ -258,6 +265,7 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
log.debug("Keep alive time : " + keepAliveTimer);
//set the state handshake completion.
h.sendKeepAliveMessage();
h.pcepPacketStats.addOutPacket();
h.setHandshakeComplete(true);
......
......@@ -434,10 +434,16 @@ public class PcepClientControllerImpl implements PcepClientController {
}
List<PcepStateReport> syncStateRptList = pc.getSyncMsgList(pccId);
if (syncStateRptList == null) {
// When there are no LSPs to sync, directly end-of-sync PCRpt will come and the
// list will be null.
syncStateRptList = Collections.EMPTY_LIST;
}
Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator();
// For every report, fetch PLSP id, local LSP id and symbolic path name from the message.
while (syncStateRptList.iterator().hasNext()) {
while (stateRptListIterator.hasNext()) {
PcepStateReport stateRpt = stateRptListIterator.next();
Tunnel tunnel = null;
......
......@@ -73,7 +73,7 @@ public class PcepClientImpl implements PcepClientDriver {
private byte sessionId;
private PcepPacketStatsImpl pktStats;
private Map<LspKey, Boolean> lspDelegationInfo;
private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>();
private Map<PccId, List<PcepStateReport>> syncRptCache = new HashMap<>();
@Override
public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) {
......@@ -267,24 +267,24 @@ public class PcepClientImpl implements PcepClientDriver {
@Override
public void initializeSyncMsgList(PccId pccId) {
List<PcepStateReport> rptMsgList = new LinkedList<>();
sycRptCache.put(pccId, rptMsgList);
syncRptCache.put(pccId, rptMsgList);
}
@Override
public List<PcepStateReport> getSyncMsgList(PccId pccId) {
return sycRptCache.get(pccId);
return syncRptCache.get(pccId);
}
@Override
public void removeSyncMsgList(PccId pccId) {
sycRptCache.remove(pccId);
syncRptCache.remove(pccId);
}
@Override
public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
List<PcepStateReport> rptMsgList = sycRptCache.get(pccId);
List<PcepStateReport> rptMsgList = syncRptCache.get(pccId);
rptMsgList.add(rptMsg);
sycRptCache.put(pccId, rptMsgList);
syncRptCache.put(pccId, rptMsgList);
}
@Override
......
......@@ -82,6 +82,7 @@ import org.onosproject.pcep.controller.PcepClientListener;
import org.onosproject.pcep.controller.PcepEventListener;
import org.onosproject.pcep.controller.PcepLspStatus;
import org.onosproject.pcep.controller.PcepLspSyncAction;
import org.onosproject.pcep.controller.SrpIdGenerators;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
import org.onosproject.pcepio.protocol.PcepAttribute;
......@@ -131,13 +132,13 @@ import static org.onosproject.net.PortNumber.portNumber;
import static org.onosproject.pcep.api.PcepDpid.uri;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.COST_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.COST_TYPE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT;
......
......@@ -23,7 +23,7 @@ import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......
......@@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......
......@@ -19,12 +19,12 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCC_TUNNEL_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED;
import static org.onosproject.net.Device.Type.ROUTER;
......
......@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNot.not;
import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......
......@@ -20,7 +20,9 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LOCAL_LSP_ID;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PLSP_ID;
import java.io.IOException;
import java.util.ArrayList;
......@@ -112,8 +114,8 @@ public class PcepUpdateTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
......@@ -173,8 +175,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -233,8 +235,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -293,8 +295,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(PLSP_ID, "1")
.set(LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......