Fixed address translation and rule removal bugs
This patch fixes two bugs in the flow rule programmable
module of the server device driver. The first bug was related
to the translation of IP addresses and masks into NIC flow
rule commands. The second bug was related to the command used
to explicitly remove a flow rule.
The first bug was detected after testing the server device driver
with large ACL configurations from Internet Service Providers.
Code review fixes applied.
Change-Id: I8f509e675e19aa05ca058b20cc5e53690c902693
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 5831b79..223f5c3 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,6 +18,7 @@
import org.onosproject.net.flow.FlowRule;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
/**
@@ -32,20 +33,17 @@
long interfaceNumber,
long cpuCoreIndex,
NicRuleScope scope) {
- super(flowRule, trafficClassId, interfaceName, interfaceNumber,
- cpuCoreIndex, scope);
+ super(flowRule, trafficClassId, interfaceName, interfaceNumber, cpuCoreIndex, scope);
}
@Override
public String createRule() {
- String rule = "flow create " + Long.toString(this.interfaceNumber) + " ";
- return rule + ruleBody();
+ return "flow create " + Long.toString(this.interfaceNumber) + " " + ruleBody();
}
@Override
public String removeRule() {
- String rule = "flow remove " + Long.toString(this.interfaceNumber) + " ";
- return rule + ruleBody();
+ return "flow destroy " + Long.toString(this.interfaceNumber) + " rule " + id().toString();
}
@Override
@@ -87,7 +85,8 @@
}
if (this.ipv4SrcMask() != null) {
- rule += "src mask " + this.ipv4SrcMask().toString() + " ";
+ rule += "src spec " + this.ipv4SrcMask().address().getIp4Address().toString() + " ";
+ rule += "src mask " + Ip4Address.makeMaskPrefix(this.ipv4SrcMask().prefixLength()).toString() + " ";
}
if (this.ipv4DstAddress() != null) {
@@ -95,7 +94,8 @@
}
if (this.ipv4DstMask() != null) {
- rule += "dst mask " + this.ipv4DstMask().toString() + " ";
+ rule += "dst spec " + this.ipv4DstMask().address().getIp4Address().toString() + " ";
+ rule += "dst mask " + Ip4Address.makeMaskPrefix(this.ipv4DstMask().prefixLength()).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 cfb05ab..be89997 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
@@ -33,6 +33,7 @@
import org.onlab.packet.EthType;
import org.onlab.packet.MacAddress;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import org.slf4j.Logger;
@@ -237,9 +238,9 @@
}
@Override
- public Ip4Prefix ipv4SrcAddress() {
+ public Ip4Address ipv4SrcAddress() {
return (ipv4SrcAddrCriterion != null) ?
- ipv4SrcAddrCriterion.ip().getIp4Prefix() : null;
+ ipv4SrcAddrCriterion.ip().address().getIp4Address() : null;
}
@Override
@@ -249,9 +250,9 @@
}
@Override
- public Ip4Prefix ipv4DstAddress() {
+ public Ip4Address ipv4DstAddress() {
return (ipv4DstAddrCriterion != null) ?
- ipv4DstAddrCriterion.ip().getIp4Prefix() : null;
+ ipv4DstAddrCriterion.ip().address().getIp4Address() : null;
}
@Override
diff --git a/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/NicFlowRule.java b/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/NicFlowRule.java
index 57ade4e..1215b6f 100644
--- a/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/NicFlowRule.java
+++ b/drivers/server/src/main/java/org/onosproject/drivers/server/devices/nic/NicFlowRule.java
@@ -20,6 +20,7 @@
import org.onlab.packet.EthType;
import org.onlab.packet.MacAddress;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
import java.util.Set;
@@ -127,7 +128,7 @@
*
* @return source IP address field
*/
- Ip4Prefix ipv4SrcAddress();
+ Ip4Address ipv4SrcAddress();
/**
* Returns the source IP mask field of this rule
@@ -143,7 +144,7 @@
*
* @return destination IP address field
*/
- Ip4Prefix ipv4DstAddress();
+ Ip4Address ipv4DstAddress();
/**
* Returns the destination IP mask field of this rule