Avantika-Huawei
Committed by Gerrit Code Review

[ONOS-4722] GoldenEye:Fix exception on learning unknown PCE-initiated LSP from PCC

Change-Id: I967a952e9fe014a88b73abadb3003b5f8b6e45b9
......@@ -116,6 +116,7 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.FAILED;
import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING;
import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
......@@ -603,6 +604,18 @@ public class PceManager implements PceService {
PceccTunnelInfo pceccTunnelInfo = new PceccTunnelInfo(null, consumerId);
pceStore.addTunnelInfo(updatedTunnelId, pceccTunnelInfo);
}
// For CR cases, download labels and send update message.
if (lspType == WITHOUT_SIGNALLING_AND_WITHOUT_SR) {
Tunnel tunnelForlabelDownload = new DefaultTunnel(null, tunnel.src(), tunnel.dst(), MPLS, INIT, null,
updatedTunnelId, tunnel.tunnelName(), computedPath,
labelStack, annotationBuilder.build());
if (!crHandler.allocateLabel(tunnelForlabelDownload)) {
log.error("Unable to allocate labels for the tunnel {}.", tunnel.toString());
}
}
return true;
}
......@@ -1154,6 +1167,11 @@ public class PceManager implements PceService {
links.get(links.size() - 1).dst().deviceId(),
tunnel.tunnelName().value(), constraints, lspType));
}
if (tunnel.state() == FAILED) {
// Check whether this ONOS instance is master, if yes, recompute and send update.
checkForMasterAndUpdateTunnel(tunnel.path().src().deviceId(), tunnel);
}
break;
case TUNNEL_REMOVED:
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.onosproject.provider.pcep.tunnel.impl;
package org.onosproject.pcep.controller;
/**
* Representation of LSP type.
......
......@@ -37,13 +37,4 @@ public interface PcepEventListener {
* @param endOfSyncAction the action that needs to be taken for the tunnel
*/
void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction);
/**
* Handles sending PCEP message to client on end of LSPDB sync.
*
* @param pccId id of the pcc
* @param msg the message to be sent
* @param endOfSyncAction the action that needs to be taken in the message
*/
void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction);
}
......
......@@ -49,6 +49,7 @@ import org.onosproject.pcep.controller.PcepLspStatus;
import org.onosproject.pcep.controller.PcepNodeListener;
import org.onosproject.pcep.controller.PcepPacketListener;
import org.onosproject.pcep.controller.PcepSyncStatus;
import org.onosproject.pcep.controller.SrpIdGenerators;
import org.onosproject.pcep.controller.driver.PcepAgent;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
......@@ -61,6 +62,7 @@ import org.onosproject.pcepio.protocol.PcepInitiateMsg;
import org.onosproject.pcepio.protocol.PcepLspObject;
import org.onosproject.pcepio.protocol.PcepMessage;
import org.onosproject.pcepio.protocol.PcepReportMsg;
import org.onosproject.pcepio.protocol.PcepSrpObject;
import org.onosproject.pcepio.protocol.PcepStateReport;
import org.onosproject.pcepio.types.PcepValueType;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
......@@ -74,7 +76,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC;
import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE;
import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE;
import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_DELETE;
import static org.onosproject.pcep.controller.PcepLspSyncAction.UNSTABLE;
import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19;
import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5;
......@@ -487,8 +488,10 @@ public class PcepClientControllerImpl implements PcepClientController {
if (lspObj.getCFlag() && !lspObj.getRFlag()) {
// For initiated LSP, need to send PCInit delete msg.
try {
PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(SrpIdGenerators.create())
.setRFlag(true).build();
PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest()
.setLspObject(lspObj).build();
.setLspObject(lspObj).setSrpObject(srpobj).build();
LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList
= new LinkedList<PcInitiatedLspRequest>();
llPcInitiatedLspRequestList.add(releaseLspRequest);
......@@ -496,10 +499,7 @@ public class PcepClientControllerImpl implements PcepClientController {
PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg()
.setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build();
for (PcepEventListener l : pcepEventListener) {
l.handleEndOfSyncAction(pccId, pcInitiateMsg, SEND_DELETE);
}
pc.sendMessage(Collections.singletonList(pcInitiateMsg));
} catch (PcepParseException e) {
log.error("Exception occured while sending initiate delete message {}", e.getMessage());
}
......
......@@ -36,7 +36,7 @@ public class NexthopIPv4addressTlv implements PcepValueType {
0 1 2 3
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type=TBD | Length = 8 |
| Type=TBD | Length = 4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| nexthop IPv4 address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
......@@ -46,7 +46,7 @@ public class NexthopIPv4addressTlv implements PcepValueType {
*/
protected static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class);
public static final short TYPE = 2; //to be defined
public static final short TYPE = (short) 65289; //to be defined
//Length is header + value
public static final short LENGTH = 8;
public static final short VALUE_LENGTH = 4;
......@@ -93,7 +93,7 @@ public class NexthopIPv4addressTlv implements PcepValueType {
@Override
public short getLength() {
return LENGTH;
return VALUE_LENGTH;
}
@Override
......@@ -117,7 +117,7 @@ public class NexthopIPv4addressTlv implements PcepValueType {
public int write(ChannelBuffer c) {
int iStartIndex = c.writerIndex();
c.writeShort(TYPE);
c.writeShort(LENGTH);
c.writeShort(VALUE_LENGTH);
c.writeInt(rawValue);
return c.writerIndex() - iStartIndex;
}
......@@ -136,7 +136,7 @@ public class NexthopIPv4addressTlv implements PcepValueType {
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
.add("Length", LENGTH)
.add("Length", VALUE_LENGTH)
.add("Ipv4Address ", rawValue)
.toString();
}
......
......@@ -138,10 +138,13 @@ import org.onosproject.pcepio.protocol.PcepUpdateMsg;
import org.onosproject.pcepio.protocol.PcepUpdateRequest;
import org.onosproject.pcepio.types.IPv4SubObject;
import org.onosproject.pcepio.types.NexthopIPv4addressTlv;
import org.onosproject.pcepio.types.PathSetupTypeTlv;
import org.onosproject.pcepio.types.PcepLabelDownload;
import org.onosproject.pcepio.types.PcepLabelMap;
import org.onosproject.pcepio.types.PcepValueType;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
import org.onosproject.pcepio.types.SymbolicPathNameTlv;
import org.onosproject.pcep.controller.LspType;
import org.onosproject.pcepio.protocol.PcepAttribute;
import org.onosproject.pcepio.protocol.PcepBandwidthObject;
import org.onosproject.pcep.controller.SrpIdGenerators;
......@@ -150,6 +153,9 @@ import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCE_INIT;
import static org.onosproject.pcep.controller.PcepSyncStatus.IN_SYNC;
import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED;
import static org.onosproject.net.flow.criteria.Criterion.Type.EXTENSION;
......@@ -507,20 +513,34 @@ public class BgpcepFlowRuleProvider extends AbstractProvider
srpObj = getSrpObject(pc, type, false);
String lspId = tunnel.annotations().value(PcepAnnotationKeys.PLSP_ID);
String plspId = tunnel.annotations().value(PcepAnnotationKeys.LOCAL_LSP_ID);
String lspId = tunnel.annotations().value(PcepAnnotationKeys.LOCAL_LSP_ID);
String plspId = tunnel.annotations().value(PcepAnnotationKeys.PLSP_ID);
String tunnelIdentifier = tunnel.annotations().value(PcepAnnotationKeys.PCC_TUNNEL_ID);
LinkedList<PcepValueType> tlvs = new LinkedList<>();
StatefulIPv4LspIdentifiersTlv lspIdTlv = new StatefulIPv4LspIdentifiersTlv(((IpTunnelEndPoint) tunnel.src())
.ip().getIp4Address().toInt(), Short.valueOf(lspId), Short.valueOf(tunnelIdentifier), 0,
.ip().getIp4Address().toInt(), Short.valueOf(lspId), Short.valueOf(tunnelIdentifier),
((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt(),
((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt());
tlvs.add(lspIdTlv);
if (tunnel.tunnelName().value() != null) {
SymbolicPathNameTlv pathNameTlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes());
tlvs.add(pathNameTlv);
}
boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false
: Boolean.valueOf(tunnel.annotations()
.value(DELEGATE));
boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false
: Boolean.valueOf(tunnel.annotations()
.value(PCE_INIT));
lspObj = pc.factory().buildLspObject()
.setRFlag(false)
.setAFlag(true)
.setDFlag(true)
.setDFlag(delegated)
.setCFlag(initiated)
.setPlspId(Integer.valueOf(plspId))
.setOptionalTlv(tlvs)
.build();
......@@ -555,9 +575,15 @@ public class BgpcepFlowRuleProvider extends AbstractProvider
return;
}
// set PathSetupTypeTlv of SRP object
LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE));
llOptionalTlv.add(new PathSetupTypeTlv(lspSigType.type()));
PcepSrpObject srpObj = pc.factory().buildSrpObject()
.setRFlag(false)
.setSrpID(SrpIdGenerators.create())
.setOptionalTlv(llOptionalTlv)
.build();
PcepEroObject eroObj = pc.factory().buildEroObject()
......
......@@ -78,6 +78,7 @@ import org.onosproject.pcep.api.PcepTunnel.PathType;
import org.onosproject.pcep.api.PcepTunnelListener;
import org.onosproject.pcep.api.PcepTunnelStatistics;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.LspType;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
......@@ -140,8 +141,9 @@ import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.net.DeviceId.deviceId;
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.pcep.controller.LspType.WITH_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
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;
......@@ -157,7 +159,6 @@ import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE;
import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE;
import static org.onosproject.pcep.controller.PcepLspSyncAction.REMOVE;
import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_UPDATE;
import static org.onosproject.pcep.controller.PcepLspSyncAction.SEND_DELETE;
import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.IGP_METRIC;
import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.TE_METRIC;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -311,7 +312,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
//TODO: tunnel which is passed doesn't have tunnelID
if (tunnel.annotations().value(PLSP_ID) != null) {
if (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) != WITHOUT_SIGNALLING_AND_WITHOUT_SR) {
// For CR LSPs, BGP flow provider will send update message after pushing labels.
updateTunnel(tunnel, path);
}
return;
}
......@@ -1221,8 +1225,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src())
.ip().getIp4Address().toInt()),
localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip()
.getIp4Address().toInt()));
localLspId, pccTunnelId,
((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt(),
(((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt()));
llOptionalTlv.add(tlv);
}
......@@ -1231,9 +1236,18 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
llOptionalTlv.add(tlv);
}
boolean delegated = (tunnel.annotations().value(DELEGATE) == null) ? false
: Boolean.valueOf(tunnel.annotations()
.value(DELEGATE));
boolean initiated = (tunnel.annotations().value(PCE_INIT) == null) ? false
: Boolean.valueOf(tunnel.annotations()
.value(PCE_INIT));
// build lsp object
PcepLspObject lspobj = pc.factory().buildLspObject().setAFlag(true)
.setPlspId(Integer.valueOf(tunnel.annotations().value(PLSP_ID)))
.setDFlag(delegated)
.setCFlag(initiated)
.setOptionalTlv(llOptionalTlv).build();
// build ero object
PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build();
......@@ -1820,36 +1834,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid
tunnelRemoved(td);
}
}
@Override
public void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction) {
try {
if ((msg instanceof PcepInitiateMsg) && (endOfSyncAction == SEND_DELETE)) {
PcepClient pc = pcepClientController.getClient(pccId);
LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = ((PcepInitiateMsg) msg)
.getPcInitiatedLspRequestList();
PcInitiatedLspRequest pcInitMsg = llPcInitiatedLspRequestList.iterator().next();
if (pcInitMsg != null) {
PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(SrpIdGenerators.create())
.setRFlag(true).build();
PcInitiatedLspRequest releaseLspRequest = pc.factory().buildPcInitiatedLspRequest()
.setLspObject(pcInitMsg.getLspObject()).setSrpObject(srpobj).build();
llPcInitiatedLspRequestList.remove(pcInitMsg);
llPcInitiatedLspRequestList.add(releaseLspRequest);
PcepInitiateMsg pcInitiateMsg = pc.factory().buildPcepInitiateMsg()
.setPcInitiatedLspRequestList(llPcInitiatedLspRequestList).build();
pc.sendMessage(Collections.singletonList(pcInitiateMsg));
}
}
} catch (PcepParseException e) {
log.error("Exception occured while sending initiate delete message {}", e.getMessage());
}
}
}
@Override
public Tunnel tunnelQueryById(TunnelId tunnelId) {
......
......@@ -20,9 +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.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.pcep.controller.LspType.WITH_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
......
......@@ -20,9 +20,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
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.pcep.controller.LspType.WITH_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
......
......@@ -25,7 +25,7 @@ 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.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED;
import static org.onosproject.net.Device.Type.ROUTER;
import static org.onosproject.net.MastershipRole.MASTER;
......
......@@ -19,7 +19,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
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.pcep.controller.LspType.WITH_SIGNALLING;
import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
......
......@@ -55,9 +55,9 @@ import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
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.pcep.controller.LspType.WITH_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
/**
* Test for PCEP update tunnel.
*/
......