summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-10-11 12:35:51 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-10-11 10:51:37 +0000
commitad80ea4335cec699db8098cf9e31010034bf989d (patch)
tree1aaa155ad3e9c4d9fa03e755383600f3985cbb73 /v3po/v3po2vpp/src/main/java/io/fd
parentc45625102fae94f34e53ebba1d039af4059cb6fc (diff)
HONEYCOMB-258: fix protocol field translation in ACEs
It was translated to version field, but should be to protocol/next header field. Change-Id: I0cf23fdd43246bcc559f61d97701c9153e9b3607 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4Writer.java15
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6Writer.java24
2 files changed, 19 insertions, 20 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4Writer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4Writer.java
index 939954f40..2f8d030ae 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4Writer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp4Writer.java
@@ -45,9 +45,10 @@ final class AceIp4Writer extends AbstractAceWriter<AceIp> implements Ipv4Transla
private static final int ETHER_TYPE_OFFSET = 12; // first 14 bytes represent L2 header (2x6)
private static final int IP_VERSION_OFFSET = ETHER_TYPE_OFFSET+2;
- private static final int IP_VERSION_MASK = 0xf0;
private static final int DSCP_OFFSET = 15;
private static final int DSCP_MASK = 0xfc;
+ private static final int IP_PROTOCOL_OFFSET = IP_VERSION_OFFSET+9;
+ private static final int IP_PROTOCOL_MASK = 0xff;
private static final int IP4_LEN = 4;
private static final int SRC_IP_OFFSET = IP_VERSION_OFFSET + 12;
private static final int DST_IP_OFFSET = SRC_IP_OFFSET + IP4_LEN;
@@ -100,16 +101,15 @@ final class AceIp4Writer extends AbstractAceWriter<AceIp> implements Ipv4Transla
request.mask[baseOffset + ETHER_TYPE_OFFSET + 1] = (byte) 0xff;
}
- // First 14 bytes represent l2 header (2x6 + etherType(2))
- if (aceIp.getProtocol() != null) { // Internet Protocol number
- request.mask[baseOffset + IP_VERSION_OFFSET] = (byte) IP_VERSION_MASK; // first 4 bits
- }
-
if (aceIp.getDscp() != null) {
aceIsEmpty = false;
request.mask[baseOffset + DSCP_OFFSET] = (byte) DSCP_MASK; // first 6 bits
}
+ if (aceIp.getProtocol() != null) { // Internet Protocol number
+ request.mask[baseOffset + IP_PROTOCOL_OFFSET] = (byte) IP_PROTOCOL_MASK;
+ }
+
if (aceIp.getSourcePortRange() != null) {
LOG.warn("L4 Header fields are not supported. Ignoring {}", aceIp.getSourcePortRange());
}
@@ -163,8 +163,7 @@ final class AceIp4Writer extends AbstractAceWriter<AceIp> implements Ipv4Transla
}
if (aceIp.getProtocol() != null) {
- request.match[baseOffset + IP_VERSION_OFFSET] =
- (byte) (IP_VERSION_MASK & (aceIp.getProtocol().intValue() << 4));
+ request.match[baseOffset + IP_PROTOCOL_OFFSET] = (byte) (IP_PROTOCOL_MASK & aceIp.getProtocol());
}
if (aceIp.getDscp() != null) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6Writer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6Writer.java
index 911b5379f..f1cccba92 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6Writer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/AceIp6Writer.java
@@ -46,9 +46,10 @@ final class AceIp6Writer extends AbstractAceWriter<AceIp> {
private static final int ETHER_TYPE_OFFSET = 12; // first 14 bytes represent L2 header (2x6)
private static final int IP_VERSION_OFFSET = ETHER_TYPE_OFFSET+2;
- private static final int IP_VERSION_MASK = 0xf0;
private static final int DSCP_MASK1 = 0x0f;
private static final int DSCP_MASK2 = 0xc0;
+ private static final int IP_PROTOCOL_OFFSET = IP_VERSION_OFFSET+6;
+ private static final int IP_PROTOCOL_MASK = 0xff;
private static final int IP6_LEN = 16;
private static final int SRC_IP_OFFSET = IP_VERSION_OFFSET + 8;
private static final int DST_IP_OFFSET = SRC_IP_OFFSET + IP6_LEN;
@@ -114,11 +115,6 @@ final class AceIp6Writer extends AbstractAceWriter<AceIp> {
request.mask[baseOffset + ETHER_TYPE_OFFSET + 1] = (byte) 0xff;
}
- if (aceIp.getProtocol() != null) {
- aceIsEmpty = false;
- request.mask[baseOffset + IP_VERSION_OFFSET] |= IP_VERSION_MASK;
- }
-
if (aceIp.getDscp() != null) {
aceIsEmpty = false;
// DCSP (bits 4-9 of IP6 header)
@@ -126,6 +122,11 @@ final class AceIp6Writer extends AbstractAceWriter<AceIp> {
request.mask[baseOffset + IP_VERSION_OFFSET + 1] |= DSCP_MASK2;
}
+ if (aceIp.getProtocol() != null) {
+ aceIsEmpty = false;
+ request.mask[baseOffset + IP_PROTOCOL_OFFSET] = (byte) IP_PROTOCOL_MASK;
+ }
+
if (aceIp.getSourcePortRange() != null) {
LOG.warn("L4 Header fields are not supported. Ignoring {}", aceIp.getSourcePortRange());
}
@@ -184,12 +185,6 @@ final class AceIp6Writer extends AbstractAceWriter<AceIp> {
request.match[baseOffset + ETHER_TYPE_OFFSET + 1] = (byte) 0xdd;
}
- if (aceIp.getProtocol() != null) {
- noMatch = false;
- request.match[baseOffset + IP_VERSION_OFFSET] |=
- (byte) (IP_VERSION_MASK & (aceIp.getProtocol().intValue() << 4));
- }
-
if (aceIp.getDscp() != null) {
noMatch = false;
final int dscp = aceIp.getDscp().getValue();
@@ -198,6 +193,11 @@ final class AceIp6Writer extends AbstractAceWriter<AceIp> {
request.match[baseOffset + IP_VERSION_OFFSET + 1] |= (byte) (DSCP_MASK2 & (dscp << 6));
}
+ if (aceIp.getProtocol() != null) {
+ noMatch = false;
+ request.match[baseOffset + IP_PROTOCOL_OFFSET] = (byte) (IP_PROTOCOL_MASK & aceIp.getProtocol());
+ }
+
if (aceIp.getSourcePortRange() != null) {
LOG.warn("L4 Header fields are not supported. Ignoring {}", aceIp.getSourcePortRange());
}