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>
This commit is contained in:
Simon Horman 2012-03-13 09:06:24 +09:00 committed by FUJITA Tomonori
parent c5a2dd55ed
commit 006c7cb407
2 changed files with 57 additions and 0 deletions

View File

@ -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 ==

View File

@ -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',