Committed by
Gerrit Code Review
[ONOS-4228]Parase and set priority for sfc classification
Change-Id: I0e25465d47ad1bd6c6035ff309ef631b8ef7c75e
Showing
9 changed files
with
92 additions
and
24 deletions
... | @@ -223,19 +223,19 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -223,19 +223,19 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
223 | // Send the packet to controller | 223 | // Send the packet to controller |
224 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); | 224 | TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
225 | treatment.setOutput(PortNumber.CONTROLLER); | 225 | treatment.setOutput(PortNumber.CONTROLLER); |
226 | - sendServiceFunctionClassifier(selector, treatment, deviceId, type); | 226 | + sendServiceFunctionClassifier(selector, treatment, deviceId, type, flowClassifier.priority()); |
227 | } else if (deviceId.equals(deviceIdfromPortPair)) { | 227 | } else if (deviceId.equals(deviceIdfromPortPair)) { |
228 | // classifier and source device are in the same OVS. So directly send packet to first port pair | 228 | // classifier and source device are in the same OVS. So directly send packet to first port pair |
229 | TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, | 229 | TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, |
230 | nshSpiId, flowClassifier, true); | 230 | nshSpiId, flowClassifier, true); |
231 | // Build forwarding objective and send to OVS. | 231 | // Build forwarding objective and send to OVS. |
232 | - sendServiceFunctionClassifier(selector, treatment, deviceId, type); | 232 | + sendServiceFunctionClassifier(selector, treatment, deviceId, type, flowClassifier.priority()); |
233 | } else { | 233 | } else { |
234 | // classifier and source device are not in the same OVS. Send packet on vlan Tunnel | 234 | // classifier and source device are not in the same OVS. Send packet on vlan Tunnel |
235 | TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, | 235 | TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, |
236 | nshSpiId, flowClassifier, false); | 236 | nshSpiId, flowClassifier, false); |
237 | // Build forwarding objective and send to OVS. | 237 | // Build forwarding objective and send to OVS. |
238 | - sendServiceFunctionClassifier(selector, treatment, deviceId, type); | 238 | + sendServiceFunctionClassifier(selector, treatment, deviceId, type, flowClassifier.priority()); |
239 | 239 | ||
240 | // At the other device get the packet from vlan and send to first port pair | 240 | // At the other device get the packet from vlan and send to first port pair |
241 | TrafficSelector.Builder selectorDst = DefaultTrafficSelector.builder(); | 241 | TrafficSelector.Builder selectorDst = DefaultTrafficSelector.builder(); |
... | @@ -244,7 +244,8 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -244,7 +244,8 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
244 | TrafficTreatment.Builder treatmentDst = DefaultTrafficTreatment.builder(); | 244 | TrafficTreatment.Builder treatmentDst = DefaultTrafficTreatment.builder(); |
245 | Host hostDst = hostService.getHost(HostId.hostId(srcMacAddress)); | 245 | Host hostDst = hostService.getHost(HostId.hostId(srcMacAddress)); |
246 | treatmentDst.setOutput(hostDst.location().port()); | 246 | treatmentDst.setOutput(hostDst.location().port()); |
247 | - sendServiceFunctionClassifier(selectorDst, treatmentDst, deviceIdfromPortPair, type); | 247 | + sendServiceFunctionClassifier(selectorDst, treatmentDst, deviceIdfromPortPair, type, |
248 | + flowClassifier.priority()); | ||
248 | } | 249 | } |
249 | } | 250 | } |
250 | return host.location(); | 251 | return host.location(); |
... | @@ -383,14 +384,15 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -383,14 +384,15 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
383 | * @param treatment traffic treatment | 384 | * @param treatment traffic treatment |
384 | * @param deviceId device id | 385 | * @param deviceId device id |
385 | * @param type operation type | 386 | * @param type operation type |
387 | + * @param priority priority of classifier | ||
386 | */ | 388 | */ |
387 | public void sendServiceFunctionClassifier(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, | 389 | public void sendServiceFunctionClassifier(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, |
388 | - DeviceId deviceId, Objective.Operation type) { | 390 | + DeviceId deviceId, Objective.Operation type, int priority) { |
389 | log.info("Sending flow to service function classifier. Selector {}, Treatment {}", | 391 | log.info("Sending flow to service function classifier. Selector {}, Treatment {}", |
390 | selector.toString(), treatment.toString()); | 392 | selector.toString(), treatment.toString()); |
391 | ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) | 393 | ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) |
392 | .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE) | 394 | .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE) |
393 | - .withPriority(FLOW_CLASSIFIER_PRIORITY); | 395 | + .withPriority(priority); |
394 | 396 | ||
395 | if (type.equals(Objective.Operation.ADD)) { | 397 | if (type.equals(Objective.Operation.ADD)) { |
396 | log.debug("flowClassifierRules-->ADD"); | 398 | log.debug("flowClassifierRules-->ADD"); | ... | ... |
... | @@ -34,6 +34,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -34,6 +34,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
34 | private final String description; | 34 | private final String description; |
35 | private final String etherType; | 35 | private final String etherType; |
36 | private final String protocol; | 36 | private final String protocol; |
37 | + private final int priority; | ||
37 | private final int minSrcPortRange; | 38 | private final int minSrcPortRange; |
38 | private final int maxSrcPortRange; | 39 | private final int maxSrcPortRange; |
39 | private final int minDstPortRange; | 40 | private final int minDstPortRange; |
... | @@ -47,6 +48,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -47,6 +48,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
47 | private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null."; | 48 | private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null."; |
48 | private static final String NAME_NOT_NULL = "Name can not be null."; | 49 | private static final String NAME_NOT_NULL = "Name can not be null."; |
49 | private static final String ETHER_TYPE_NOT_NULL = "Ether Type can not be null."; | 50 | private static final String ETHER_TYPE_NOT_NULL = "Ether Type can not be null."; |
51 | + private static final int DEFAULT_CLASSIFIER_PRIORITY = 0xFFFF; | ||
50 | 52 | ||
51 | /** | 53 | /** |
52 | * Constructor to create default flow classifier. | 54 | * Constructor to create default flow classifier. |
... | @@ -57,6 +59,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -57,6 +59,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
57 | * @param description flow classifier description | 59 | * @param description flow classifier description |
58 | * @param etherType etherType | 60 | * @param etherType etherType |
59 | * @param protocol IP protocol | 61 | * @param protocol IP protocol |
62 | + * @param priority priority for classification | ||
60 | * @param minSrcPortRange Minimum Source port range | 63 | * @param minSrcPortRange Minimum Source port range |
61 | * @param maxSrcPortRange Maximum Source port range | 64 | * @param maxSrcPortRange Maximum Source port range |
62 | * @param minDstPortRange Minimum destination port range | 65 | * @param minDstPortRange Minimum destination port range |
... | @@ -67,15 +70,17 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -67,15 +70,17 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
67 | * @param dstPort destination VirtualPort | 70 | * @param dstPort destination VirtualPort |
68 | */ | 71 | */ |
69 | private DefaultFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name, | 72 | private DefaultFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name, |
70 | - String description, String etherType, String protocol, int minSrcPortRange, int maxSrcPortRange, | 73 | + String description, String etherType, String protocol, int priority, |
71 | - int minDstPortRange, int maxDstPortRange, IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, | 74 | + int minSrcPortRange, int maxSrcPortRange, int minDstPortRange, int maxDstPortRange, |
72 | - VirtualPortId srcPort, VirtualPortId dstPort) { | 75 | + IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, VirtualPortId srcPort, |
76 | + VirtualPortId dstPort) { | ||
73 | this.flowClassifierId = flowClassifierId; | 77 | this.flowClassifierId = flowClassifierId; |
74 | this.tenantId = tenantId; | 78 | this.tenantId = tenantId; |
75 | this.name = name; | 79 | this.name = name; |
76 | this.description = description; | 80 | this.description = description; |
77 | this.etherType = etherType; | 81 | this.etherType = etherType; |
78 | this.protocol = protocol; | 82 | this.protocol = protocol; |
83 | + this.priority = priority; | ||
79 | this.minSrcPortRange = minSrcPortRange; | 84 | this.minSrcPortRange = minSrcPortRange; |
80 | this.maxSrcPortRange = maxSrcPortRange; | 85 | this.maxSrcPortRange = maxSrcPortRange; |
81 | this.minDstPortRange = minDstPortRange; | 86 | this.minDstPortRange = minDstPortRange; |
... | @@ -117,6 +122,11 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -117,6 +122,11 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
117 | } | 122 | } |
118 | 123 | ||
119 | @Override | 124 | @Override |
125 | + public int priority() { | ||
126 | + return priority; | ||
127 | + } | ||
128 | + | ||
129 | + @Override | ||
120 | public int minSrcPortRange() { | 130 | public int minSrcPortRange() { |
121 | return minSrcPortRange; | 131 | return minSrcPortRange; |
122 | } | 132 | } |
... | @@ -169,6 +179,8 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -169,6 +179,8 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
169 | private String etherType; | 179 | private String etherType; |
170 | private String protocol; | 180 | private String protocol; |
171 | private boolean isProtocolSet = false; | 181 | private boolean isProtocolSet = false; |
182 | + private int priority; | ||
183 | + private boolean isPrioritySet = false; | ||
172 | private int minSrcPortRange; | 184 | private int minSrcPortRange; |
173 | private boolean isMinSrcPortRangeSet = false; | 185 | private boolean isMinSrcPortRangeSet = false; |
174 | private int maxSrcPortRange; | 186 | private int maxSrcPortRange; |
... | @@ -195,6 +207,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -195,6 +207,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
195 | checkNotNull(etherType, ETHER_TYPE_NOT_NULL); | 207 | checkNotNull(etherType, ETHER_TYPE_NOT_NULL); |
196 | String description = null; | 208 | String description = null; |
197 | String protocol = null; | 209 | String protocol = null; |
210 | + int priority = DEFAULT_CLASSIFIER_PRIORITY; | ||
198 | int minSrcPortRange = NULL_PORT; | 211 | int minSrcPortRange = NULL_PORT; |
199 | int maxSrcPortRange = NULL_PORT; | 212 | int maxSrcPortRange = NULL_PORT; |
200 | int minDstPortRange = NULL_PORT; | 213 | int minDstPortRange = NULL_PORT; |
... | @@ -210,6 +223,9 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -210,6 +223,9 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
210 | if (isProtocolSet) { | 223 | if (isProtocolSet) { |
211 | protocol = this.protocol; | 224 | protocol = this.protocol; |
212 | } | 225 | } |
226 | + if (isPrioritySet) { | ||
227 | + priority = this.priority; | ||
228 | + } | ||
213 | if (isMinSrcPortRangeSet) { | 229 | if (isMinSrcPortRangeSet) { |
214 | minSrcPortRange = this.minSrcPortRange; | 230 | minSrcPortRange = this.minSrcPortRange; |
215 | } | 231 | } |
... | @@ -236,8 +252,8 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -236,8 +252,8 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
236 | } | 252 | } |
237 | 253 | ||
238 | return new DefaultFlowClassifier(flowClassifierId, tenantId, name, description, etherType, protocol, | 254 | return new DefaultFlowClassifier(flowClassifierId, tenantId, name, description, etherType, protocol, |
239 | - minSrcPortRange, maxSrcPortRange, minDstPortRange, maxDstPortRange, srcIpPrefix, dstIpPrefix, | 255 | + priority, minSrcPortRange, maxSrcPortRange, minDstPortRange, |
240 | - srcPort, dstPort); | 256 | + maxDstPortRange, srcIpPrefix, dstIpPrefix, srcPort, dstPort); |
241 | } | 257 | } |
242 | 258 | ||
243 | @Override | 259 | @Override |
... | @@ -279,6 +295,13 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -279,6 +295,13 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
279 | } | 295 | } |
280 | 296 | ||
281 | @Override | 297 | @Override |
298 | + public Builder setPriority(int priority) { | ||
299 | + this.priority = priority; | ||
300 | + this.isPrioritySet = true; | ||
301 | + return this; | ||
302 | + } | ||
303 | + | ||
304 | + @Override | ||
282 | public Builder setMinSrcPortRange(int minSrcPortRange) { | 305 | public Builder setMinSrcPortRange(int minSrcPortRange) { |
283 | this.minSrcPortRange = minSrcPortRange; | 306 | this.minSrcPortRange = minSrcPortRange; |
284 | this.isMinSrcPortRangeSet = true; | 307 | this.isMinSrcPortRangeSet = true; |
... | @@ -354,6 +377,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -354,6 +377,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
354 | && Objects.equals(this.description, other.description) | 377 | && Objects.equals(this.description, other.description) |
355 | && Objects.equals(this.etherType, other.etherType) | 378 | && Objects.equals(this.etherType, other.etherType) |
356 | && Objects.equals(this.protocol, other.protocol) | 379 | && Objects.equals(this.protocol, other.protocol) |
380 | + && Objects.equals(this.priority, other.priority) | ||
357 | && Objects.equals(this.minSrcPortRange, other.minSrcPortRange) | 381 | && Objects.equals(this.minSrcPortRange, other.minSrcPortRange) |
358 | && Objects.equals(this.maxSrcPortRange, other.maxSrcPortRange) | 382 | && Objects.equals(this.maxSrcPortRange, other.maxSrcPortRange) |
359 | && Objects.equals(this.minDstPortRange, other.minDstPortRange) | 383 | && Objects.equals(this.minDstPortRange, other.minDstPortRange) |
... | @@ -375,6 +399,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -375,6 +399,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
375 | && Objects.equals(this.description, flowClassifier.description()) | 399 | && Objects.equals(this.description, flowClassifier.description()) |
376 | && Objects.equals(this.etherType, flowClassifier.etherType()) | 400 | && Objects.equals(this.etherType, flowClassifier.etherType()) |
377 | && Objects.equals(this.protocol, flowClassifier.protocol()) | 401 | && Objects.equals(this.protocol, flowClassifier.protocol()) |
402 | + && Objects.equals(this.priority, flowClassifier.priority()) | ||
378 | && Objects.equals(this.minSrcPortRange, flowClassifier.minSrcPortRange()) | 403 | && Objects.equals(this.minSrcPortRange, flowClassifier.minSrcPortRange()) |
379 | && Objects.equals(this.maxSrcPortRange, flowClassifier.maxSrcPortRange()) | 404 | && Objects.equals(this.maxSrcPortRange, flowClassifier.maxSrcPortRange()) |
380 | && Objects.equals(this.minDstPortRange, flowClassifier.minDstPortRange()) | 405 | && Objects.equals(this.minDstPortRange, flowClassifier.minDstPortRange()) |
... | @@ -394,6 +419,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { | ... | @@ -394,6 +419,7 @@ public final class DefaultFlowClassifier implements FlowClassifier { |
394 | .add("Description", description) | 419 | .add("Description", description) |
395 | .add("String", etherType) | 420 | .add("String", etherType) |
396 | .add("Protocol", protocol) | 421 | .add("Protocol", protocol) |
422 | + .add("Priority", priority) | ||
397 | .add("MinSrcPortRange", minSrcPortRange) | 423 | .add("MinSrcPortRange", minSrcPortRange) |
398 | .add("MaxSrcPortRange", maxSrcPortRange) | 424 | .add("MaxSrcPortRange", maxSrcPortRange) |
399 | .add("MinDstPortRange", minDstPortRange) | 425 | .add("MinDstPortRange", minDstPortRange) | ... | ... |
... | @@ -68,6 +68,13 @@ public interface FlowClassifier { | ... | @@ -68,6 +68,13 @@ public interface FlowClassifier { |
68 | String protocol(); | 68 | String protocol(); |
69 | 69 | ||
70 | /** | 70 | /** |
71 | + * Returns priority. | ||
72 | + * | ||
73 | + * @return priority | ||
74 | + */ | ||
75 | + int priority(); | ||
76 | + | ||
77 | + /** | ||
71 | * Returns minimum source port range. | 78 | * Returns minimum source port range. |
72 | * | 79 | * |
73 | * @return minimum source port range | 80 | * @return minimum source port range |
... | @@ -193,6 +200,14 @@ public interface FlowClassifier { | ... | @@ -193,6 +200,14 @@ public interface FlowClassifier { |
193 | Builder setProtocol(String protocol); | 200 | Builder setProtocol(String protocol); |
194 | 201 | ||
195 | /** | 202 | /** |
203 | + * Sets priority. | ||
204 | + * | ||
205 | + * @param priority priority | ||
206 | + * @return builder object by setting priority | ||
207 | + */ | ||
208 | + Builder setPriority(int priority); | ||
209 | + | ||
210 | + /** | ||
196 | * Set minimum source port range. | 211 | * Set minimum source port range. |
197 | * | 212 | * |
198 | * @param minRange minimum source port range | 213 | * @param minRange minimum source port range | ... | ... |
... | @@ -46,6 +46,7 @@ public class DefaultFlowClassifierTest { | ... | @@ -46,6 +46,7 @@ public class DefaultFlowClassifierTest { |
46 | final String description = "FlowClassifier1"; | 46 | final String description = "FlowClassifier1"; |
47 | final String ethType = "IPv4"; | 47 | final String ethType = "IPv4"; |
48 | final String protocol = "tcp"; | 48 | final String protocol = "tcp"; |
49 | + final int priority = 65535; | ||
49 | final int minSrcPortRange = 5; | 50 | final int minSrcPortRange = 5; |
50 | final int maxSrcPortRange = 10; | 51 | final int maxSrcPortRange = 10; |
51 | final int minDstPortRange = 5; | 52 | final int minDstPortRange = 5; |
... | @@ -60,22 +61,25 @@ public class DefaultFlowClassifierTest { | ... | @@ -60,22 +61,25 @@ public class DefaultFlowClassifierTest { |
60 | DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder(); | 61 | DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder(); |
61 | final FlowClassifier flowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) | 62 | final FlowClassifier flowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) |
62 | .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) | 63 | .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) |
63 | - .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) | 64 | + .setProtocol(protocol).setPriority(priority).setMinSrcPortRange(minSrcPortRange) |
64 | - .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) | 65 | + .setMaxSrcPortRange(maxSrcPortRange).setMinDstPortRange(minDstPortRange) |
65 | - .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); | 66 | + .setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix).setDstIpPrefix(dstIpPrefix) |
67 | + .setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); | ||
66 | 68 | ||
67 | flowClassifierBuilder = new DefaultFlowClassifier.Builder(); | 69 | flowClassifierBuilder = new DefaultFlowClassifier.Builder(); |
68 | final FlowClassifier sameAsFlowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) | 70 | final FlowClassifier sameAsFlowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) |
69 | .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) | 71 | .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) |
70 | - .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) | 72 | + .setProtocol(protocol).setPriority(priority).setMinSrcPortRange(minSrcPortRange) |
71 | - .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) | 73 | + .setMaxSrcPortRange(maxSrcPortRange).setMinDstPortRange(minDstPortRange) |
72 | - .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); | 74 | + .setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix).setDstIpPrefix(dstIpPrefix) |
75 | + .setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); | ||
73 | 76 | ||
74 | // Create different classifier object. | 77 | // Create different classifier object. |
75 | final String name2 = "FlowClassifier2"; | 78 | final String name2 = "FlowClassifier2"; |
76 | final String description2 = "FlowClassifier2"; | 79 | final String description2 = "FlowClassifier2"; |
77 | final String ethType2 = "IPv6"; | 80 | final String ethType2 = "IPv6"; |
78 | final String protocol2 = "udp"; | 81 | final String protocol2 = "udp"; |
82 | + final int priority2 = 50000; | ||
79 | final int minSrcPortRange2 = 5; | 83 | final int minSrcPortRange2 = 5; |
80 | final int maxSrcPortRange2 = 10; | 84 | final int maxSrcPortRange2 = 10; |
81 | final int minDstPortRange2 = 5; | 85 | final int minDstPortRange2 = 5; |
... | @@ -92,7 +96,8 @@ public class DefaultFlowClassifierTest { | ... | @@ -92,7 +96,8 @@ public class DefaultFlowClassifierTest { |
92 | .setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2) | 96 | .setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2) |
93 | .setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange2).setMaxSrcPortRange(maxSrcPortRange2) | 97 | .setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange2).setMaxSrcPortRange(maxSrcPortRange2) |
94 | .setMinDstPortRange(minDstPortRange2).setMaxDstPortRange(maxDstPortRange2).setSrcIpPrefix(srcIpPrefix2) | 98 | .setMinDstPortRange(minDstPortRange2).setMaxDstPortRange(maxDstPortRange2).setSrcIpPrefix(srcIpPrefix2) |
95 | - .setDstIpPrefix(dstIpPrefix2).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2).build(); | 99 | + .setDstIpPrefix(dstIpPrefix2).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2) |
100 | + .setPriority(priority2).build(); | ||
96 | 101 | ||
97 | new EqualsTester().addEqualityGroup(flowClassifier1, sameAsFlowClassifier1).addEqualityGroup(flowClassifier2) | 102 | new EqualsTester().addEqualityGroup(flowClassifier1, sameAsFlowClassifier1).addEqualityGroup(flowClassifier2) |
98 | .testEquals(); | 103 | .testEquals(); |
... | @@ -107,6 +112,7 @@ public class DefaultFlowClassifierTest { | ... | @@ -107,6 +112,7 @@ public class DefaultFlowClassifierTest { |
107 | final String description = "FlowClassifier"; | 112 | final String description = "FlowClassifier"; |
108 | final String ethType = "IPv4"; | 113 | final String ethType = "IPv4"; |
109 | final String protocol = "tcp"; | 114 | final String protocol = "tcp"; |
115 | + final int priority = 30000; | ||
110 | final int minSrcPortRange = 5; | 116 | final int minSrcPortRange = 5; |
111 | final int maxSrcPortRange = 10; | 117 | final int maxSrcPortRange = 10; |
112 | final int minDstPortRange = 5; | 118 | final int minDstPortRange = 5; |
... | @@ -123,7 +129,8 @@ public class DefaultFlowClassifierTest { | ... | @@ -123,7 +129,8 @@ public class DefaultFlowClassifierTest { |
123 | .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) | 129 | .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) |
124 | .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) | 130 | .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) |
125 | .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) | 131 | .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) |
126 | - .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); | 132 | + .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort) |
133 | + .setPriority(priority).build(); | ||
127 | 134 | ||
128 | assertThat(flowClassifierId, is(flowClassifier.flowClassifierId())); | 135 | assertThat(flowClassifierId, is(flowClassifier.flowClassifierId())); |
129 | assertThat(tenantId, is(flowClassifier.tenantId())); | 136 | assertThat(tenantId, is(flowClassifier.tenantId())); |
... | @@ -131,6 +138,7 @@ public class DefaultFlowClassifierTest { | ... | @@ -131,6 +138,7 @@ public class DefaultFlowClassifierTest { |
131 | assertThat(description, is(flowClassifier.description())); | 138 | assertThat(description, is(flowClassifier.description())); |
132 | assertThat(ethType, is(flowClassifier.etherType())); | 139 | assertThat(ethType, is(flowClassifier.etherType())); |
133 | assertThat(protocol, is(flowClassifier.protocol())); | 140 | assertThat(protocol, is(flowClassifier.protocol())); |
141 | + assertThat(priority, is(flowClassifier.priority())); | ||
134 | assertThat(minSrcPortRange, is(flowClassifier.minSrcPortRange())); | 142 | assertThat(minSrcPortRange, is(flowClassifier.minSrcPortRange())); |
135 | assertThat(maxSrcPortRange, is(flowClassifier.maxSrcPortRange())); | 143 | assertThat(maxSrcPortRange, is(flowClassifier.maxSrcPortRange())); |
136 | assertThat(minDstPortRange, is(flowClassifier.minDstPortRange())); | 144 | assertThat(minDstPortRange, is(flowClassifier.minDstPortRange())); | ... | ... |
... | @@ -40,6 +40,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> { | ... | @@ -40,6 +40,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> { |
40 | private static final String DESCRIPTION = "description"; | 40 | private static final String DESCRIPTION = "description"; |
41 | private static final String ETHER_TYPE = "ethertype"; | 41 | private static final String ETHER_TYPE = "ethertype"; |
42 | private static final String PROTOCOL = "protocol"; | 42 | private static final String PROTOCOL = "protocol"; |
43 | + private static final String PRIORITY = "priority"; | ||
43 | private static final String MIN_SRC_PORT_RANGE = "source_port_range_min"; | 44 | private static final String MIN_SRC_PORT_RANGE = "source_port_range_min"; |
44 | private static final String MAX_SRC_PORT_RANGE = "source_port_range_max"; | 45 | private static final String MAX_SRC_PORT_RANGE = "source_port_range_max"; |
45 | private static final String MIN_DST_PORT_RANGE = "destination_port_range_min"; | 46 | private static final String MIN_DST_PORT_RANGE = "destination_port_range_min"; |
... | @@ -79,6 +80,9 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> { | ... | @@ -79,6 +80,9 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> { |
79 | resultBuilder.setProtocol(protocol); | 80 | resultBuilder.setProtocol(protocol); |
80 | } | 81 | } |
81 | 82 | ||
83 | + int priority = (json.get(PRIORITY)).asInt(); | ||
84 | + resultBuilder.setPriority(priority); | ||
85 | + | ||
82 | int minSrcPortRange = (json.get(MIN_SRC_PORT_RANGE)).asInt(); | 86 | int minSrcPortRange = (json.get(MIN_SRC_PORT_RANGE)).asInt(); |
83 | resultBuilder.setMinSrcPortRange(minSrcPortRange); | 87 | resultBuilder.setMinSrcPortRange(minSrcPortRange); |
84 | 88 | ||
... | @@ -123,6 +127,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> { | ... | @@ -123,6 +127,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> { |
123 | .put(DESCRIPTION, flowClassifier.description()) | 127 | .put(DESCRIPTION, flowClassifier.description()) |
124 | .put(ETHER_TYPE, flowClassifier.etherType()) | 128 | .put(ETHER_TYPE, flowClassifier.etherType()) |
125 | .put(PROTOCOL, flowClassifier.protocol()) | 129 | .put(PROTOCOL, flowClassifier.protocol()) |
130 | + .put(PRIORITY, flowClassifier.priority()) | ||
126 | .put(MIN_SRC_PORT_RANGE, flowClassifier.minSrcPortRange()) | 131 | .put(MIN_SRC_PORT_RANGE, flowClassifier.minSrcPortRange()) |
127 | .put(MAX_SRC_PORT_RANGE, flowClassifier.maxSrcPortRange()) | 132 | .put(MAX_SRC_PORT_RANGE, flowClassifier.maxSrcPortRange()) |
128 | .put(MIN_DST_PORT_RANGE, flowClassifier.minDstPortRange()) | 133 | .put(MIN_DST_PORT_RANGE, flowClassifier.minDstPortRange()) | ... | ... |
... | @@ -65,8 +65,9 @@ public class FlowClassifierResourceTest extends VtnResourceTest { | ... | @@ -65,8 +65,9 @@ public class FlowClassifierResourceTest extends VtnResourceTest { |
65 | VirtualPortId dstPortId1 = VirtualPortId.portId("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"); | 65 | VirtualPortId dstPortId1 = VirtualPortId.portId("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"); |
66 | 66 | ||
67 | final MockFlowClassifier flowClassifier1 = new MockFlowClassifier(flowClassifierId1, tenantId1, "flowClassifier1", | 67 | final MockFlowClassifier flowClassifier1 = new MockFlowClassifier(flowClassifierId1, tenantId1, "flowClassifier1", |
68 | - "Mock flow classifier", "IPv4", "IP", 1001, 1500, | 68 | + "Mock flow classifier", "IPv4", "IP", 10000, |
69 | - 5001, 6000, IpPrefix.valueOf("1.1.1.1/16"), | 69 | + 1001, 1500, 5001, 6000, |
70 | + IpPrefix.valueOf("1.1.1.1/16"), | ||
70 | IpPrefix.valueOf("22.12.34.45/16"), | 71 | IpPrefix.valueOf("22.12.34.45/16"), |
71 | srcPortId1, dstPortId1); | 72 | srcPortId1, dstPortId1); |
72 | 73 | ||
... | @@ -81,6 +82,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest { | ... | @@ -81,6 +82,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest { |
81 | private final String description; | 82 | private final String description; |
82 | private final String etherType; | 83 | private final String etherType; |
83 | private final String protocol; | 84 | private final String protocol; |
85 | + private final int priority; | ||
84 | private final int minSrcPortRange; | 86 | private final int minSrcPortRange; |
85 | private final int maxSrcPortRange; | 87 | private final int maxSrcPortRange; |
86 | private final int minDstPortRange; | 88 | private final int minDstPortRange; |
... | @@ -91,15 +93,17 @@ public class FlowClassifierResourceTest extends VtnResourceTest { | ... | @@ -91,15 +93,17 @@ public class FlowClassifierResourceTest extends VtnResourceTest { |
91 | private final VirtualPortId dstPort; | 93 | private final VirtualPortId dstPort; |
92 | 94 | ||
93 | public MockFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name, | 95 | public MockFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name, |
94 | - String description, String etherType, String protocol, int minSrcPortRange, | 96 | + String description, String etherType, String protocol, int priority, |
95 | - int maxSrcPortRange, int minDstPortRange, int maxDstPortRange, IpPrefix srcIpPrefix, | 97 | + int minSrcPortRange, int maxSrcPortRange, int minDstPortRange, int maxDstPortRange, |
96 | - IpPrefix dstIpPrefix, VirtualPortId srcPort, VirtualPortId dstPort) { | 98 | + IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, VirtualPortId srcPort, |
99 | + VirtualPortId dstPort) { | ||
97 | this.flowClassifierId = flowClassifierId; | 100 | this.flowClassifierId = flowClassifierId; |
98 | this.tenantId = tenantId; | 101 | this.tenantId = tenantId; |
99 | this.name = name; | 102 | this.name = name; |
100 | this.description = description; | 103 | this.description = description; |
101 | this.etherType = etherType; | 104 | this.etherType = etherType; |
102 | this.protocol = protocol; | 105 | this.protocol = protocol; |
106 | + this.priority = priority; | ||
103 | this.minSrcPortRange = minSrcPortRange; | 107 | this.minSrcPortRange = minSrcPortRange; |
104 | this.maxSrcPortRange = maxSrcPortRange; | 108 | this.maxSrcPortRange = maxSrcPortRange; |
105 | this.minDstPortRange = minDstPortRange; | 109 | this.minDstPortRange = minDstPortRange; |
... | @@ -142,6 +146,11 @@ public class FlowClassifierResourceTest extends VtnResourceTest { | ... | @@ -142,6 +146,11 @@ public class FlowClassifierResourceTest extends VtnResourceTest { |
142 | } | 146 | } |
143 | 147 | ||
144 | @Override | 148 | @Override |
149 | + public int priority() { | ||
150 | + return priority; | ||
151 | + } | ||
152 | + | ||
153 | + @Override | ||
145 | public int minSrcPortRange() { | 154 | public int minSrcPortRange() { |
146 | return minSrcPortRange; | 155 | return minSrcPortRange; |
147 | } | 156 | } | ... | ... |
... | @@ -89,6 +89,7 @@ public class FlowClassifierCodecTest { | ... | @@ -89,6 +89,7 @@ public class FlowClassifierCodecTest { |
89 | assertThat(flowClassifier.tenantId().toString(), is(tenantId.toString())); | 89 | assertThat(flowClassifier.tenantId().toString(), is(tenantId.toString())); |
90 | assertThat(flowClassifier.description(), is("flow classifier")); | 90 | assertThat(flowClassifier.description(), is("flow classifier")); |
91 | assertThat(flowClassifier.protocol(), is("tcp")); | 91 | assertThat(flowClassifier.protocol(), is("tcp")); |
92 | + assertThat(flowClassifier.priority(), is(65535)); | ||
92 | assertThat(flowClassifier.minSrcPortRange(), is(22)); | 93 | assertThat(flowClassifier.minSrcPortRange(), is(22)); |
93 | assertThat(flowClassifier.maxSrcPortRange(), is(4000)); | 94 | assertThat(flowClassifier.maxSrcPortRange(), is(4000)); |
94 | assertThat(flowClassifier.minDstPortRange(), is(80)); | 95 | assertThat(flowClassifier.minDstPortRange(), is(80)); | ... | ... |
... | @@ -5,6 +5,7 @@ | ... | @@ -5,6 +5,7 @@ |
5 | "description": "flow classifier", | 5 | "description": "flow classifier", |
6 | "ethertype": "IPv4", | 6 | "ethertype": "IPv4", |
7 | "protocol": "tcp", | 7 | "protocol": "tcp", |
8 | + "priority": 10000, | ||
8 | "source_port_range_min": 22, "source_port_range_max": 4000, | 9 | "source_port_range_min": 22, "source_port_range_max": 4000, |
9 | "destination_port_range_min": 80, "destination_port_range_max": 80, | 10 | "destination_port_range_min": 80, "destination_port_range_max": 80, |
10 | "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16", | 11 | "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16", | ... | ... |
... | @@ -5,6 +5,7 @@ | ... | @@ -5,6 +5,7 @@ |
5 | "description": "flow classifier", | 5 | "description": "flow classifier", |
6 | "ethertype": "IPv4", | 6 | "ethertype": "IPv4", |
7 | "protocol": "tcp", | 7 | "protocol": "tcp", |
8 | + "priority": 65535, | ||
8 | "source_port_range_min": 22, "source_port_range_max": 4000, | 9 | "source_port_range_min": 22, "source_port_range_max": 4000, |
9 | "destination_port_range_min": 80, "destination_port_range_max": 80, | 10 | "destination_port_range_min": 80, "destination_port_range_max": 80, |
10 | "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16" | 11 | "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16" | ... | ... |
-
Please register or login to post a comment