Duplicated flow obj requests are sent in occasion of ROUTE_REMOVED event
Change-Id: I7ad9aa8f27203684921356689805b4092f138d78
diff --git a/app/src/main/java/org/onosproject/segmentrouting/RouteHandler.java b/app/src/main/java/org/onosproject/segmentrouting/RouteHandler.java
index 21870ee..a8de070 100644
--- a/app/src/main/java/org/onosproject/segmentrouting/RouteHandler.java
+++ b/app/src/main/java/org/onosproject/segmentrouting/RouteHandler.java
@@ -222,9 +222,8 @@
locations.forEach(location -> {
log.debug("RouteRemoved. removeSubnet {}, {}", location, prefix);
srManager.deviceConfiguration.removeSubnet(location, prefix);
- log.debug("RouteRemoved. revokeRoute {}, {}, {}, {}", location, prefix, nextHopMac, nextHopVlan);
- srManager.defaultRoutingHandler.revokeRoute(location.deviceId(), prefix,
- nextHopMac, nextHopVlan, location.port());
+ // We don't need to call revokeRoute again since revokeSubnet will remove the prefix
+ // from all devices, including the ones that next hop attaches to.
// Also remove redirection flows on the pair device if exists.
Optional<DeviceId> pairDeviceId = srManager.getPairDeviceId(location.deviceId());
diff --git a/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java b/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java
index e33a36d..b6ec070 100644
--- a/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java
+++ b/app/src/test/java/org/onosproject/segmentrouting/HostHandlerTest.java
@@ -205,7 +205,7 @@
srManager.deviceConfiguration = new DeviceConfiguration(srManager);
srManager.flowObjectiveService = new MockFlowObjectiveService(BRIDGING_TABLE, NEXT_TABLE);
srManager.routingRulePopulator = new MockRoutingRulePopulator(srManager, ROUTING_TABLE);
- srManager.defaultRoutingHandler = new MockDefaultRoutingHandler(srManager, SUBNET_TABLE);
+ srManager.defaultRoutingHandler = new MockDefaultRoutingHandler(srManager, SUBNET_TABLE, ROUTING_TABLE);
srManager.interfaceService = new MockInterfaceService(INTERFACES);
srManager.mastershipService = new MockMastershipService(LOCAL_DEVICES);
srManager.hostService = new MockHostService(HOSTS);
diff --git a/app/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java b/app/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java
index ec07238..d31be2f 100644
--- a/app/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java
+++ b/app/src/test/java/org/onosproject/segmentrouting/MockDefaultRoutingHandler.java
@@ -27,11 +27,14 @@
*/
public class MockDefaultRoutingHandler extends DefaultRoutingHandler {
private Map<ConnectPoint, Set<IpPrefix>> subnetTable;
+ private Map<MockRoutingTableKey, MockRoutingTableValue> routingTable;
MockDefaultRoutingHandler(SegmentRoutingManager srManager,
- Map<ConnectPoint, Set<IpPrefix>> subnetTable) {
+ Map<ConnectPoint, Set<IpPrefix>> subnetTable,
+ Map<MockRoutingTableKey, MockRoutingTableValue> routingTable) {
super(srManager);
this.subnetTable = subnetTable;
+ this.routingTable = routingTable;
}
@Override
@@ -56,6 +59,7 @@
subnetTable.remove(entry.getKey());
}
}
+ routingTable.entrySet().removeIf(e -> subnets.contains(e.getKey().ipPrefix));
return true;
}
}
\ No newline at end of file
diff --git a/app/src/test/java/org/onosproject/segmentrouting/RouteHandlerTest.java b/app/src/test/java/org/onosproject/segmentrouting/RouteHandlerTest.java
index 843ba6b..36a9e79 100644
--- a/app/src/test/java/org/onosproject/segmentrouting/RouteHandlerTest.java
+++ b/app/src/test/java/org/onosproject/segmentrouting/RouteHandlerTest.java
@@ -145,7 +145,7 @@
srManager.deviceConfiguration = createMock(DeviceConfiguration.class);
srManager.flowObjectiveService = new MockFlowObjectiveService(BRIDGING_TABLE, NEXT_TABLE);
srManager.routingRulePopulator = new MockRoutingRulePopulator(srManager, ROUTING_TABLE);
- srManager.defaultRoutingHandler = new MockDefaultRoutingHandler(srManager, SUBNET_TABLE);
+ srManager.defaultRoutingHandler = new MockDefaultRoutingHandler(srManager, SUBNET_TABLE, ROUTING_TABLE);
srManager.interfaceService = new MockInterfaceService(INTERFACES);
srManager.mastershipService = new MockMastershipService(LOCAL_DEVICES);
hostService = new MockHostService(HOSTS);