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 {
LocationType dstIpLocationType = getLocationType(dstIp);
Optional<Interface> srcInterface =
interfaceService.getInterfacesByPort(srcConnectPoint).stream().findFirst();
Set<ConnectPoint> ingressPoints = config.getBgpPeerConnectPoints();
switch (dstIpLocationType) {
case INTERNET:
if (!srcInterface.isPresent()) {
if (srcInterface.isPresent() &&
(!ingressPoints.contains(srcConnectPoint))) {
return TrafficType.HOST_TO_INTERNET;
} else {
return TrafficType.INTERNET_TO_INTERNET;
}
case LOCAL:
if (!srcInterface.isPresent()) {
if (srcInterface.isPresent() &&
(!ingressPoints.contains(srcConnectPoint))) {
return TrafficType.HOST_TO_HOST;
} else {
// TODO Currently we only consider local public prefixes.
......
......@@ -32,8 +32,8 @@ import java.util.List;
public class Configuration {
// We call the BGP routers in our SDN network the BGP speakers, and call
// the BGP routers outside our SDN network the BGP peers.
private List<BgpSpeaker> bgpSpeakers;
private List<BgpPeer> peers;
private List<BgpSpeaker> bgpSpeakers = Collections.emptyList();
private List<BgpPeer> peers = Collections.emptyList();
private MacAddress virtualGatewayMacAddress;
// All IP prefixes from the configuration are local
......
......@@ -195,7 +195,9 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
}
BgpConfig bgpConfig = configService.getConfig(routerAppId, BgpConfig.class);
if (bgpConfig == null) {
return Collections.emptySet();
} else {
return bgpConfig.bgpSpeakers().stream()
.flatMap(speaker -> speaker.peers().stream())
.map(peer -> interfaceService.getMatchingInterface(peer))
......@@ -203,6 +205,7 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
.map(intf -> intf.connectPoint())
.collect(Collectors.toSet());
}
}
@Override
public Interface getInterface(ConnectPoint connectPoint) {
......