Skip edge port disabling logic when the setup has only a pair of leaves
The mechanism was originally introduced to signal dual-homed hosts to send traffic via another leaf when a leaf doesn't have any uplink
by disable edge ports.
This logic is no longer applicable in a setup with only a pair of leaves.
Change-Id: I0c00e866422c7104c76388f5a913eb35acc026ba
diff --git a/api/src/main/java/org/onosproject/segmentrouting/config/DeviceProperties.java b/api/src/main/java/org/onosproject/segmentrouting/config/DeviceProperties.java
index bb86aac..fd50c19 100644
--- a/api/src/main/java/org/onosproject/segmentrouting/config/DeviceProperties.java
+++ b/api/src/main/java/org/onosproject/segmentrouting/config/DeviceProperties.java
@@ -108,6 +108,13 @@
List<DeviceId> getEdgeDeviceIds();
/**
+ * Returns a list of infra devices.
+ *
+ * @return list of the infra device ids
+ */
+ List<DeviceId> getInfraDeviceIds();
+
+ /**
* Returns all segment IDs to be considered in building auto
*
* created groups.
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java b/impl/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
index 0f9efce..7980d25 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
@@ -426,6 +426,14 @@
}
@Override
+ public List<DeviceId> getInfraDeviceIds() {
+ return deviceConfigMap.values().stream()
+ .filter(deviceInfo -> !deviceInfo.isEdge)
+ .map(deviceInfo -> deviceInfo.deviceId)
+ .collect(Collectors.toList());
+ }
+
+ @Override
public List<Integer> getAllDeviceSegmentIds() {
return allSegmentIds;
}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/LinkHandler.java b/impl/src/main/java/org/onosproject/segmentrouting/LinkHandler.java
index 62ac1c0..229d32c 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/LinkHandler.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/LinkHandler.java
@@ -347,6 +347,12 @@
* @param added true if link was added, false if link was removed
*/
private void updateHostPorts(Link link, boolean added) {
+ // Topology has only a single pair of leaves
+ if (srManager.getInfraDeviceIds().isEmpty()) {
+ log.debug("No spine configured. Not updating edge port for {} {}", link, added ? "add" : "remove");
+ return;
+ }
+
DeviceConfiguration devConfig = srManager.deviceConfiguration;
if (added) {
try {
@@ -674,12 +680,19 @@
* @param loc the host location
*/
void checkUplinksForHost(HostLocation loc) {
+ // Topology has only a single pair of leaves
+ if (srManager.getInfraDeviceIds().isEmpty()) {
+ log.debug("No spine configured. Not disabling access port for {}", loc);
+ return;
+ }
+
// 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())) {
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index f96e9d0..c42773f 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -1214,6 +1214,11 @@
}
@Override
+ public List<DeviceId> getInfraDeviceIds() {
+ return deviceConfiguration.getInfraDeviceIds();
+ }
+
+ @Override
public MacAddress getDeviceMacAddress(DeviceId deviceId) throws DeviceConfigNotFoundException {
return deviceConfiguration.getDeviceMac(deviceId);
}
@@ -1583,6 +1588,7 @@
defaultRoutingHandler.invalidateShouldProgramCache(deviceId);
pairDeviceId.ifPresent(defaultRoutingHandler::invalidateShouldProgramCache);
defaultRoutingHandler.checkFullRerouteForMasterChange(deviceId, me);
+
} else {
log.warn("Unhandled event type: {}", event.type());
}
diff --git a/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingService.java b/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingService.java
index 4d89588..061e246 100644
--- a/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingService.java
+++ b/impl/src/main/java/org/onosproject/segmentrouting/SegmentRoutingService.java
@@ -447,6 +447,13 @@
List<DeviceId> getEdgeDeviceIds();
/**
+ * Returns a list of infra devices.
+ *
+ * @return list of the infra device ids
+ */
+ List<DeviceId> getInfraDeviceIds();
+
+ /**
* Returns the configured mac address of the device.
*
* @param deviceId the device id