Adding a component config to take down single homed host ports when all uplinks are lost.
In addition:
- handle port updates that may be lost if mastership changes at same time
- fix javadoc in DeviceService
Change-Id: I032909e8ab9564cf9c978b1d66abd3ab32c814d7
diff --git a/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java b/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java
index b798cec..fecdd30 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/HostHandler.java
@@ -77,10 +77,10 @@
private void processHostAdded(Host host) {
host.locations().forEach(location -> processHostAddedAtLocation(host, location));
// ensure dual-homed host locations have viable uplinks
- if (host.locations().size() > 1) {
+ if (host.locations().size() > 1 || srManager.singleHomedDown) {
host.locations().forEach(loc -> {
if (srManager.mastershipService.isLocalMaster(loc.deviceId())) {
- srManager.linkHandler.checkUplinksForDualHomedHosts(loc);
+ srManager.linkHandler.checkUplinksForHost(loc);
}
});
}
@@ -112,7 +112,7 @@
// processBridgingRule or processRoutingRule due to VLAN or IP mismatch respectively
srManager.getPairDeviceId(location.deviceId()).ifPresent(pairDeviceId -> {
if (host.locations().stream().noneMatch(l -> l.deviceId().equals(pairDeviceId))) {
- srManager.getPairLocalPorts(pairDeviceId).ifPresent(pairRemotePort -> {
+ srManager.getPairLocalPort(pairDeviceId).ifPresent(pairRemotePort -> {
// NOTE: Since the pairLocalPort is trunk port, use assigned vlan of original port
// when the host is untagged
VlanId vlanId = Optional.ofNullable(srManager.getInternalVlanId(location)).orElse(hostVlanId);
@@ -155,7 +155,7 @@
// Also remove redirection flows on the pair device if exists.
Optional<DeviceId> pairDeviceId = srManager.getPairDeviceId(location.deviceId());
- Optional<PortNumber> pairLocalPort = srManager.getPairLocalPorts(location.deviceId());
+ Optional<PortNumber> pairLocalPort = srManager.getPairLocalPort(location.deviceId());
if (pairDeviceId.isPresent() && pairLocalPort.isPresent()) {
// NOTE: Since the pairLocalPort is trunk port, use assigned vlan of original port
// when the host is untagged
@@ -204,7 +204,7 @@
// Redirect the flows to pair link if configured
// Note: Do not continue removing any rule
Optional<DeviceId> pairDeviceId = srManager.getPairDeviceId(prevLocation.deviceId());
- Optional<PortNumber> pairLocalPort = srManager.getPairLocalPorts(prevLocation.deviceId());
+ Optional<PortNumber> pairLocalPort = srManager.getPairLocalPort(prevLocation.deviceId());
if (pairDeviceId.isPresent() && pairLocalPort.isPresent() && newLocations.stream()
.anyMatch(location -> location.deviceId().equals(pairDeviceId.get()))) {
// NOTE: Since the pairLocalPort is trunk port, use assigned vlan of original port
@@ -301,10 +301,10 @@
});
// ensure dual-homed host locations have viable uplinks
- if (newLocations.size() > prevLocations.size()) {
+ if (newLocations.size() > prevLocations.size() || srManager.singleHomedDown) {
newLocations.forEach(loc -> {
if (srManager.mastershipService.isLocalMaster(loc.deviceId())) {
- srManager.linkHandler.checkUplinksForDualHomedHosts(loc);
+ srManager.linkHandler.checkUplinksForHost(loc);
}
});
}
@@ -350,7 +350,7 @@
Set<IpAddress> ipsToAdd = Sets.difference(newIps, prevIps);
Set<IpAddress> ipsToRemove = Sets.difference(prevIps, newIps);
- srManager.getPairLocalPorts(pairDeviceId).ifPresent(pairRemotePort -> {
+ srManager.getPairLocalPort(pairDeviceId).ifPresent(pairRemotePort -> {
// NOTE: Since the pairLocalPort is trunk port, use assigned vlan of original port
// when the host is untagged
VlanId vlanId = Optional.ofNullable(srManager.getInternalVlanId(location)).orElse(hostVlanId);
@@ -379,7 +379,7 @@
* @param cp connect point
*/
void processPortUp(ConnectPoint cp) {
- if (cp.port().equals(srManager.getPairLocalPorts(cp.deviceId()).orElse(null))) {
+ if (cp.port().equals(srManager.getPairLocalPort(cp.deviceId()).orElse(null))) {
return;
}
if (srManager.activeProbing) {