Avoids disabling access ports when the dev is not paired
Change-Id: Ice14b6986b58c9abc47bdede54d1f6cac6895791
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/LinkHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/LinkHandler.java
index 5e41dc5..2193c95 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/LinkHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/LinkHandler.java
@@ -339,8 +339,8 @@
* @param added true if link was added, false if link was removed
*/
private void updateHostPorts(Link link, boolean added) {
+ DeviceConfiguration devConfig = srManager.deviceConfiguration;
if (added) {
- DeviceConfiguration devConfig = srManager.deviceConfiguration;
try {
if (!devConfig.isEdgeDevice(link.src().deviceId())
|| devConfig.isEdgeDevice(link.dst().deviceId())) {
@@ -360,11 +360,18 @@
.changePortState(link.src().deviceId(), pnum, true));
}
} else {
+ // If the device does not have a pair device - skip
+ DeviceId dev = link.src().deviceId();
+ if (getPairDeviceIdOrNull(dev) == null) {
+ log.info("Device {} does not have pair device " +
+ "not disabling access port", dev);
+ return;
+ }
+ // Verify if last uplink
if (!lastUplink(link)) {
return;
}
// find dual homed hosts on this dev to disable
- DeviceId dev = link.src().deviceId();
Set<PortNumber> dp = srManager.hostHandler
.getDualHomedHostPorts(dev);
log.warn("Link src {} --> dst {} removed was the last uplink, "
@@ -659,6 +666,13 @@
* @param loc the host location
*/
void checkUplinksForHost(HostLocation loc) {
+ // If the device does not have a pair device - return
+ if (getPairDeviceIdOrNull(loc.deviceId()) == null) {
+ log.info("Device {} does not have pair device " +
+ "not disabling access port", loc.deviceId());
+ return;
+ }
+ // Verify link validity
try {
for (Link l : srManager.linkService.getDeviceLinks(loc.deviceId())) {
if (srManager.deviceConfiguration.isEdgeDevice(l.dst().deviceId())
@@ -685,6 +699,16 @@
downedPortStore.put(loc.deviceId(), p);
}
+ private DeviceId getPairDeviceIdOrNull(DeviceId deviceId) {
+ DeviceId pairDev;
+ try {
+ pairDev = srManager.deviceConfiguration.getPairDeviceId(deviceId);
+ } catch (DeviceConfigNotFoundException e) {
+ pairDev = null;
+ }
+ return pairDev;
+ }
+
ImmutableMap<Link, Boolean> getSeenLinks() {
return ImmutableMap.copyOf(seenLinks);
}