Determines route IP by checking the interface config directly
Previously, SR checked the subnet data structure which contains
multiple subnets now in order to support generic routing.
A missing part of gerrit #11842.
Change-Id: Ia778c8ba5a42927d259c70bbb7538869270a7a1f
diff --git a/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java b/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
index 15e9fa7..cb0a275 100644
--- a/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
+++ b/src/main/java/org/onosproject/segmentrouting/config/DeviceConfiguration.java
@@ -386,17 +386,21 @@
* @return router ip address
*/
public Ip4Address getRouterIpAddressForASubnetHost(Ip4Address destIpAddress) {
- for (Map.Entry<DeviceId, SegmentRouterInfo> entry:
- deviceConfigMap.entrySet()) {
- for (Ip4Prefix prefix : entry.getValue().subnets.values()) {
- if (prefix.contains(destIpAddress)) {
- return entry.getValue().ip;
- }
- }
+ Interface matchIntf = srManager.interfaceService.getMatchingInterface(destIpAddress);
+
+ if (matchIntf == null) {
+ log.debug("No router was found for {}", destIpAddress);
+ return null;
}
- log.debug("No router was found for {}", destIpAddress);
- return null;
+ DeviceId routerDeviceId = matchIntf.connectPoint().deviceId();
+ SegmentRouterInfo srInfo = deviceConfigMap.get(routerDeviceId);
+ if (srInfo == null) {
+ log.debug("No device config was found for {}", routerDeviceId);
+ return null;
+ }
+
+ return srInfo.ip;
}
/**