ONOS-4635:Fix Issue with add flows using flowobjective-forward REST API with incorrect priority
Change-Id: I929918b61aec83c2dc2cdca456dfdb1d2d736c01
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java
index 83c8d1f..e28131a 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultFilteringObjective.java
@@ -272,6 +272,8 @@
checkNotNull(type, "Must have a type.");
checkArgument(!conditions.isEmpty(), "Must have at least one condition.");
checkNotNull(appId, "Must supply an application id");
+ checkArgument(priority <= MAX_PRIORITY && priority >= MIN_PRIORITY, "Priority " +
+ "out of range");
return new DefaultFilteringObjective(this);
}
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
index fd08fd4..5796f24 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/DefaultForwardingObjective.java
@@ -266,6 +266,8 @@
checkArgument(nextId != null || treatment != null, "Must supply at " +
"least a treatment and/or a nextId");
checkNotNull(appId, "Must supply an application id");
+ checkArgument(priority <= MAX_PRIORITY && priority >= MIN_PRIORITY, "Priority " +
+ "out of range");
op = Operation.ADD;
return new DefaultForwardingObjective(this);
}
diff --git a/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java b/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
index eb1e106..7c0af50 100644
--- a/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
+++ b/core/api/src/main/java/org/onosproject/net/flowobjective/Objective.java
@@ -29,6 +29,8 @@
boolean DEFAULT_PERMANENT = true;
int DEFAULT_TIMEOUT = 0;
int DEFAULT_PRIORITY = 32768;
+ int MIN_PRIORITY = 0;
+ int MAX_PRIORITY = 65535;
/**
* Type of operation.