Pingping Lin
Committed by Gerrit Code Review

enable run reactive routing without BGP

   Another improment is: if we config interfaces for local subnet
   in network-cfg.json, sdn-ip will classify the traffic correctly

Change-Id: I94d80bc5a7c29b70e6c8546d99b71850cfb3f14d
...@@ -305,16 +305,19 @@ public class SdnIpReactiveRouting { ...@@ -305,16 +305,19 @@ public class SdnIpReactiveRouting {
305 LocationType dstIpLocationType = getLocationType(dstIp); 305 LocationType dstIpLocationType = getLocationType(dstIp);
306 Optional<Interface> srcInterface = 306 Optional<Interface> srcInterface =
307 interfaceService.getInterfacesByPort(srcConnectPoint).stream().findFirst(); 307 interfaceService.getInterfacesByPort(srcConnectPoint).stream().findFirst();
308 + Set<ConnectPoint> ingressPoints = config.getBgpPeerConnectPoints();
308 309
309 switch (dstIpLocationType) { 310 switch (dstIpLocationType) {
310 case INTERNET: 311 case INTERNET:
311 - if (!srcInterface.isPresent()) { 312 + if (srcInterface.isPresent() &&
313 + (!ingressPoints.contains(srcConnectPoint))) {
312 return TrafficType.HOST_TO_INTERNET; 314 return TrafficType.HOST_TO_INTERNET;
313 } else { 315 } else {
314 return TrafficType.INTERNET_TO_INTERNET; 316 return TrafficType.INTERNET_TO_INTERNET;
315 } 317 }
316 case LOCAL: 318 case LOCAL:
317 - if (!srcInterface.isPresent()) { 319 + if (srcInterface.isPresent() &&
320 + (!ingressPoints.contains(srcConnectPoint))) {
318 return TrafficType.HOST_TO_HOST; 321 return TrafficType.HOST_TO_HOST;
319 } else { 322 } else {
320 // TODO Currently we only consider local public prefixes. 323 // TODO Currently we only consider local public prefixes.
......
...@@ -32,8 +32,8 @@ import java.util.List; ...@@ -32,8 +32,8 @@ import java.util.List;
32 public class Configuration { 32 public class Configuration {
33 // We call the BGP routers in our SDN network the BGP speakers, and call 33 // We call the BGP routers in our SDN network the BGP speakers, and call
34 // the BGP routers outside our SDN network the BGP peers. 34 // the BGP routers outside our SDN network the BGP peers.
35 - private List<BgpSpeaker> bgpSpeakers; 35 + private List<BgpSpeaker> bgpSpeakers = Collections.emptyList();
36 - private List<BgpPeer> peers; 36 + private List<BgpPeer> peers = Collections.emptyList();
37 private MacAddress virtualGatewayMacAddress; 37 private MacAddress virtualGatewayMacAddress;
38 38
39 // All IP prefixes from the configuration are local 39 // All IP prefixes from the configuration are local
......
...@@ -195,7 +195,9 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { ...@@ -195,7 +195,9 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
195 } 195 }
196 196
197 BgpConfig bgpConfig = configService.getConfig(routerAppId, BgpConfig.class); 197 BgpConfig bgpConfig = configService.getConfig(routerAppId, BgpConfig.class);
198 - 198 + if (bgpConfig == null) {
199 + return Collections.emptySet();
200 + } else {
199 return bgpConfig.bgpSpeakers().stream() 201 return bgpConfig.bgpSpeakers().stream()
200 .flatMap(speaker -> speaker.peers().stream()) 202 .flatMap(speaker -> speaker.peers().stream())
201 .map(peer -> interfaceService.getMatchingInterface(peer)) 203 .map(peer -> interfaceService.getMatchingInterface(peer))
...@@ -203,6 +205,7 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService { ...@@ -203,6 +205,7 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
203 .map(intf -> intf.connectPoint()) 205 .map(intf -> intf.connectPoint())
204 .collect(Collectors.toSet()); 206 .collect(Collectors.toSet());
205 } 207 }
208 + }
206 209
207 @Override 210 @Override
208 public Interface getInterface(ConnectPoint connectPoint) { 211 public Interface getInterface(ConnectPoint connectPoint) {
......