Adding support to remove a subscriber.
And fixing an issue where build on a flowrule could not be
called repeatedly.
Change-Id: I85773ac7a3fb4f2970b63599d1eafbfc8b3c5879
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
index b8645fe..b8605f1 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
@@ -364,6 +364,7 @@
@Override
public FlowRule build() {
+ FlowId localFlowId;
checkArgument((flowId != null) ^ (appId != null), "Either an application" +
" id or a cookie must be supplied");
checkNotNull(selector, "Traffic selector cannot be null");
@@ -377,11 +378,13 @@
// Computing a flow ID based on appId takes precedence over setting
// the flow ID directly
if (appId != null) {
- flowId = computeFlowId(appId);
+ localFlowId = computeFlowId(appId);
+ } else {
+ localFlowId = flowId;
}
return new DefaultFlowRule(deviceId, selector, treatment, priority,
- flowId, permanent, timeout, tableId);
+ localFlowId, permanent, timeout, tableId);
}
private FlowId computeFlowId(ApplicationId appId) {
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/OltPipeline.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/OltPipeline.java
index e8b4411..0139573 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/OltPipeline.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/OltPipeline.java
@@ -38,7 +38,6 @@
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleOperations;
import org.onosproject.net.flow.FlowRuleOperationsContext;
@@ -579,12 +578,7 @@
builder.add(inner.build()).add(outer.build());
break;
case REMOVE:
- Iterable<FlowEntry> flows = flowRuleService.getFlowEntries(deviceId);
- for (FlowEntry fe : flows) {
- if (fe.equals(inner.build()) || fe.equals(outer.build())) {
- builder.remove(fe);
- }
- }
+ builder.remove(inner.build()).remove(outer.build());
break;
case ADD_TO_EXISTING:
break;