summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2012-03-13 09:06:24 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-03-13 21:41:44 -0700
commit006c7cb4078b2ba6a4abdb28cdeef69bb002a5fb (patch)
tree77170bdd5d92e1f8ed3b692fb56bc3d40f270e15
parentc5a2dd55edfcd2c4098355d683c225f62f6f0e71 (diff)
Add NXActionSetTunnel and NXActionSetTunnel64
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 <horms@verge.net.au> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_0.py17
-rw-r--r--ryu/ofproto/ofproto_v1_0_parser.py40
2 files changed, 57 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 74ec3c8b..e666ad93 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 629c5992..13d5688d 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',