move the reactive routing to new config subsystem
Change-Id: I3e570138afb800c5bd7dbef872cbf9044732fa49
diff --git a/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/ReactiveRoutingFib.java b/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/ReactiveRoutingFib.java
index 8e86056..ac5f148 100644
--- a/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/ReactiveRoutingFib.java
+++ b/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/ReactiveRoutingFib.java
@@ -16,8 +16,17 @@
package org.onosproject.reactive.routing;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
import org.onlab.packet.Ethernet;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
@@ -39,17 +48,9 @@
import org.onosproject.net.intent.constraint.PartialFailureConstraint;
import org.onosproject.routing.IntentRequestListener;
import org.onosproject.routing.IntentSynchronizationService;
-import org.onosproject.routing.config.RoutingConfigurationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* FIB component for reactive routing intents.
*/
@@ -64,7 +65,6 @@
private final ApplicationId appId;
private final HostService hostService;
- private final RoutingConfigurationService configService;
private final InterfaceService interfaceService;
private final IntentSynchronizationService intentSynchronizer;
@@ -75,17 +75,14 @@
*
* @param appId application ID to use to generate intents
* @param hostService host service
- * @param configService routing configuration service
* @param interfaceService interface service
* @param intentSynchronizer intent synchronization service
*/
public ReactiveRoutingFib(ApplicationId appId, HostService hostService,
- RoutingConfigurationService configService,
InterfaceService interfaceService,
IntentSynchronizationService intentSynchronizer) {
this.appId = appId;
this.hostService = hostService;
- this.configService = configService;
this.interfaceService = interfaceService;
this.intentSynchronizer = intentSynchronizer;
@@ -95,8 +92,6 @@
@Override
public void setUpConnectivityInternetToHost(IpAddress hostIpAddress) {
checkNotNull(hostIpAddress);
- Set<ConnectPoint> ingressPoints =
- configService.getBgpPeerConnectPoints();
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
@@ -130,6 +125,24 @@
Key key = Key.of(ipPrefix.toString(), appId);
int priority = ipPrefix.prefixLength() * PRIORITY_MULTIPLIER
+ PRIORITY_OFFSET;
+
+ Set<ConnectPoint> interfaceConnectPoints =
+ interfaceService.getInterfaces().stream()
+ .map(intf -> intf.connectPoint()).collect(Collectors.toSet());
+
+ if (interfaceConnectPoints.isEmpty()) {
+ log.error("The interface connect points are empty!");
+ return;
+ }
+
+ Set<ConnectPoint> ingressPoints = new HashSet<>();
+
+ for (ConnectPoint connectPoint : interfaceConnectPoints) {
+ if (!connectPoint.equals(egressPoint)) {
+ ingressPoints.add(connectPoint);
+ }
+ }
+
MultiPointToSinglePointIntent intent =
MultiPointToSinglePointIntent.builder()
.appId(appId)
@@ -150,7 +163,8 @@
public void setUpConnectivityHostToInternet(IpAddress hostIp, IpPrefix prefix,
IpAddress nextHopIpAddress) {
// Find the attachment point (egress interface) of the next hop
- Interface egressInterface = interfaceService.getMatchingInterface(nextHopIpAddress);
+ Interface egressInterface =
+ interfaceService.getMatchingInterface(nextHopIpAddress);
if (egressInterface == null) {
log.warn("No outgoing interface found for {}",
nextHopIpAddress);
diff --git a/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/SdnIpReactiveRouting.java b/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/SdnIpReactiveRouting.java
index ffbdf10..a18e263 100644
--- a/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/SdnIpReactiveRouting.java
+++ b/apps/reactive-routing/src/main/java/org/onosproject/reactive/routing/SdnIpReactiveRouting.java
@@ -15,6 +15,16 @@
*/
package org.onosproject.reactive.routing;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.packet.Ethernet.TYPE_ARP;
+import static org.onlab.packet.Ethernet.TYPE_IPV4;
+import static org.onosproject.net.packet.PacketPriority.REACTIVE;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.nio.ByteBuffer;
+import java.util.Optional;
+import java.util.Set;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -53,16 +63,6 @@
import org.onosproject.routing.config.RoutingConfigurationService;
import org.slf4j.Logger;
-import java.nio.ByteBuffer;
-import java.util.Optional;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.packet.Ethernet.TYPE_ARP;
-import static org.onlab.packet.Ethernet.TYPE_IPV4;
-import static org.onosproject.net.packet.PacketPriority.REACTIVE;
-import static org.slf4j.LoggerFactory.getLogger;
-
/**
* This is reactive routing to handle 3 cases:
* (1) one host wants to talk to another host, both two hosts are in
@@ -107,9 +107,8 @@
@Activate
public void activate() {
appId = coreService.registerApplication(APP_NAME);
-
intentRequestListener = new ReactiveRoutingFib(appId, hostService,
- config, interfaceService, intentSynchronizer);
+ interfaceService, intentSynchronizer);
packetService.addProcessor(processor, PacketProcessor.director(2));
requestIntercepts();
@@ -300,23 +299,26 @@
* @return the traffic type which this packet belongs to
*/
private TrafficType trafficTypeClassifier(ConnectPoint srcConnectPoint,
- IpAddress dstIp) {
+ IpAddress dstIp) {
LocationType dstIpLocationType = getLocationType(dstIp);
Optional<Interface> srcInterface =
interfaceService.getInterfacesByPort(srcConnectPoint).stream().findFirst();
- Set<ConnectPoint> ingressPoints = config.getBgpPeerConnectPoints();
+
+ Set<ConnectPoint> bgpPeerConnectPoints = config.getBgpPeerConnectPoints();
+
+
switch (dstIpLocationType) {
case INTERNET:
if (srcInterface.isPresent() &&
- (!ingressPoints.contains(srcConnectPoint))) {
+ (!bgpPeerConnectPoints.contains(srcConnectPoint))) {
return TrafficType.HOST_TO_INTERNET;
} else {
return TrafficType.INTERNET_TO_INTERNET;
}
case LOCAL:
if (srcInterface.isPresent() &&
- (!ingressPoints.contains(srcConnectPoint))) {
+ (!bgpPeerConnectPoints.contains(srcConnectPoint))) {
return TrafficType.HOST_TO_HOST;
} else {
// TODO Currently we only consider local public prefixes.
@@ -394,6 +396,5 @@
packetService.emit(packet);
log.trace("sending packet: {}", packet);
}
-
}