Fix for the Issue - flow rules greater than max-priority ONOS-4613 .
Change-Id: I3bb873b9a263f77ff7c687cbe3506f49b1d72c1c
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 e5d0231..d2cf76a 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
@@ -101,10 +101,10 @@
ApplicationId appId, int timeout, boolean permanent,
FlowRuleExtPayLoad payLoad) {
- if (priority < FlowRule.MIN_PRIORITY) {
- throw new IllegalArgumentException("Priority cannot be less than "
- + MIN_PRIORITY);
- }
+ checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " +
+ MIN_PRIORITY);
+ checkArgument(priority <= MAX_PRIORITY, "Priority cannot be greater than " +
+ MAX_PRIORITY);
this.deviceId = deviceId;
this.priority = priority;
@@ -148,10 +148,10 @@
ApplicationId appId, GroupId groupId, int timeout,
boolean permanent, FlowRuleExtPayLoad payLoad) {
- if (priority < FlowRule.MIN_PRIORITY) {
- throw new IllegalArgumentException("Priority cannot be less than "
- + MIN_PRIORITY);
- }
+ checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " +
+ MIN_PRIORITY);
+ checkArgument(priority <= MAX_PRIORITY, "Priority cannot be greater than " +
+ MAX_PRIORITY);
this.deviceId = deviceId;
this.priority = priority;
@@ -373,6 +373,8 @@
checkNotNull(priority, "Priority cannot be null");
checkArgument(priority >= MIN_PRIORITY, "Priority cannot be less than " +
MIN_PRIORITY);
+ checkArgument(priority <= MAX_PRIORITY, "Priority cannot be greater than " +
+ MAX_PRIORITY);
// Computing a flow ID based on appId takes precedence over setting
// the flow ID directly
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
index 35d45fb..ddbc1db 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
@@ -27,7 +27,7 @@
int MAX_TIMEOUT = 60;
int MIN_PRIORITY = 0;
-
+ int MAX_PRIORITY = 65535;
/**
* Returns the ID of this flow.
*