aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java46
1 files changed, 27 insertions, 19 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 5d18a9ad..a628725c 100644
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -31,7 +31,6 @@ import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
import org.onosproject.net.meter.MeterId;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -51,7 +50,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
private final boolean hasClear;
private static final DefaultTrafficTreatment EMPTY
- = new DefaultTrafficTreatment(Collections.emptyList());
+ = new DefaultTrafficTreatment(ImmutableList.of(Instructions.createNoAction()));
private final Instructions.MeterInstruction meter;
/**
@@ -212,8 +211,6 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
List<Instruction> current = immediate;
-
-
// Creates a new builder
private Builder() {
}
@@ -224,7 +221,10 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
treatment.deferred().forEach(i -> add(i));
immediate();
- treatment.immediate().forEach(i -> add(i));
+ treatment.immediate().stream()
+ // NOACTION will get re-added if there are no other actions
+ .filter(i -> i.type() != Instruction.Type.NOACTION)
+ .forEach(i -> add(i));
clear = treatment.clearedDeferred();
}
@@ -234,6 +234,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
switch (instruction.type()) {
case DROP:
+ case NOACTION:
case OUTPUT:
case GROUP:
case L0MODIFICATION:
@@ -250,6 +251,7 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
break;
case METER:
meter = (Instructions.MeterInstruction) instruction;
+ break;
default:
throw new IllegalArgumentException("Unknown instruction type: " +
instruction.type());
@@ -258,9 +260,23 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
return this;
}
+ /**
+ * Add a NOACTION when DROP instruction is explicitly specified.
+ *
+ * @return the traffic treatment builder
+ */
@Override
public Builder drop() {
- return add(Instructions.createDrop());
+ return add(Instructions.createNoAction());
+ }
+
+ /**
+ * Add a NOACTION when no instruction is specified.
+ *
+ * @return the traffic treatment builder
+ */
+ private Builder noAction() {
+ return add(Instructions.createNoAction());
}
@Override
@@ -380,11 +396,6 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
}
@Override
- public Builder transition(FlowRule.Type type) {
- return add(Instructions.transition(type.ordinal()));
- }
-
- @Override
public Builder transition(Integer tableId) {
return add(Instructions.transition(tableId));
}
@@ -463,14 +474,11 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
@Override
public TrafficTreatment build() {
- //Don't add DROP instruction by default when instruction
- //set is empty. This will be handled in DefaultSingleTablePipeline
- //driver.
-
- //if (deferred.size() == 0 && immediate.size() == 0
- // && table == null && !clear) {
- // drop();
- //}
+ if (deferred.size() == 0 && immediate.size() == 0
+ && table == null && !clear) {
+ immediate();
+ noAction();
+ }
return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter);
}