NIC flow rules match IP prefixes
The server device driver's flow installer allows to
devise NIC flow rules on entire src/dst IP subnets.
Change-Id: Ia7683c7bc131788ecf3465b08588d0c9bf81b6e6
Signed-off-by: Georgios Katsikas <katsikas.gp@gmail.com>
diff --git a/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultDpdkNicFlowRule.java b/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultDpdkNicFlowRule.java
index 223f5c3..b7b6f05 100644
--- a/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultDpdkNicFlowRule.java
+++ b/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultDpdkNicFlowRule.java
@@ -18,7 +18,6 @@
import org.onosproject.net.flow.FlowRule;
-import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
/**
@@ -81,21 +80,21 @@
}
if (this.ipv4SrcAddress() != null) {
- rule += "src is " + this.ipv4SrcAddress().toString() + " ";
- }
-
- if (this.ipv4SrcMask() != null) {
- rule += "src spec " + this.ipv4SrcMask().address().getIp4Address().toString() + " ";
- rule += "src mask " + Ip4Address.makeMaskPrefix(this.ipv4SrcMask().prefixLength()).toString() + " ";
+ if ((this.ipv4SrcMask() != null) && (this.ipv4SrcMask().prefixLength() < 32)) {
+ rule += "src spec " + this.ipv4SrcAddress().toString() + " ";
+ rule += "src prefix " + this.ipv4SrcMask().prefixLength() + " ";
+ } else {
+ rule += "src is " + this.ipv4SrcAddress().toString() + " ";
+ }
}
if (this.ipv4DstAddress() != null) {
- rule += "dst is " + this.ipv4DstAddress().toString() + " ";
- }
-
- if (this.ipv4DstMask() != null) {
- rule += "dst spec " + this.ipv4DstMask().address().getIp4Address().toString() + " ";
- rule += "dst mask " + Ip4Address.makeMaskPrefix(this.ipv4DstMask().prefixLength()).toString() + " ";
+ if ((this.ipv4DstMask() != null) && (this.ipv4DstMask().prefixLength() < 32)) {
+ rule += "dst spec " + this.ipv4DstAddress().toString() + " ";
+ rule += "dst prefix " + this.ipv4DstMask().prefixLength() + " ";
+ } else {
+ rule += "dst is " + this.ipv4DstAddress().toString() + " ";
+ }
}
rule += "/ ";
diff --git a/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultNicFlowRule.java b/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultNicFlowRule.java
index be89997..abbf0b8 100644
--- a/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultNicFlowRule.java
+++ b/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/DefaultNicFlowRule.java
@@ -144,9 +144,8 @@
this.ipv4ProtoCriterion = (IPProtocolCriterion) this.selector().getCriterion(IP_PROTO);
this.ipv4SrcAddrCriterion = (IPCriterion) this.selector().getCriterion(IPV4_SRC);
this.ipv4DstAddrCriterion = (IPCriterion) this.selector().getCriterion(IPV4_DST);
- // Is there a criterion for IP masks?
- this.ipv4SrcMaskCriterion = (IPCriterion) null;
- this.ipv4DstMaskCriterion = (IPCriterion) null;
+ this.ipv4SrcMaskCriterion = (IPCriterion) this.selector().getCriterion(IPV4_SRC);
+ this.ipv4DstMaskCriterion = (IPCriterion) this.selector().getCriterion(IPV4_DST);
this.udpSrcPortCriterion = (UdpPortCriterion) this.selector().getCriterion(UDP_SRC);
this.udpDstPortCriterion = (UdpPortCriterion) this.selector().getCriterion(UDP_DST);
this.tcpSrcPortCriterion = (TcpPortCriterion) this.selector().getCriterion(TCP_SRC);