diff options
Diffstat (limited to 'framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java')
-rw-r--r-- | framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java index 8fdf81a2..eef1b147 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java @@ -62,11 +62,18 @@ public class DeviceConfiguration implements DeviceProperties { HashMap<PortNumber, Ip4Address> gatewayIps; HashMap<PortNumber, Ip4Prefix> subnets; List<AdjacencySid> adjacencySids; + + public SegmentRouterInfo() { + this.gatewayIps = new HashMap<>(); + this.subnets = new HashMap<>(); + } } /** * Constructor. Reads all the configuration for all devices of type * Segment Router and organizes into various maps for easier access. + * + * @param cfgService config service */ public DeviceConfiguration(NetworkConfigRegistry cfgService) { // Read config from device subject, excluding gatewayIps and subnets. @@ -82,8 +89,6 @@ public class DeviceConfiguration implements DeviceProperties { info.mac = config.getMac(); info.isEdge = config.isEdgeRouter(); info.adjacencySids = config.getAdjacencySids(); - info.gatewayIps = new HashMap<>(); - info.subnets = new HashMap<>(); this.deviceConfigMap.put(info.deviceId, info); this.allSegmentIds.add(info.nodeSid); @@ -107,11 +112,14 @@ public class DeviceConfiguration implements DeviceProperties { PortNumber port = networkInterface.connectPoint().port(); SegmentRouterInfo info = this.deviceConfigMap.get(dpid); - Set<InterfaceIpAddress> interfaceAddresses = networkInterface.ipAddresses(); - interfaceAddresses.forEach(interfaceAddress -> { - info.gatewayIps.put(port, interfaceAddress.ipAddress().getIp4Address()); - info.subnets.put(port, interfaceAddress.subnetAddress().getIp4Prefix()); - }); + // skip if there is no corresponding device for this ConenctPoint + if (info != null) { + Set<InterfaceIpAddress> interfaceAddresses = networkInterface.ipAddresses(); + interfaceAddresses.forEach(interfaceAddress -> { + info.gatewayIps.put(port, interfaceAddress.ipAddress().getIp4Address()); + info.subnets.put(port, interfaceAddress.subnetAddress().getIp4Prefix()); + }); + } }); }); |