[ONOS-4687] GoldenEye - Label map download issues.
Change-Id: I5b56ccc6b8bad3c585f4d33ddd6d9094751c8797
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
index b415534..41e14dd 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceManager.java
@@ -893,9 +893,7 @@
// 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 @@
// 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 @@
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 @@
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;
+ }
+
+ srTeHandler.advertiseNodeLabelRule(deviceId,
+ entry.getValue(),
+ IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
+ Objective.Operation.ADD, false);
}
- 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);
- }
-
- 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);
+ }
}
}
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
index c760bc1..63eed1b 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pceservice/PceccSrTeBeHandler.java
@@ -28,7 +28,6 @@
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 @@
// 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 @@
// 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 @@
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();
diff --git a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
index 1c1aece..6afdb30 100644
--- a/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
+++ b/apps/pce/app/src/main/java/org/onosproject/pce/pcestore/DistributedPceStore.java
@@ -219,19 +219,19 @@
@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
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepAnnotationKeys.java b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepAnnotationKeys.java
similarity index 96%
rename from providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepAnnotationKeys.java
rename to protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepAnnotationKeys.java
index 18292b7..097f647 100644
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepAnnotationKeys.java
+++ b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepAnnotationKeys.java
@@ -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.
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/SrpIdGenerators.java b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/SrpIdGenerators.java
similarity index 96%
rename from providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/SrpIdGenerators.java
rename to protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/SrpIdGenerators.java
index 3e18025..e0cb3b3 100644
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/SrpIdGenerators.java
+++ b/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/SrpIdGenerators.java
@@ -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;
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java
index 6fe05e0..d2523f5 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java
@@ -62,6 +62,8 @@
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 @@
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 @@
log.debug("Keep alive time : " + keepAliveTimer);
//set the state handshake completion.
+
h.sendKeepAliveMessage();
h.pcepPacketStats.addOutPacket();
h.setHandshakeComplete(true);
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
index cb40ea0..00a7a20 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
@@ -434,10 +434,16 @@
}
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;
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
index a62a611..91a79de 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
@@ -73,7 +73,7 @@
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 @@
@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
diff --git a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java b/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
index b005132..6f0f10a 100644
--- a/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
+++ b/providers/bgpcep/flow/src/main/java/org/onosproject/provider/bgpcep/flow/impl/BgpcepFlowRuleProvider.java
@@ -15,6 +15,9 @@
*/
package org.onosproject.provider.bgpcep.flow.impl;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -28,7 +31,6 @@
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MplsLabel;
import org.onosproject.bgp.controller.BgpController;
-import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
@@ -42,21 +44,24 @@
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.flow.CompletedBatchOperation;
+import org.onosproject.net.flow.DefaultFlowEntry;
+import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.FlowRuleBatchEntry;
import org.onosproject.net.flow.FlowRuleBatchOperation;
import org.onosproject.net.flow.FlowRuleProvider;
import org.onosproject.net.flow.FlowRuleProviderRegistry;
import org.onosproject.net.flow.FlowRuleProviderService;
import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.FlowEntry.FlowEntryState;
import org.onosproject.net.flow.criteria.Criterion;
import org.onosproject.net.flow.criteria.IPCriterion;
import org.onosproject.net.flow.criteria.MetadataCriterion;
import org.onosproject.net.flow.criteria.MplsBosCriterion;
import org.onosproject.net.flow.criteria.MplsCriterion;
import org.onosproject.net.flow.criteria.PortCriterion;
-import org.onosproject.net.flow.criteria.TcpPortCriterion;
import org.onosproject.net.flow.criteria.TunnelIdCriterion;
-import org.onosproject.net.flowobjective.Objective;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.net.resource.ResourceService;
@@ -81,13 +86,14 @@
import org.onosproject.pcepio.types.PcepLabelMap;
import org.onosproject.pcepio.types.PcepValueType;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
-import org.onosproject.provider.pcep.tunnel.impl.SrpIdGenerators;
-import org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys;
+import org.onosproject.pcep.controller.SrpIdGenerators;
+import org.onosproject.pcep.controller.PcepAnnotationKeys;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
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;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
@@ -104,9 +110,6 @@
protected FlowRuleProviderRegistry providerRegistry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ComponentConfigService cfgService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected BgpController bgpController;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -129,6 +132,12 @@
public static final long SET = 0xFFFFFFFFL;
private static final String LSRID = "lsrId";
+ private enum PcepFlowType {
+ ADD,
+ MODIFY,
+ REMOVE
+ }
+
/**
* Creates a BgpFlow host provider.
*/
@@ -138,14 +147,12 @@
@Activate
public void activate(ComponentContext context) {
- cfgService.registerProperties(getClass());
providerService = providerRegistry.register(this);
log.info("Started");
}
@Deactivate
public void deactivate(ComponentContext context) {
- cfgService.unregisterProperties(getClass(), false);
providerRegistry.unregister(this);
providerService = null;
log.info("Stopped");
@@ -154,26 +161,25 @@
@Override
public void applyFlowRule(FlowRule... flowRules) {
for (FlowRule flowRule : flowRules) {
- processRule(flowRule, Objective.Operation.ADD);
+ processRule(flowRule, PcepFlowType.ADD);
}
}
@Override
public void removeFlowRule(FlowRule... flowRules) {
for (FlowRule flowRule : flowRules) {
- processRule(flowRule, Objective.Operation.REMOVE);
+ processRule(flowRule, PcepFlowType.REMOVE);
}
}
- private void processRule(FlowRule flowRule, Objective.Operation type) {
+ private void processRule(FlowRule flowRule, PcepFlowType type) {
MplsLabel mplsLabel = null;
- IpPrefix ip4Prefix = null;
+ IpPrefix ip4PrefixSrc = null;
+ IpPrefix ip4PrefixDst = null;
PortNumber port = null;
TunnelId tunnelId = null;
long labelType = 0;
boolean bottomOfStack = false;
- int srcPort = 0;
- int dstPort = 0;
TrafficSelector selector = flowRule.selector();
for (Criterion c : selector.criteria()) {
@@ -184,20 +190,16 @@
break;
case IPV4_SRC:
IPCriterion ipCriterion = (IPCriterion) c;
- ip4Prefix = ipCriterion.ip().getIp4Prefix();
+ ip4PrefixSrc = ipCriterion.ip().getIp4Prefix();
+ break;
+ case IPV4_DST:
+ ipCriterion = (IPCriterion) c;
+ ip4PrefixDst = ipCriterion.ip().getIp4Prefix();
break;
case IN_PORT:
PortCriterion inPort = (PortCriterion) c;
port = inPort.port();
break;
- case TCP_SRC:
- TcpPortCriterion srcTcpPort = (TcpPortCriterion) c;
- srcPort = srcTcpPort.tcpPort().toInt();
- break;
- case TCP_DST:
- TcpPortCriterion dstTcpPort = (TcpPortCriterion) c;
- dstPort = dstTcpPort.tcpPort().toInt();
- break;
case TUNNEL_ID:
TunnelIdCriterion tc = (TunnelIdCriterion) c;
tunnelId = TunnelId.valueOf(String.valueOf(tc.tunnelId()));
@@ -224,13 +226,12 @@
return;
}
- if (srcPort != 0 && dstPort != 0) {
- pushAdjacencyLabel(flowRule.deviceId(), label, PortNumber.portNumber(srcPort),
- PortNumber.portNumber(dstPort), type);
+ if (ip4PrefixDst != null) {
+ pushAdjacencyLabel(flowRule.deviceId(), label, ip4PrefixSrc, ip4PrefixDst, type);
return;
}
- pushGlobalNodeLabel(flowRule.deviceId(), label, ip4Prefix, type, bottomOfStack);
+ pushGlobalNodeLabel(flowRule.deviceId(), label, ip4PrefixSrc, type, bottomOfStack);
} catch (PcepParseException e) {
log.error("Exception occured while sending label message to PCC {}", e.getMessage());
@@ -255,7 +256,7 @@
//Pushes node labels to the specified device.
private void pushGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId,
- IpPrefix ipPrefix, Objective.Operation type, boolean isBos) throws PcepParseException {
+ IpPrefix ipPrefix, PcepFlowType type, boolean isBos) throws PcepParseException {
checkNotNull(deviceId);
checkNotNull(labelId);
@@ -271,7 +272,7 @@
if (ipPrefix == null) {
// Pushing self node label to device.
- IpPrefix.valueOf(pc.getPccId().ipAddress(), 32);
+ ipPrefix = IpPrefix.valueOf(pc.getPccId().ipAddress(), 32);
}
PcepFecObjectIPv4 fecObject = pc.factory().buildFecObjectIpv4()
@@ -279,16 +280,9 @@
.build();
boolean bSFlag = false;
- if (pc.labelDbSyncStatus() == IN_SYNC) {
- if (isBos) {
- /*
- * Now the sync is completed.
- * Need to send label DB end-of-sync msg, i.e. S flag in SRP id is reset.
- */
- pc.setLabelDbSyncStatus(SYNCED);
- } else {
- bSFlag = true;
- }
+ if (pc.labelDbSyncStatus() == IN_SYNC && !isBos) {
+ // Need to set sync flag in all messages till sync completes.
+ bSFlag = true;
}
PcepSrpObject srpObj = getSrpObject(pc, type, bSFlag);
@@ -312,14 +306,19 @@
.build();
pc.sendMessage(labelMsg);
+
+ if (isBos) {
+ // Sync is completed.
+ pc.setLabelDbSyncStatus(SYNCED);
+ }
}
- private PcepSrpObject getSrpObject(PcepClient pc, Objective.Operation type, boolean bSFlag)
+ private PcepSrpObject getSrpObject(PcepClient pc, PcepFlowType type, boolean bSFlag)
throws PcepParseException {
PcepSrpObject srpObj;
boolean bRFlag = false;
- if (!type.equals(Objective.Operation.ADD)) {
+ if (!type.equals(PcepFlowType.ADD)) {
// To cleanup labels, R bit is set
bRFlag = true;
}
@@ -334,13 +333,14 @@
}
//Pushes adjacency labels to the specified device.
- private void pushAdjacencyLabel(DeviceId deviceId, LabelResourceId labelId,
- PortNumber srcPortNum, PortNumber dstPortNum, Objective.Operation type) throws PcepParseException {
+ private void pushAdjacencyLabel(DeviceId deviceId, LabelResourceId labelId, IpPrefix ip4PrefixSrc,
+ IpPrefix ip4PrefixDst, PcepFlowType type)
+ throws PcepParseException {
checkNotNull(deviceId);
checkNotNull(labelId);
- checkNotNull(srcPortNum);
- checkNotNull(dstPortNum);
+ checkNotNull(ip4PrefixSrc);
+ checkNotNull(ip4PrefixDst);
checkNotNull(type);
PcepClient pc = getPcepClient(deviceId);
@@ -351,17 +351,21 @@
LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>();
- long srcPortNo = srcPortNum.toLong();
- long dstPortNo = dstPortNum.toLong();
- srcPortNo = ((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? srcPortNo & SET : srcPortNo;
- dstPortNo = ((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? dstPortNo & SET : dstPortNo;
+ int srcPortNo = ip4PrefixSrc.address().getIp4Address().toInt();
+ int dstPortNo = ip4PrefixDst.address().getIp4Address().toInt();
PcepFecObjectIPv4Adjacency fecAdjObject = pc.factory().buildFecIpv4Adjacency()
- .seRemoteIPv4Address((int) dstPortNo)
- .seLocalIPv4Address((int) srcPortNo)
+ .seRemoteIPv4Address(dstPortNo)
+ .seLocalIPv4Address(srcPortNo)
.build();
- PcepSrpObject srpObj = getSrpObject(pc, type, false);
+ boolean bSFlag = false;
+ if (pc.labelDbSyncStatus() == IN_SYNC) {
+ // Need to set sync flag in all messages till sync completes.
+ bSFlag = true;
+ }
+
+ PcepSrpObject srpObj = getSrpObject(pc, type, bSFlag);
//Adjacency label object
PcepLabelObject labelObject = pc.factory().buildLabelObject()
@@ -387,7 +391,7 @@
//Pushes local labels to the device which is specific to path [CR-case].
private void pushLocalLabels(DeviceId deviceId, LabelResourceId labelId,
PortNumber portNum, TunnelId tunnelId,
- Boolean isBos, Long labelType, Objective.Operation type) throws PcepParseException {
+ Boolean isBos, Long labelType, PcepFlowType type) throws PcepParseException {
checkNotNull(deviceId);
checkNotNull(labelId);
@@ -559,6 +563,31 @@
@Override
public void executeBatch(FlowRuleBatchOperation batch) {
- //TODO
+ Collection<FlowEntry> flowEntries = new ArrayList<>();
+
+ for (FlowRuleBatchEntry fbe : batch.getOperations()) {
+ Criterion criteria = fbe.target().selector().getCriterion(EXTENSION);
+
+ switch (fbe.operator()) {
+ case ADD:
+ if (criteria == null) {
+ processRule(fbe.target(), PcepFlowType.ADD);
+ flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.ADDED, 0, 0, 0));
+ }
+ break;
+ case REMOVE:
+ if (criteria == null) {
+ processRule(fbe.target(), PcepFlowType.REMOVE);
+ flowEntries.add(new DefaultFlowEntry(fbe.target(), FlowEntryState.REMOVED, 0, 0, 0));
+ }
+ break;
+ default:
+ log.error("Unknown flow operation: {}", fbe);
+ }
+ }
+
+ CompletedBatchOperation status = new CompletedBatchOperation(true, Collections.emptySet(), batch.deviceId());
+ providerService.batchOperationCompleted(batch.id(), status);
+ providerService.pushFlowMetrics(batch.deviceId(), flowEntries);
}
}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
index 66e7f31..8448528 100644
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
+++ b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
@@ -82,6 +82,7 @@
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.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;
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java
index 22a683b..e8ed50a 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepReleaseTunnelProviderTest.java
@@ -23,7 +23,7 @@
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;
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java
index 078deb1..018f50c 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepSetupTunnelProviderTest.java
@@ -23,7 +23,7 @@
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;
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelAddedTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelAddedTest.java
index ce00b5e..537d888 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelAddedTest.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelAddedTest.java
@@ -19,12 +19,12 @@
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;
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java
index e641c64..0e7fc99 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProviderTest.java
@@ -20,7 +20,7 @@
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;
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java
index 4106dfb..2b85fdf 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepUpdateTunnelProviderTest.java
@@ -20,7 +20,9 @@
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 @@
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 @@
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 @@
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 @@
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,