mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-17 10:21:52 +02:00
[ONOS-4743] - DB sync is suspended if PCEP session is formed before BGP devices are learnt
Change-Id: I543201c54883e06182c1c83c4c64dd16a18e096c
This commit is contained in:
parent
b6e884ba5e
commit
28b5375f91
@ -1058,6 +1058,18 @@ public class PceManager implements PceService {
|
|||||||
// Node-label allocation is being done during Label DB Sync.
|
// Node-label allocation is being done during Label DB Sync.
|
||||||
// So, when device is detected, no need to do node-label
|
// So, when device is detected, no need to do node-label
|
||||||
// allocation.
|
// allocation.
|
||||||
|
String lsrId = specificDevice.annotations().value(LSRID);
|
||||||
|
if (lsrId != null) {
|
||||||
|
pceStore.addLsrIdDevice(lsrId, specificDevice.id());
|
||||||
|
|
||||||
|
// Search in failed DB sync store. If found, trigger label DB sync.
|
||||||
|
DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
|
||||||
|
if (pceStore.hasPccLsr(pccDeviceId)) {
|
||||||
|
log.debug("Continue to perform label DB sync for device {}.", pccDeviceId.toString());
|
||||||
|
syncLabelDb(pccDeviceId);
|
||||||
|
pceStore.removePccLsr(pccDeviceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEVICE_REMOVED:
|
case DEVICE_REMOVED:
|
||||||
@ -1065,6 +1077,11 @@ public class PceManager implements PceService {
|
|||||||
if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
|
if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
|
||||||
releaseNodeLabel(specificDevice);
|
releaseNodeLabel(specificDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (specificDevice.annotations().value(LSRID) != null) {
|
||||||
|
pceStore.removeLsrIdDevice(specificDevice.annotations().value(LSRID));
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1252,13 +1269,20 @@ public class PceManager implements PceService {
|
|||||||
private boolean syncLabelDb(DeviceId deviceId) {
|
private boolean syncLabelDb(DeviceId deviceId) {
|
||||||
checkNotNull(deviceId);
|
checkNotNull(deviceId);
|
||||||
|
|
||||||
Device specificDevice = deviceService.getDevice(deviceId);
|
DeviceId actualDevcieId = pceStore.getLsrIdDevice(deviceId.toString());
|
||||||
if (specificDevice == null) {
|
if (actualDevcieId == null) {
|
||||||
log.error("Unable to find device for specific device id {}.", deviceId.toString());
|
log.error("Device not available {}.", deviceId.toString());
|
||||||
|
pceStore.addPccLsr(deviceId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pceStore.getGlobalNodeLabel(deviceId) != null) {
|
Device specificDevice = deviceService.getDevice(actualDevcieId);
|
||||||
|
if (specificDevice == null) {
|
||||||
|
log.error("Unable to find device for specific device id {}.", actualDevcieId.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pceStore.getGlobalNodeLabel(actualDevcieId) != null) {
|
||||||
Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
|
Map<DeviceId, LabelResourceId> globalNodeLabelMap = pceStore.getGlobalNodeLabels();
|
||||||
|
|
||||||
for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
|
for (Entry<DeviceId, LabelResourceId> entry : globalNodeLabelMap.entrySet()) {
|
||||||
@ -1279,7 +1303,7 @@ public class PceManager implements PceService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
srTeHandler.advertiseNodeLabelRule(deviceId,
|
srTeHandler.advertiseNodeLabelRule(actualDevcieId,
|
||||||
entry.getValue(),
|
entry.getValue(),
|
||||||
IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
|
IpPrefix.valueOf(IpAddress.valueOf(srcLsrId), PREFIX_LENGTH),
|
||||||
Objective.Operation.ADD, false);
|
Objective.Operation.ADD, false);
|
||||||
@ -1287,8 +1311,8 @@ public class PceManager implements PceService {
|
|||||||
|
|
||||||
Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
|
Map<Link, LabelResourceId> adjLabelMap = pceStore.getAdjLabels();
|
||||||
for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
|
for (Entry<Link, LabelResourceId> entry : adjLabelMap.entrySet()) {
|
||||||
if (entry.getKey().src().deviceId().equals(deviceId)) {
|
if (entry.getKey().src().deviceId().equals(actualDevcieId)) {
|
||||||
srTeHandler.installAdjLabelRule(deviceId,
|
srTeHandler.installAdjLabelRule(actualDevcieId,
|
||||||
entry.getValue(),
|
entry.getValue(),
|
||||||
entry.getKey().src().port(),
|
entry.getKey().src().port(),
|
||||||
entry.getKey().dst().port(),
|
entry.getKey().dst().port(),
|
||||||
@ -1297,12 +1321,12 @@ public class PceManager implements PceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srTeHandler.advertiseNodeLabelRule(deviceId,
|
srTeHandler.advertiseNodeLabelRule(actualDevcieId,
|
||||||
LabelResourceId.labelResourceId(0),
|
LabelResourceId.labelResourceId(0),
|
||||||
IpPrefix.valueOf(END_OF_SYNC_IP_PREFIX),
|
IpPrefix.valueOf(END_OF_SYNC_IP_PREFIX),
|
||||||
Objective.Operation.ADD, true);
|
Objective.Operation.ADD, true);
|
||||||
|
|
||||||
log.debug("End of label DB sync for device {}", deviceId);
|
log.debug("End of label DB sync for device {}", actualDevcieId);
|
||||||
|
|
||||||
if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
|
if (mastershipService.getLocalRole(specificDevice.id()) == MastershipRole.MASTER) {
|
||||||
// Allocate node-label to this specific device.
|
// Allocate node-label to this specific device.
|
||||||
|
@ -19,6 +19,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -89,6 +91,13 @@ public class DistributedPceStore implements PceStore {
|
|||||||
// List of Failed path info
|
// List of Failed path info
|
||||||
private DistributedSet<PcePathInfo> failedPathSet;
|
private DistributedSet<PcePathInfo> failedPathSet;
|
||||||
|
|
||||||
|
// Locally maintain LSRID to device id mapping for better performance.
|
||||||
|
private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
|
||||||
|
|
||||||
|
// List of PCC LSR ids whose BGP device information was not available to perform
|
||||||
|
// label db sync.
|
||||||
|
private HashSet<DeviceId> pendinglabelDbSyncPccMap = new HashSet();
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
protected void activate() {
|
protected void activate() {
|
||||||
globalNodeLabelMap = storageService.<DeviceId, LabelResourceId>consistentMapBuilder()
|
globalNodeLabelMap = storageService.<DeviceId, LabelResourceId>consistentMapBuilder()
|
||||||
@ -341,4 +350,50 @@ public class DistributedPceStore implements PceStore {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
|
||||||
|
checkNotNull(lsrId);
|
||||||
|
checkNotNull(deviceId);
|
||||||
|
|
||||||
|
lsrIdDeviceIdMap.put(lsrId, deviceId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeLsrIdDevice(String lsrId) {
|
||||||
|
checkNotNull(lsrId);
|
||||||
|
|
||||||
|
lsrIdDeviceIdMap.remove(lsrId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceId getLsrIdDevice(String lsrId) {
|
||||||
|
checkNotNull(lsrId);
|
||||||
|
|
||||||
|
return lsrIdDeviceIdMap.get(lsrId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addPccLsr(DeviceId lsrId) {
|
||||||
|
checkNotNull(lsrId);
|
||||||
|
pendinglabelDbSyncPccMap.add(lsrId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removePccLsr(DeviceId lsrId) {
|
||||||
|
checkNotNull(lsrId);
|
||||||
|
pendinglabelDbSyncPccMap.remove(lsrId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPccLsr(DeviceId lsrId) {
|
||||||
|
checkNotNull(lsrId);
|
||||||
|
return pendinglabelDbSyncPccMap.contains(lsrId);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,4 +224,54 @@ public interface PceStore {
|
|||||||
* @return success or failure
|
* @return success or failure
|
||||||
*/
|
*/
|
||||||
boolean removeFailedPathInfo(PcePathInfo failedPathInfo);
|
boolean removeFailedPathInfo(PcePathInfo failedPathInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds lsrid to device id mapping.
|
||||||
|
*
|
||||||
|
* @param lsrId lsrId of the device
|
||||||
|
* @param deviceId device id
|
||||||
|
* @return success or failure
|
||||||
|
*/
|
||||||
|
boolean addLsrIdDevice(String lsrId, DeviceId deviceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes lsrid to device id mapping.
|
||||||
|
*
|
||||||
|
* @param lsrId lsrId of the device
|
||||||
|
* @return success or failure
|
||||||
|
*/
|
||||||
|
boolean removeLsrIdDevice(String lsrId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets lsrid to device id mapping.
|
||||||
|
*
|
||||||
|
* @param lsrId lsrId of the device
|
||||||
|
* @return device id of the lsrId
|
||||||
|
*/
|
||||||
|
DeviceId getLsrIdDevice(String lsrId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds lsrId of the PCC in form of device id for the PCC for which sync is pending due to non-availability of BGP.
|
||||||
|
* device.
|
||||||
|
*
|
||||||
|
* @param lsrId LSR id of the PCC in form of device id
|
||||||
|
* @return success or failure
|
||||||
|
*/
|
||||||
|
public boolean addPccLsr(DeviceId lsrId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes lsrId of the PCC in form of device id for the PCC for which pending sync is done.
|
||||||
|
*
|
||||||
|
* @param lsrId LSR id of the PCC in form of device id
|
||||||
|
* @return success or failure
|
||||||
|
*/
|
||||||
|
public boolean removePccLsr(DeviceId lsrId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets lsrId of the PCC in form of device id.
|
||||||
|
*
|
||||||
|
* @param lsrId LSR id of the PCC in form of device id
|
||||||
|
* @return success or failure
|
||||||
|
*/
|
||||||
|
public boolean hasPccLsr(DeviceId lsrId);
|
||||||
}
|
}
|
||||||
|
@ -690,6 +690,7 @@ public class PceManagerTest {
|
|||||||
LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
|
LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
|
||||||
LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
|
LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
|
||||||
|
|
||||||
|
pceManager.pceStore.addLsrIdDevice(deviceD1.annotations().value(LSRID), deviceD1.id());
|
||||||
pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
|
pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
|
||||||
pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
|
pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
|
||||||
|
|
||||||
@ -713,7 +714,7 @@ public class PceManagerTest {
|
|||||||
eth.setEtherType(Ethernet.TYPE_IPV4);
|
eth.setEtherType(Ethernet.TYPE_IPV4);
|
||||||
eth.setPayload(ipv4);
|
eth.setPayload(ipv4);
|
||||||
|
|
||||||
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(D1.deviceId(),
|
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(DeviceId.deviceId("1.1.1.1"),
|
||||||
PortNumber.portNumber(PCEP_PORT)),
|
PortNumber.portNumber(PCEP_PORT)),
|
||||||
eth, null);
|
eth, null);
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -52,6 +54,9 @@ public class PceStoreAdapter implements PceStore {
|
|||||||
// Set of Path info
|
// Set of Path info
|
||||||
private Set<PcePathInfo> failedPathInfoSet = new HashSet<>();
|
private Set<PcePathInfo> failedPathInfoSet = new HashSet<>();
|
||||||
|
|
||||||
|
// Locally maintain LSRID to device id mapping for better performance.
|
||||||
|
private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean existsGlobalNodeLabel(DeviceId id) {
|
public boolean existsGlobalNodeLabel(DeviceId id) {
|
||||||
return globalNodeLabelMap.containsKey(id);
|
return globalNodeLabelMap.containsKey(id);
|
||||||
@ -208,4 +213,39 @@ public class PceStoreAdapter implements PceStore {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addLsrIdDevice(String lsrId, DeviceId deviceId) {
|
||||||
|
lsrIdDeviceIdMap.put(lsrId, deviceId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeLsrIdDevice(String lsrId) {
|
||||||
|
lsrIdDeviceIdMap.remove(lsrId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceId getLsrIdDevice(String lsrId) {
|
||||||
|
return lsrIdDeviceIdMap.get(lsrId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addPccLsr(DeviceId lsrId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removePccLsr(DeviceId lsrId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPccLsr(DeviceId lsrId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,7 @@ import org.onlab.packet.Ethernet;
|
|||||||
import org.onlab.packet.IPv4;
|
import org.onlab.packet.IPv4;
|
||||||
import org.onlab.packet.MacAddress;
|
import org.onlab.packet.MacAddress;
|
||||||
import org.onlab.packet.TCP;
|
import org.onlab.packet.TCP;
|
||||||
import org.onosproject.net.AnnotationKeys;
|
|
||||||
import org.onosproject.net.ConnectPoint;
|
import org.onosproject.net.ConnectPoint;
|
||||||
import org.onosproject.net.Device;
|
|
||||||
import org.onosproject.net.DeviceId;
|
import org.onosproject.net.DeviceId;
|
||||||
import org.onosproject.net.PortNumber;
|
import org.onosproject.net.PortNumber;
|
||||||
import org.onosproject.net.device.DeviceService;
|
import org.onosproject.net.device.DeviceService;
|
||||||
@ -96,22 +94,7 @@ public class PcepPacketProvider extends AbstractProvider implements PacketProvid
|
|||||||
|
|
||||||
// Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
|
// Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID.
|
||||||
String lsrId = String.valueOf(pccId.ipAddress());
|
String lsrId = String.valueOf(pccId.ipAddress());
|
||||||
DeviceId pccDeviceId = null;
|
DeviceId pccDeviceId = DeviceId.deviceId(lsrId);
|
||||||
|
|
||||||
// Find PCC deviceID from lsrId stored as annotations
|
|
||||||
Iterable<Device> devices = deviceService.getAvailableDevices();
|
|
||||||
for (Device dev : devices) {
|
|
||||||
if ("L3".equals(dev.annotations().value(AnnotationKeys.TYPE))
|
|
||||||
&& lsrId.equals(dev.annotations().value(LSRID))) {
|
|
||||||
pccDeviceId = dev.id();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pccDeviceId == null) {
|
|
||||||
log.error("Device not found to perform label DB sync.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
|
InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId,
|
||||||
PortNumber.portNumber(PCEP_PORT)),
|
PortNumber.portNumber(PCEP_PORT)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user