Jayasree Ghosh
Committed by Charles Chan

ONOS-4635:Fix Issue with add flows using flowobjective-forward REST API with incorrect priority

cherry-picked from https://gerrit.onosproject.org/#/c/9815/

Change-Id: I9637c6c0fa6906146fe6d60403c1b540b3e5531c
...@@ -272,6 +272,8 @@ public final class DefaultFilteringObjective implements FilteringObjective { ...@@ -272,6 +272,8 @@ public final class DefaultFilteringObjective implements FilteringObjective {
272 checkNotNull(type, "Must have a type."); 272 checkNotNull(type, "Must have a type.");
273 checkArgument(!conditions.isEmpty(), "Must have at least one condition."); 273 checkArgument(!conditions.isEmpty(), "Must have at least one condition.");
274 checkNotNull(appId, "Must supply an application id"); 274 checkNotNull(appId, "Must supply an application id");
275 + checkArgument(priority <= MAX_PRIORITY && priority >= MIN_PRIORITY, "Priority " +
276 + "out of range");
275 277
276 return new DefaultFilteringObjective(this); 278 return new DefaultFilteringObjective(this);
277 } 279 }
......
...@@ -284,6 +284,8 @@ public final class DefaultForwardingObjective implements ForwardingObjective { ...@@ -284,6 +284,8 @@ public final class DefaultForwardingObjective implements ForwardingObjective {
284 "least a treatment and/or a nextId"); 284 "least a treatment and/or a nextId");
285 checkNotNull(appId, "Must supply an application id"); 285 checkNotNull(appId, "Must supply an application id");
286 op = Operation.ADD; 286 op = Operation.ADD;
287 + checkArgument(priority <= MAX_PRIORITY && priority >= MIN_PRIORITY, "Priority " +
288 + "out of range");
287 return new DefaultForwardingObjective(this); 289 return new DefaultForwardingObjective(this);
288 } 290 }
289 291
......
...@@ -29,6 +29,8 @@ public interface Objective { ...@@ -29,6 +29,8 @@ public interface Objective {
29 boolean DEFAULT_PERMANENT = true; 29 boolean DEFAULT_PERMANENT = true;
30 int DEFAULT_TIMEOUT = 0; 30 int DEFAULT_TIMEOUT = 0;
31 int DEFAULT_PRIORITY = 32768; 31 int DEFAULT_PRIORITY = 32768;
32 + int MIN_PRIORITY = 0;
33 + int MAX_PRIORITY = 65535;
32 34
33 /** 35 /**
34 * Type of operation. 36 * Type of operation.
......