Charles Chan
Committed by Gerrit Code Review

Bugfix and improvement of SR config loading

Change-Id: If17af7ff1fbd3cb712e59cce930ef11146bdbf2e
...@@ -137,12 +137,7 @@ public class NetworkConfigEventHandler { ...@@ -137,12 +137,7 @@ public class NetworkConfigEventHandler {
137 if (config == null) { 137 if (config == null) {
138 return ImmutableSet.of(); 138 return ImmutableSet.of();
139 } 139 }
140 - 140 + return ImmutableSet.copyOf(config.vRouterMacs());
141 - HashSet<MacAddress> macAddresses = new HashSet<>();
142 - config.vRouterMacs().forEach(mac -> {
143 - macAddresses.add(mac);
144 - });
145 - return ImmutableSet.copyOf(macAddresses);
146 } 141 }
147 142
148 private boolean isEdge(DeviceId deviceId) { 143 private boolean isEdge(DeviceId deviceId) {
......
...@@ -59,7 +59,6 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -59,7 +59,6 @@ public class DeviceConfiguration implements DeviceProperties {
59 private final Map<VlanId, List<ConnectPoint>> xConnects = new ConcurrentHashMap<>(); 59 private final Map<VlanId, List<ConnectPoint>> xConnects = new ConcurrentHashMap<>();
60 private ApplicationId appId; 60 private ApplicationId appId;
61 private NetworkConfigService cfgService; 61 private NetworkConfigService cfgService;
62 - private SegmentRoutingAppConfig appConfig;
63 62
64 private class SegmentRouterInfo { 63 private class SegmentRouterInfo {
65 int nodeSid; 64 int nodeSid;
...@@ -107,9 +106,6 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -107,9 +106,6 @@ public class DeviceConfiguration implements DeviceProperties {
107 allSegmentIds.add(info.nodeSid); 106 allSegmentIds.add(info.nodeSid);
108 }); 107 });
109 108
110 - // Read SegmentRoutingAppConfig
111 - appConfig = cfgService.getConfig(appId, SegmentRoutingAppConfig.class);
112 -
113 // Read gatewayIps and subnets from port subject. 109 // Read gatewayIps and subnets from port subject.
114 Set<ConnectPoint> portSubjects = 110 Set<ConnectPoint> portSubjects =
115 cfgService.getSubjects(ConnectPoint.class, InterfaceConfig.class); 111 cfgService.getSubjects(ConnectPoint.class, InterfaceConfig.class);
...@@ -367,9 +363,13 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -367,9 +363,13 @@ public class DeviceConfiguration implements DeviceProperties {
367 363
368 ImmutableSet.Builder<Ip4Prefix> builder = ImmutableSet.builder(); 364 ImmutableSet.Builder<Ip4Prefix> builder = ImmutableSet.builder();
369 builder.addAll(srinfo.subnets.values()); 365 builder.addAll(srinfo.subnets.values());
370 - if (appConfig != null && deviceId.equals(appConfig.vRouterId())) { 366 + SegmentRoutingAppConfig appConfig =
367 + cfgService.getConfig(appId, SegmentRoutingAppConfig.class);
368 + if (appConfig != null) {
369 + if (deviceId.equals(appConfig.vRouterId().orElse(null))) {
371 builder.add(Ip4Prefix.valueOf("0.0.0.0/0")); 370 builder.add(Ip4Prefix.valueOf("0.0.0.0/0"));
372 } 371 }
372 + }
373 return builder.build(); 373 return builder.build();
374 } 374 }
375 return null; 375 return null;
...@@ -493,10 +493,14 @@ public class DeviceConfiguration implements DeviceProperties { ...@@ -493,10 +493,14 @@ public class DeviceConfiguration implements DeviceProperties {
493 } 493 }
494 494
495 public Set<ConnectPoint> suppressSubnet() { 495 public Set<ConnectPoint> suppressSubnet() {
496 + SegmentRoutingAppConfig appConfig =
497 + cfgService.getConfig(appId, SegmentRoutingAppConfig.class);
496 return (appConfig != null) ? appConfig.suppressSubnet() : ImmutableSet.of(); 498 return (appConfig != null) ? appConfig.suppressSubnet() : ImmutableSet.of();
497 } 499 }
498 500
499 public Set<ConnectPoint> suppressHost() { 501 public Set<ConnectPoint> suppressHost() {
502 + SegmentRoutingAppConfig appConfig =
503 + cfgService.getConfig(appId, SegmentRoutingAppConfig.class);
500 return (appConfig != null) ? appConfig.suppressHost() : ImmutableSet.of(); 504 return (appConfig != null) ? appConfig.suppressHost() : ImmutableSet.of();
501 } 505 }
502 } 506 }
......