Adding tunnel ipv4 src/dst openflow augmentations 33/7633/3
authorBrent Salisbury <brent.salisbury@gmail.com>
Tue, 3 Jun 2014 09:47:42 +0000 (05:47 -0400)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Tue, 3 Jun 2014 13:40:42 +0000 (13:40 +0000)
Augments the low-level openflowjava models and
OF13 implementation to support flow based tunnels
rather then port based tunnels only which is ovsdb
specific thus making a more generic TEP implementation.

I used the v4 parent serializer
AbstractOxmIpv4AddressSerializer since its pretty
class agnostic except for the v4 OpenflowBasic
match but it that is abstracted from the DP and
I don't see any glaring issues uses it. If you
guys would prefer an NXM1Class/NXM0Class specific
ipv4 super just say the word. I have both
implementations local with the same result in the DP.

Output of tests and ovs integration is posted here:
https://gist.github.com/22f0749bba00df1a3cf6

Change-Id: I0f3ebed560bba0137553944fe342704456b4658e
Signed-off-by: Brent Salisbury <brent.salisbury@gmail.com>
openflow-protocol-api/src/main/yang/openflow-augments.yang
openflow-protocol-api/src/main/yang/openflow-extensible-match.yang
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java [new file with mode: 0644]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OxmMatchConstants.java

index f11399f76a65940caa2dc364af3a9870fb6763b3..4f274d4ccf6714dd0d84806f95e6fbd87e8049f9 100644 (file)
              type uint16;\r
          }\r
      }\r
+     augment "/oxm:oxm-container/oxm:match-entries" {\r
+         ext:augment-identifier "tunnel-ipv4-dst-match-entry";\r
+         leaf tunnel-ipv4-dst {\r
+             type inet:ipv4-address;\r
+         }\r
+     }\r
+     augment "/oxm:oxm-container/oxm:match-entries" {\r
+         ext:augment-identifier "tunnel-ipv4-src-match-entry";\r
+         leaf tunnel-ipv4-src {\r
+             type inet:ipv4-address;\r
+         }\r
+     }\r
 \r
 // OFP_ACTION AUGMENTS\r
      augment "/ofaction:actions-container/ofaction:action" {\r
index 16de9a1ad9a5fc622fb2f1fd92ce980816cb6a20..ff3960aa3d0de39285527dc48e973c5433029465 100644 (file)
             base match-field;
             description "NXM field for NXM_NX_TCP_FLAGS";
         }
+        identity tunnel_ipv4_dst {
+            base match-field;
+            description "NXM field for NXM_NX_TUN_IPV4_DST";
+        }
+        identity tunnel_ipv4_src {
+            base match-field;
+            description "NXM field for NXM_NX_TUN_IPV4_SRC";
+        }
         container oxm-container {
             uses oxm-fields-grouping;
         }
index c37c1d1bd8e43a13c92a5e50fe98ad945dc7410d..e29504f3dd837d37d0ab48445a88280a5cf6ea56 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization;
 \r
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTcpFlagDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4DstDeserializer;\r
+import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4SrcDeserializer;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer;\r
@@ -113,6 +115,8 @@ public class MatchEntryDeserializerInitializer {
         MatchEntryDeserializerRegistryHelper nxm1helper =\r
                 new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID,\r
                         OxmMatchConstants.NXM_1_CLASS, registry);\r
+        nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_SRC, new NxmTunnelIpv4SrcDeserializer());\r
+        nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_DST, new NxmTunnelIpv4DstDeserializer());\r
         nxm1helper.register(OxmMatchConstants.NXM_NX_TCP_FLAG, new NxmTcpFlagDeserializer());\r
 \r
     }\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4DstDeserializer.java
new file mode 100644 (file)
index 0000000..5aa3819
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Dst;
+
+/**
+ * @author brent.salisbury
+ *
+ */
+public class NxmTunnelIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer {
+
+    @Override
+    protected Class<? extends MatchField> getOxmField() {
+        return TunnelIpv4Dst.class;
+    }
+
+    @Override
+    protected Class<? extends Clazz> getOxmClass() {
+        return Nxm1Class.class;
+    }
+}
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTunnelIpv4SrcDeserializer.java
new file mode 100644 (file)
index 0000000..0d415f6
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Clazz;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src;
+
+/**
+ * @author brent.salisbury
+ *
+ */
+public class NxmTunnelIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer {
+
+    @Override
+    protected Class<? extends MatchField> getOxmField() {
+        return TunnelIpv4Src.class;
+    }
+
+    @Override
+    protected Class<? extends Clazz> getOxmClass() {
+        return Nxm1Class.class;
+    }
+}
index bd778aee0fffa135f401f8066126de6514efc65a..348487e029e7a352b88a59a11b9a23eb883edf11 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization;
 \r
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTcpFlagSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4DstSerializer;\r
+import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4SrcSerializer;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer;\r
 import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer;\r
@@ -90,6 +92,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpD
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Dst;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;\r
@@ -155,6 +159,8 @@ public class MatchEntriesInitializer {
         Class<Nxm1Class> nxm1Class = Nxm1Class.class;\r
         EnhancedKeyRegistryHelper<Nxm1Class> nxm1RegistryHelper =\r
                 new EnhancedKeyRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, nxm1Class, serializerRegistry);\r
+        nxm1RegistryHelper.registerSerializer(TunnelIpv4Dst.class, new NxmTunnelIpv4DstSerializer());\r
+        nxm1RegistryHelper.registerSerializer(TunnelIpv4Src.class, new NxmTunnelIpv4SrcSerializer());\r
         nxm1RegistryHelper.registerSerializer(TcpFlag.class, new NxmTcpFlagSerializer());\r
     }\r
 }\r
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4DstSerializer.java
new file mode 100644 (file)
index 0000000..a2f4e22
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.match;
+
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants;
+
+/**
+ * @author brent.salisbury
+ *
+ */
+public class NxmTunnelIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer {
+
+    @Override
+    protected int getOxmClassCode() {
+        return OxmMatchConstants.NXM_1_CLASS;
+    }
+
+    @Override
+    protected int getOxmFieldCode() {
+        return OxmMatchConstants.NXM_NX_TUN_IPV4_DST;
+    }
+
+    @Override
+    protected int getValueLength() {
+        return EncodeConstants.SIZE_OF_INT_IN_BYTES;
+    }
+
+}
\ No newline at end of file
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTunnelIpv4SrcSerializer.java
new file mode 100644 (file)
index 0000000..7cebc5a
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowjava.protocol.impl.serialization.match;
+
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.OxmMatchConstants;
+
+/**
+ * @author brent.salisbury
+ *
+ */
+public class NxmTunnelIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer {
+
+    @Override
+    protected int getOxmClassCode() {
+        return OxmMatchConstants.NXM_1_CLASS;
+    }
+
+    @Override
+    protected int getOxmFieldCode() {
+        return OxmMatchConstants.NXM_NX_TUN_IPV4_SRC;
+    }
+
+    @Override
+    protected int getValueLength() {
+        return EncodeConstants.SIZE_OF_INT_IN_BYTES;
+    }
+
+}
index 202868be72db3579b7300e641cd1a901ff100cfd..94fbc2b31809a3c65730e8d498f329353aba518a 100644 (file)
@@ -108,6 +108,10 @@ public abstract class OxmMatchConstants {
      * OFPXMC_NXM_1 class Constants\r
      */\r
 \r
+    /** NXM IPv4 Tunnel Endpoint Source */\r
+    public static final int NXM_NX_TUN_IPV4_SRC = 31;\r
+    /** NXM IPv4 Tunnel Endpoint Destination */\r
+    public static final int NXM_NX_TUN_IPV4_DST = 32;\r
     /** NXM TCP_Flag value */\r
     public static final int NXM_NX_TCP_FLAG = 34;\r
 }
\ No newline at end of file