These actions allow setting of the tunnel id when a packet
is transmitted over a tunnel. For example, to set a tenant-specific
id when transmitting packets over a tunnel used by more than one tenant.

The NXActionSetTunnel64 was added to OpenvSwtich after NXActionSetTunnel.
NXActionSetTunnel64 seems to be the preferred action although GRE tunnels
only support 32bit keys.t

Signed-off-by: Simon Horman <[email protected]>
---
 ryu/ofproto/ofproto_v1_0.py        |   17 +++++++++++++++
 ryu/ofproto/ofproto_v1_0_parser.py |   40 ++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 74ec3c8..e666ad9 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -230,6 +230,23 @@ OFP_ACTION_PACK_STR = '!H'
 # OFP_ACTION_SIZE = 8
 # assert calcsize(OFP_ACTION_PACK_STR) == OFP_ACTION_SIZE
 
+# enum nx_action_subtype (truncated)
+NXAST_SET_TUNNEL = 2
+NXAST_SET_TUNNEL64 = 9
+
+NX_ACTION_SET_TUNNEL_PACK_STR = '!HHIH2xI'
+NX_ACTION_SET_TUNNEL_SIZE = 16
+assert calcsize(NX_ACTION_SET_TUNNEL_PACK_STR) == NX_ACTION_SET_TUNNEL_SIZE
+
+NX_ACTION_SET_TUNNEL64_PACK_STR = '!HHIH6xQ'
+NX_ACTION_SET_TUNNEL64_SIZE = 24
+assert calcsize(NX_ACTION_SET_TUNNEL64_PACK_STR) == NX_ACTION_SET_TUNNEL64_SIZE
+
+NX_ACTION_HEADER_PACK_STR = '!H'
+NX_ACTION_HEADER_SIZE = 10
+assert (OFP_ACTION_VENDOR_HEADER_SIZE +
+        calcsize(NX_ACTION_HEADER_PACK_STR)) == NX_ACTION_HEADER_SIZE
+
 OFP_PACKET_OUT_PACK_STR = '!IHH'
 OFP_PACKET_OUT_SIZE = 16
 assert (calcsize(OFP_PACKET_OUT_PACK_STR) + OFP_HEADER_SIZE ==
diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
b/ryu/ofproto/ofproto_v1_0_parser.py
index 629c599..13d5688 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -352,6 +352,46 @@ class OFPActionEnqueue(OFPAction):
 
 
 # TODO:XXX OFPActionVendor
+# NXAction* is a partial implementatoin, only handling serilalisation
+# of a subset of Nicira vendor actions
+
+
+class NXActionHeader(object):
+    def __init__(self, subtype_, len_):
+        self.type = ofproto_v1_0.OFPAT_VENDOR
+        self.len = len_
+        self.vendor = ofproto_v1_0.NX_VENDOR_ID
+        self.subtype = subtype_
+
+    def serialise(self, buf, offset):
+        msg_pack_into(ofproto_v1_0.OFP_ACTION_HEADER_PACK_STR,
+                      buf, offset, self.type, self.len)
+
+
+class NXActionSetTunnel(NXActionHeader):
+    def __init__(self, tun_id_):
+        self.tun_id = tun_id_
+        super(NXActionSetTunnel, self).__init__(
+            ofproto_v1_0.NXAST_SET_TUNNEL,
+            ofproto_v1_0.NX_ACTION_SET_TUNNEL_SIZE)
+
+    def serialize(self, buf, offset):
+        msg_pack_into(ofproto_v1_0.NX_ACTION_SET_TUNNEL_PACK_STR, buf,
+                      offset, self.type, self.len, self.vendor, self.subtype,
+                      self.tun_id)
+
+
+class NXActionSetTunnel64(NXActionHeader):
+    def __init__(self, tun_id_):
+        self.tun_id = tun_id_
+        super(NXActionSetTunnel64, self).__init__(
+            ofproto_v1_0.NXAST_SET_TUNNEL64,
+            ofproto_v1_0.NX_ACTION_SET_TUNNEL64_SIZE)
+
+    def serialize(self, buf, offset):
+        msg_pack_into(ofproto_v1_0.NX_ACTION_SET_TUNNEL64_PACK_STR, buf,
+                      offset, self.type, self.len, self.vendor, self.subtype,
+                      self.tun_id)
 
 
 class OFPDescStats(collections.namedtuple('OFPDescStats',
-- 
1.7.6.3


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to