[ONOS-4228]Parase and set priority for sfc classification

Change-Id: I0e25465d47ad1bd6c6035ff309ef631b8ef7c75e
This commit is contained in:
Phaneendra Manda 2016-04-13 23:28:03 +05:30 committed by Gerrit Code Review
parent 29f52a3e30
commit 299877f3d5
9 changed files with 92 additions and 24 deletions

View File

@ -223,19 +223,19 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi
// Send the packet to controller // Send the packet to controller
TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
treatment.setOutput(PortNumber.CONTROLLER); treatment.setOutput(PortNumber.CONTROLLER);
sendServiceFunctionClassifier(selector, treatment, deviceId, type); sendServiceFunctionClassifier(selector, treatment, deviceId, type, flowClassifier.priority());
} else if (deviceId.equals(deviceIdfromPortPair)) { } else if (deviceId.equals(deviceIdfromPortPair)) {
// classifier and source device are in the same OVS. So directly send packet to first port pair // classifier and source device are in the same OVS. So directly send packet to first port pair
TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort,
nshSpiId, flowClassifier, true); nshSpiId, flowClassifier, true);
// Build forwarding objective and send to OVS. // Build forwarding objective and send to OVS.
sendServiceFunctionClassifier(selector, treatment, deviceId, type); sendServiceFunctionClassifier(selector, treatment, deviceId, type, flowClassifier.priority());
} else { } else {
// classifier and source device are not in the same OVS. Send packet on vlan Tunnel // classifier and source device are not in the same OVS. Send packet on vlan Tunnel
TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort,
nshSpiId, flowClassifier, false); nshSpiId, flowClassifier, false);
// Build forwarding objective and send to OVS. // Build forwarding objective and send to OVS.
sendServiceFunctionClassifier(selector, treatment, deviceId, type); sendServiceFunctionClassifier(selector, treatment, deviceId, type, flowClassifier.priority());
// At the other device get the packet from vlan and send to first port pair // At the other device get the packet from vlan and send to first port pair
TrafficSelector.Builder selectorDst = DefaultTrafficSelector.builder(); TrafficSelector.Builder selectorDst = DefaultTrafficSelector.builder();
@ -244,7 +244,8 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi
TrafficTreatment.Builder treatmentDst = DefaultTrafficTreatment.builder(); TrafficTreatment.Builder treatmentDst = DefaultTrafficTreatment.builder();
Host hostDst = hostService.getHost(HostId.hostId(srcMacAddress)); Host hostDst = hostService.getHost(HostId.hostId(srcMacAddress));
treatmentDst.setOutput(hostDst.location().port()); treatmentDst.setOutput(hostDst.location().port());
sendServiceFunctionClassifier(selectorDst, treatmentDst, deviceIdfromPortPair, type); sendServiceFunctionClassifier(selectorDst, treatmentDst, deviceIdfromPortPair, type,
flowClassifier.priority());
} }
} }
return host.location(); return host.location();
@ -383,14 +384,15 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi
* @param treatment traffic treatment * @param treatment traffic treatment
* @param deviceId device id * @param deviceId device id
* @param type operation type * @param type operation type
* @param priority priority of classifier
*/ */
public void sendServiceFunctionClassifier(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, public void sendServiceFunctionClassifier(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment,
DeviceId deviceId, Objective.Operation type) { DeviceId deviceId, Objective.Operation type, int priority) {
log.info("Sending flow to service function classifier. Selector {}, Treatment {}", log.info("Sending flow to service function classifier. Selector {}, Treatment {}",
selector.toString(), treatment.toString()); selector.toString(), treatment.toString());
ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build())
.withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE) .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE)
.withPriority(FLOW_CLASSIFIER_PRIORITY); .withPriority(priority);
if (type.equals(Objective.Operation.ADD)) { if (type.equals(Objective.Operation.ADD)) {
log.debug("flowClassifierRules-->ADD"); log.debug("flowClassifierRules-->ADD");

View File

@ -34,6 +34,7 @@ public final class DefaultFlowClassifier implements FlowClassifier {
private final String description; private final String description;
private final String etherType; private final String etherType;
private final String protocol; private final String protocol;
private final int priority;
private final int minSrcPortRange; private final int minSrcPortRange;
private final int maxSrcPortRange; private final int maxSrcPortRange;
private final int minDstPortRange; private final int minDstPortRange;
@ -47,6 +48,7 @@ public final class DefaultFlowClassifier implements FlowClassifier {
private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null."; private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null.";
private static final String NAME_NOT_NULL = "Name can not be null."; private static final String NAME_NOT_NULL = "Name can not be null.";
private static final String ETHER_TYPE_NOT_NULL = "Ether Type can not be null."; private static final String ETHER_TYPE_NOT_NULL = "Ether Type can not be null.";
private static final int DEFAULT_CLASSIFIER_PRIORITY = 0xFFFF;
/** /**
* Constructor to create default flow classifier. * Constructor to create default flow classifier.
@ -57,6 +59,7 @@ public final class DefaultFlowClassifier implements FlowClassifier {
* @param description flow classifier description * @param description flow classifier description
* @param etherType etherType * @param etherType etherType
* @param protocol IP protocol * @param protocol IP protocol
* @param priority priority for classification
* @param minSrcPortRange Minimum Source port range * @param minSrcPortRange Minimum Source port range
* @param maxSrcPortRange Maximum Source port range * @param maxSrcPortRange Maximum Source port range
* @param minDstPortRange Minimum destination port range * @param minDstPortRange Minimum destination port range
@ -67,15 +70,17 @@ public final class DefaultFlowClassifier implements FlowClassifier {
* @param dstPort destination VirtualPort * @param dstPort destination VirtualPort
*/ */
private DefaultFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name, private DefaultFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name,
String description, String etherType, String protocol, int minSrcPortRange, int maxSrcPortRange, String description, String etherType, String protocol, int priority,
int minDstPortRange, int maxDstPortRange, IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, int minSrcPortRange, int maxSrcPortRange, int minDstPortRange, int maxDstPortRange,
VirtualPortId srcPort, VirtualPortId dstPort) { IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, VirtualPortId srcPort,
VirtualPortId dstPort) {
this.flowClassifierId = flowClassifierId; this.flowClassifierId = flowClassifierId;
this.tenantId = tenantId; this.tenantId = tenantId;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.etherType = etherType; this.etherType = etherType;
this.protocol = protocol; this.protocol = protocol;
this.priority = priority;
this.minSrcPortRange = minSrcPortRange; this.minSrcPortRange = minSrcPortRange;
this.maxSrcPortRange = maxSrcPortRange; this.maxSrcPortRange = maxSrcPortRange;
this.minDstPortRange = minDstPortRange; this.minDstPortRange = minDstPortRange;
@ -116,6 +121,11 @@ public final class DefaultFlowClassifier implements FlowClassifier {
return protocol; return protocol;
} }
@Override
public int priority() {
return priority;
}
@Override @Override
public int minSrcPortRange() { public int minSrcPortRange() {
return minSrcPortRange; return minSrcPortRange;
@ -169,6 +179,8 @@ public final class DefaultFlowClassifier implements FlowClassifier {
private String etherType; private String etherType;
private String protocol; private String protocol;
private boolean isProtocolSet = false; private boolean isProtocolSet = false;
private int priority;
private boolean isPrioritySet = false;
private int minSrcPortRange; private int minSrcPortRange;
private boolean isMinSrcPortRangeSet = false; private boolean isMinSrcPortRangeSet = false;
private int maxSrcPortRange; private int maxSrcPortRange;
@ -195,6 +207,7 @@ public final class DefaultFlowClassifier implements FlowClassifier {
checkNotNull(etherType, ETHER_TYPE_NOT_NULL); checkNotNull(etherType, ETHER_TYPE_NOT_NULL);
String description = null; String description = null;
String protocol = null; String protocol = null;
int priority = DEFAULT_CLASSIFIER_PRIORITY;
int minSrcPortRange = NULL_PORT; int minSrcPortRange = NULL_PORT;
int maxSrcPortRange = NULL_PORT; int maxSrcPortRange = NULL_PORT;
int minDstPortRange = NULL_PORT; int minDstPortRange = NULL_PORT;
@ -210,6 +223,9 @@ public final class DefaultFlowClassifier implements FlowClassifier {
if (isProtocolSet) { if (isProtocolSet) {
protocol = this.protocol; protocol = this.protocol;
} }
if (isPrioritySet) {
priority = this.priority;
}
if (isMinSrcPortRangeSet) { if (isMinSrcPortRangeSet) {
minSrcPortRange = this.minSrcPortRange; minSrcPortRange = this.minSrcPortRange;
} }
@ -236,8 +252,8 @@ public final class DefaultFlowClassifier implements FlowClassifier {
} }
return new DefaultFlowClassifier(flowClassifierId, tenantId, name, description, etherType, protocol, return new DefaultFlowClassifier(flowClassifierId, tenantId, name, description, etherType, protocol,
minSrcPortRange, maxSrcPortRange, minDstPortRange, maxDstPortRange, srcIpPrefix, dstIpPrefix, priority, minSrcPortRange, maxSrcPortRange, minDstPortRange,
srcPort, dstPort); maxDstPortRange, srcIpPrefix, dstIpPrefix, srcPort, dstPort);
} }
@Override @Override
@ -278,6 +294,13 @@ public final class DefaultFlowClassifier implements FlowClassifier {
return this; return this;
} }
@Override
public Builder setPriority(int priority) {
this.priority = priority;
this.isPrioritySet = true;
return this;
}
@Override @Override
public Builder setMinSrcPortRange(int minSrcPortRange) { public Builder setMinSrcPortRange(int minSrcPortRange) {
this.minSrcPortRange = minSrcPortRange; this.minSrcPortRange = minSrcPortRange;
@ -354,6 +377,7 @@ public final class DefaultFlowClassifier implements FlowClassifier {
&& Objects.equals(this.description, other.description) && Objects.equals(this.description, other.description)
&& Objects.equals(this.etherType, other.etherType) && Objects.equals(this.etherType, other.etherType)
&& Objects.equals(this.protocol, other.protocol) && Objects.equals(this.protocol, other.protocol)
&& Objects.equals(this.priority, other.priority)
&& Objects.equals(this.minSrcPortRange, other.minSrcPortRange) && Objects.equals(this.minSrcPortRange, other.minSrcPortRange)
&& Objects.equals(this.maxSrcPortRange, other.maxSrcPortRange) && Objects.equals(this.maxSrcPortRange, other.maxSrcPortRange)
&& Objects.equals(this.minDstPortRange, other.minDstPortRange) && Objects.equals(this.minDstPortRange, other.minDstPortRange)
@ -375,6 +399,7 @@ public final class DefaultFlowClassifier implements FlowClassifier {
&& Objects.equals(this.description, flowClassifier.description()) && Objects.equals(this.description, flowClassifier.description())
&& Objects.equals(this.etherType, flowClassifier.etherType()) && Objects.equals(this.etherType, flowClassifier.etherType())
&& Objects.equals(this.protocol, flowClassifier.protocol()) && Objects.equals(this.protocol, flowClassifier.protocol())
&& Objects.equals(this.priority, flowClassifier.priority())
&& Objects.equals(this.minSrcPortRange, flowClassifier.minSrcPortRange()) && Objects.equals(this.minSrcPortRange, flowClassifier.minSrcPortRange())
&& Objects.equals(this.maxSrcPortRange, flowClassifier.maxSrcPortRange()) && Objects.equals(this.maxSrcPortRange, flowClassifier.maxSrcPortRange())
&& Objects.equals(this.minDstPortRange, flowClassifier.minDstPortRange()) && Objects.equals(this.minDstPortRange, flowClassifier.minDstPortRange())
@ -394,6 +419,7 @@ public final class DefaultFlowClassifier implements FlowClassifier {
.add("Description", description) .add("Description", description)
.add("String", etherType) .add("String", etherType)
.add("Protocol", protocol) .add("Protocol", protocol)
.add("Priority", priority)
.add("MinSrcPortRange", minSrcPortRange) .add("MinSrcPortRange", minSrcPortRange)
.add("MaxSrcPortRange", maxSrcPortRange) .add("MaxSrcPortRange", maxSrcPortRange)
.add("MinDstPortRange", minDstPortRange) .add("MinDstPortRange", minDstPortRange)

View File

@ -67,6 +67,13 @@ public interface FlowClassifier {
*/ */
String protocol(); String protocol();
/**
* Returns priority.
*
* @return priority
*/
int priority();
/** /**
* Returns minimum source port range. * Returns minimum source port range.
* *
@ -192,6 +199,14 @@ public interface FlowClassifier {
*/ */
Builder setProtocol(String protocol); Builder setProtocol(String protocol);
/**
* Sets priority.
*
* @param priority priority
* @return builder object by setting priority
*/
Builder setPriority(int priority);
/** /**
* Set minimum source port range. * Set minimum source port range.
* *

View File

@ -46,6 +46,7 @@ public class DefaultFlowClassifierTest {
final String description = "FlowClassifier1"; final String description = "FlowClassifier1";
final String ethType = "IPv4"; final String ethType = "IPv4";
final String protocol = "tcp"; final String protocol = "tcp";
final int priority = 65535;
final int minSrcPortRange = 5; final int minSrcPortRange = 5;
final int maxSrcPortRange = 10; final int maxSrcPortRange = 10;
final int minDstPortRange = 5; final int minDstPortRange = 5;
@ -60,22 +61,25 @@ public class DefaultFlowClassifierTest {
DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder(); DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
final FlowClassifier flowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) final FlowClassifier flowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
.setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
.setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) .setProtocol(protocol).setPriority(priority).setMinSrcPortRange(minSrcPortRange)
.setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) .setMaxSrcPortRange(maxSrcPortRange).setMinDstPortRange(minDstPortRange)
.setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); .setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix).setDstIpPrefix(dstIpPrefix)
.setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
flowClassifierBuilder = new DefaultFlowClassifier.Builder(); flowClassifierBuilder = new DefaultFlowClassifier.Builder();
final FlowClassifier sameAsFlowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId) final FlowClassifier sameAsFlowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
.setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
.setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) .setProtocol(protocol).setPriority(priority).setMinSrcPortRange(minSrcPortRange)
.setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) .setMaxSrcPortRange(maxSrcPortRange).setMinDstPortRange(minDstPortRange)
.setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); .setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix).setDstIpPrefix(dstIpPrefix)
.setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
// Create different classifier object. // Create different classifier object.
final String name2 = "FlowClassifier2"; final String name2 = "FlowClassifier2";
final String description2 = "FlowClassifier2"; final String description2 = "FlowClassifier2";
final String ethType2 = "IPv6"; final String ethType2 = "IPv6";
final String protocol2 = "udp"; final String protocol2 = "udp";
final int priority2 = 50000;
final int minSrcPortRange2 = 5; final int minSrcPortRange2 = 5;
final int maxSrcPortRange2 = 10; final int maxSrcPortRange2 = 10;
final int minDstPortRange2 = 5; final int minDstPortRange2 = 5;
@ -92,7 +96,8 @@ public class DefaultFlowClassifierTest {
.setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2) .setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2)
.setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange2).setMaxSrcPortRange(maxSrcPortRange2) .setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange2).setMaxSrcPortRange(maxSrcPortRange2)
.setMinDstPortRange(minDstPortRange2).setMaxDstPortRange(maxDstPortRange2).setSrcIpPrefix(srcIpPrefix2) .setMinDstPortRange(minDstPortRange2).setMaxDstPortRange(maxDstPortRange2).setSrcIpPrefix(srcIpPrefix2)
.setDstIpPrefix(dstIpPrefix2).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2).build(); .setDstIpPrefix(dstIpPrefix2).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2)
.setPriority(priority2).build();
new EqualsTester().addEqualityGroup(flowClassifier1, sameAsFlowClassifier1).addEqualityGroup(flowClassifier2) new EqualsTester().addEqualityGroup(flowClassifier1, sameAsFlowClassifier1).addEqualityGroup(flowClassifier2)
.testEquals(); .testEquals();
@ -107,6 +112,7 @@ public class DefaultFlowClassifierTest {
final String description = "FlowClassifier"; final String description = "FlowClassifier";
final String ethType = "IPv4"; final String ethType = "IPv4";
final String protocol = "tcp"; final String protocol = "tcp";
final int priority = 30000;
final int minSrcPortRange = 5; final int minSrcPortRange = 5;
final int maxSrcPortRange = 10; final int maxSrcPortRange = 10;
final int minDstPortRange = 5; final int minDstPortRange = 5;
@ -123,7 +129,8 @@ public class DefaultFlowClassifierTest {
.setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
.setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
.setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
.setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort)
.setPriority(priority).build();
assertThat(flowClassifierId, is(flowClassifier.flowClassifierId())); assertThat(flowClassifierId, is(flowClassifier.flowClassifierId()));
assertThat(tenantId, is(flowClassifier.tenantId())); assertThat(tenantId, is(flowClassifier.tenantId()));
@ -131,6 +138,7 @@ public class DefaultFlowClassifierTest {
assertThat(description, is(flowClassifier.description())); assertThat(description, is(flowClassifier.description()));
assertThat(ethType, is(flowClassifier.etherType())); assertThat(ethType, is(flowClassifier.etherType()));
assertThat(protocol, is(flowClassifier.protocol())); assertThat(protocol, is(flowClassifier.protocol()));
assertThat(priority, is(flowClassifier.priority()));
assertThat(minSrcPortRange, is(flowClassifier.minSrcPortRange())); assertThat(minSrcPortRange, is(flowClassifier.minSrcPortRange()));
assertThat(maxSrcPortRange, is(flowClassifier.maxSrcPortRange())); assertThat(maxSrcPortRange, is(flowClassifier.maxSrcPortRange()));
assertThat(minDstPortRange, is(flowClassifier.minDstPortRange())); assertThat(minDstPortRange, is(flowClassifier.minDstPortRange()));

View File

@ -40,6 +40,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
private static final String DESCRIPTION = "description"; private static final String DESCRIPTION = "description";
private static final String ETHER_TYPE = "ethertype"; private static final String ETHER_TYPE = "ethertype";
private static final String PROTOCOL = "protocol"; private static final String PROTOCOL = "protocol";
private static final String PRIORITY = "priority";
private static final String MIN_SRC_PORT_RANGE = "source_port_range_min"; private static final String MIN_SRC_PORT_RANGE = "source_port_range_min";
private static final String MAX_SRC_PORT_RANGE = "source_port_range_max"; private static final String MAX_SRC_PORT_RANGE = "source_port_range_max";
private static final String MIN_DST_PORT_RANGE = "destination_port_range_min"; private static final String MIN_DST_PORT_RANGE = "destination_port_range_min";
@ -79,6 +80,9 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
resultBuilder.setProtocol(protocol); resultBuilder.setProtocol(protocol);
} }
int priority = (json.get(PRIORITY)).asInt();
resultBuilder.setPriority(priority);
int minSrcPortRange = (json.get(MIN_SRC_PORT_RANGE)).asInt(); int minSrcPortRange = (json.get(MIN_SRC_PORT_RANGE)).asInt();
resultBuilder.setMinSrcPortRange(minSrcPortRange); resultBuilder.setMinSrcPortRange(minSrcPortRange);
@ -123,6 +127,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
.put(DESCRIPTION, flowClassifier.description()) .put(DESCRIPTION, flowClassifier.description())
.put(ETHER_TYPE, flowClassifier.etherType()) .put(ETHER_TYPE, flowClassifier.etherType())
.put(PROTOCOL, flowClassifier.protocol()) .put(PROTOCOL, flowClassifier.protocol())
.put(PRIORITY, flowClassifier.priority())
.put(MIN_SRC_PORT_RANGE, flowClassifier.minSrcPortRange()) .put(MIN_SRC_PORT_RANGE, flowClassifier.minSrcPortRange())
.put(MAX_SRC_PORT_RANGE, flowClassifier.maxSrcPortRange()) .put(MAX_SRC_PORT_RANGE, flowClassifier.maxSrcPortRange())
.put(MIN_DST_PORT_RANGE, flowClassifier.minDstPortRange()) .put(MIN_DST_PORT_RANGE, flowClassifier.minDstPortRange())

View File

@ -65,8 +65,9 @@ public class FlowClassifierResourceTest extends VtnResourceTest {
VirtualPortId dstPortId1 = VirtualPortId.portId("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345"); VirtualPortId dstPortId1 = VirtualPortId.portId("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345");
final MockFlowClassifier flowClassifier1 = new MockFlowClassifier(flowClassifierId1, tenantId1, "flowClassifier1", final MockFlowClassifier flowClassifier1 = new MockFlowClassifier(flowClassifierId1, tenantId1, "flowClassifier1",
"Mock flow classifier", "IPv4", "IP", 1001, 1500, "Mock flow classifier", "IPv4", "IP", 10000,
5001, 6000, IpPrefix.valueOf("1.1.1.1/16"), 1001, 1500, 5001, 6000,
IpPrefix.valueOf("1.1.1.1/16"),
IpPrefix.valueOf("22.12.34.45/16"), IpPrefix.valueOf("22.12.34.45/16"),
srcPortId1, dstPortId1); srcPortId1, dstPortId1);
@ -81,6 +82,7 @@ public class FlowClassifierResourceTest extends VtnResourceTest {
private final String description; private final String description;
private final String etherType; private final String etherType;
private final String protocol; private final String protocol;
private final int priority;
private final int minSrcPortRange; private final int minSrcPortRange;
private final int maxSrcPortRange; private final int maxSrcPortRange;
private final int minDstPortRange; private final int minDstPortRange;
@ -91,15 +93,17 @@ public class FlowClassifierResourceTest extends VtnResourceTest {
private final VirtualPortId dstPort; private final VirtualPortId dstPort;
public MockFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name, public MockFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name,
String description, String etherType, String protocol, int minSrcPortRange, String description, String etherType, String protocol, int priority,
int maxSrcPortRange, int minDstPortRange, int maxDstPortRange, IpPrefix srcIpPrefix, int minSrcPortRange, int maxSrcPortRange, int minDstPortRange, int maxDstPortRange,
IpPrefix dstIpPrefix, VirtualPortId srcPort, VirtualPortId dstPort) { IpPrefix srcIpPrefix, IpPrefix dstIpPrefix, VirtualPortId srcPort,
VirtualPortId dstPort) {
this.flowClassifierId = flowClassifierId; this.flowClassifierId = flowClassifierId;
this.tenantId = tenantId; this.tenantId = tenantId;
this.name = name; this.name = name;
this.description = description; this.description = description;
this.etherType = etherType; this.etherType = etherType;
this.protocol = protocol; this.protocol = protocol;
this.priority = priority;
this.minSrcPortRange = minSrcPortRange; this.minSrcPortRange = minSrcPortRange;
this.maxSrcPortRange = maxSrcPortRange; this.maxSrcPortRange = maxSrcPortRange;
this.minDstPortRange = minDstPortRange; this.minDstPortRange = minDstPortRange;
@ -141,6 +145,11 @@ public class FlowClassifierResourceTest extends VtnResourceTest {
return protocol; return protocol;
} }
@Override
public int priority() {
return priority;
}
@Override @Override
public int minSrcPortRange() { public int minSrcPortRange() {
return minSrcPortRange; return minSrcPortRange;

View File

@ -89,6 +89,7 @@ public class FlowClassifierCodecTest {
assertThat(flowClassifier.tenantId().toString(), is(tenantId.toString())); assertThat(flowClassifier.tenantId().toString(), is(tenantId.toString()));
assertThat(flowClassifier.description(), is("flow classifier")); assertThat(flowClassifier.description(), is("flow classifier"));
assertThat(flowClassifier.protocol(), is("tcp")); assertThat(flowClassifier.protocol(), is("tcp"));
assertThat(flowClassifier.priority(), is(65535));
assertThat(flowClassifier.minSrcPortRange(), is(22)); assertThat(flowClassifier.minSrcPortRange(), is(22));
assertThat(flowClassifier.maxSrcPortRange(), is(4000)); assertThat(flowClassifier.maxSrcPortRange(), is(4000));
assertThat(flowClassifier.minDstPortRange(), is(80)); assertThat(flowClassifier.minDstPortRange(), is(80));

View File

@ -5,6 +5,7 @@
"description": "flow classifier", "description": "flow classifier",
"ethertype": "IPv4", "ethertype": "IPv4",
"protocol": "tcp", "protocol": "tcp",
"priority": 10000,
"source_port_range_min": 22, "source_port_range_max": 4000, "source_port_range_min": 22, "source_port_range_max": 4000,
"destination_port_range_min": 80, "destination_port_range_max": 80, "destination_port_range_min": 80, "destination_port_range_max": 80,
"source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16", "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16",

View File

@ -5,6 +5,7 @@
"description": "flow classifier", "description": "flow classifier",
"ethertype": "IPv4", "ethertype": "IPv4",
"protocol": "tcp", "protocol": "tcp",
"priority": 65535,
"source_port_range_min": 22, "source_port_range_max": 4000, "source_port_range_min": 22, "source_port_range_max": 4000,
"destination_port_range_min": 80, "destination_port_range_max": 80, "destination_port_range_min": 80, "destination_port_range_max": 80,
"source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16" "source_ip_prefix": "1.1.1.1/16" , "destination_ip_prefix": "22.12.34.45/16"