Adding DROP rule for failed intents + changing netconfig imports from incubator
Change-Id: I95c0b8cdc51921c8b2c7e8f571d8b28251543f13
diff --git a/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java b/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java
index cc813d3..8f4c980 100644
--- a/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java
+++ b/ifwd/src/main/java/org/onosproject/ifwd/IntentReactiveForwarding.java
@@ -31,6 +31,9 @@
import org.onosproject.net.flow.FlowRuleService;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flowobjective.DefaultForwardingObjective;
+import org.onosproject.net.flowobjective.FlowObjectiveService;
+import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.host.HostService;
import org.onosproject.net.intent.HostToHostIntent;
import org.onosproject.net.intent.IntentService;
@@ -76,9 +79,14 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected FlowRuleService flowRuleService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected FlowObjectiveService flowObjectiveService;
+
private ReactivePacketProcessor processor = new ReactivePacketProcessor();
private ApplicationId appId;
+ private static final int DROP_RULE_TIMEOUT = 300;
+
private static final EnumSet<IntentState> WITHDRAWN_STATES = EnumSet.of(IntentState.WITHDRAWN,
IntentState.WITHDRAWING,
IntentState.WITHDRAW_REQ);
@@ -115,7 +123,6 @@
if (context.isHandled()) {
return;
}
-
InboundPacket pkt = context.inPacket();
Ethernet ethPkt = pkt.parsed();
@@ -175,8 +182,41 @@
key = Key.of(dstId.toString() + srcId.toString(), appId);
}
+ HostToHostIntent intent = (HostToHostIntent) intentService.getIntent(key);
// TODO handle the FAILED state
- if (intentService.getIntent(key) == null || WITHDRAWN_STATES.contains(intentService.getIntentState(key))) {
+ if (intent != null) {
+ if (WITHDRAWN_STATES.contains(intentService.getIntentState(key))) {
+ HostToHostIntent hostIntent = HostToHostIntent.builder()
+ .appId(appId)
+ .key(key)
+ .one(srcId)
+ .two(dstId)
+ .selector(selector)
+ .treatment(treatment)
+ .build();
+
+ intentService.submit(hostIntent);
+ } else if (intentService.getIntentState(key) == IntentState.FAILED) {
+
+ TrafficSelector objectiveSelector = DefaultTrafficSelector.builder()
+ .matchEthSrc(srcId.mac()).matchEthDst(dstId.mac()).build();
+
+ TrafficTreatment dropTreatment = DefaultTrafficTreatment.builder()
+ .drop().build();
+
+ ForwardingObjective objective = DefaultForwardingObjective.builder()
+ .withSelector(objectiveSelector)
+ .withTreatment(dropTreatment)
+ .fromApp(appId)
+ .withPriority(intent.priority() - 1)
+ .makeTemporary(DROP_RULE_TIMEOUT)
+ .withFlag(ForwardingObjective.Flag.VERSATILE)
+ .add();
+
+ flowObjectiveService.forward(context.outPacket().sendThrough(), objective);
+ }
+
+ } else if (intent == null) {
HostToHostIntent hostIntent = HostToHostIntent.builder()
.appId(appId)
.key(key)
@@ -188,6 +228,7 @@
intentService.submit(hostIntent);
}
+
}
}
diff --git a/onos-app-dhcpserver/pom.xml b/onos-app-dhcpserver/pom.xml
index 0272eee..9a60df2 100644
--- a/onos-app-dhcpserver/pom.xml
+++ b/onos-app-dhcpserver/pom.xml
@@ -76,13 +76,6 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-incubator-api</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPConfig.java b/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPConfig.java
index 16fcdd7..f57ff3a 100644
--- a/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPConfig.java
+++ b/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPConfig.java
@@ -16,7 +16,7 @@
package org.onosproject.dhcpserver.impl;
import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.config.Config;
+import org.onosproject.net.config.Config;
import org.onosproject.incubator.net.config.basics.BasicElementConfig;
/**
diff --git a/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPManager.java b/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPManager.java
index ccb9e67..96bb4c3 100644
--- a/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPManager.java
+++ b/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPManager.java
@@ -36,10 +36,11 @@
import org.onosproject.core.CoreService;
import org.onosproject.dhcpserver.DHCPService;
import org.onosproject.dhcpserver.DHCPStore;
-import org.onosproject.incubator.net.config.ConfigFactory;
-import org.onosproject.incubator.net.config.NetworkConfigEvent;
-import org.onosproject.incubator.net.config.NetworkConfigListener;
-import org.onosproject.incubator.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
+
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
diff --git a/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPStoreConfig.java b/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPStoreConfig.java
index edc389c..999527f 100644
--- a/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPStoreConfig.java
+++ b/onos-app-dhcpserver/src/main/java/org/onosproject/dhcpserver/impl/DHCPStoreConfig.java
@@ -16,7 +16,7 @@
package org.onosproject.dhcpserver.impl;
import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.config.Config;
+import org.onosproject.net.config.Config;
import org.onosproject.incubator.net.config.basics.BasicElementConfig;
/**
diff --git a/onos-app-dhcpserver/src/test/java/org/onosproject/dhcpserver/impl/DHCPManagerTest.java b/onos-app-dhcpserver/src/test/java/org/onosproject/dhcpserver/impl/DHCPManagerTest.java
index 0807653..12baf7a 100644
--- a/onos-app-dhcpserver/src/test/java/org/onosproject/dhcpserver/impl/DHCPManagerTest.java
+++ b/onos-app-dhcpserver/src/test/java/org/onosproject/dhcpserver/impl/DHCPManagerTest.java
@@ -28,7 +28,7 @@
import org.onlab.packet.UDP;
import org.onosproject.core.CoreServiceAdapter;
import org.onosproject.dhcpserver.DHCPStore;
-import org.onosproject.incubator.net.config.NetworkConfigRegistryAdapter;
+import org.onosproject.net.config.NetworkConfigRegistryAdapter;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.host.HostDescription;