mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-10 14:56:11 +02:00
Implement NXActionCT and related ct_* matches
These are a Nicira extension for conntrack. Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
89e1bcd577
commit
0599edf753
@ -48,6 +48,7 @@ Int2 = IntDescr(2)
|
||||
Int3 = IntDescr(3)
|
||||
Int4 = IntDescr(4)
|
||||
Int8 = IntDescr(8)
|
||||
Int16 = IntDescr(16)
|
||||
|
||||
|
||||
def _split_str(s, n):
|
||||
|
||||
@ -43,6 +43,7 @@ NXAST_DEC_TTL = 18
|
||||
NXAST_FIN_TIMEOUT = 19
|
||||
NXAST_CONTROLLER = 20
|
||||
NXAST_CONJUNCTION = 34
|
||||
NXAST_CT = 35
|
||||
|
||||
NX_ACTION_RESUBMIT_PACK_STR = '!HHIHHB3x'
|
||||
NX_ACTION_RESUBMIT_SIZE = 16
|
||||
|
||||
@ -415,6 +415,68 @@ def generate(ofp_name, ofpp_name):
|
||||
msg_pack_into('!%ds' % len(data), buf, offset + payload_offset,
|
||||
bytes(data))
|
||||
|
||||
class NXActionCT(NXAction):
|
||||
_subtype = nicira_ext.NXAST_CT
|
||||
|
||||
# flags, zone_src, zone_ofs_nbits (zone_imm), recirc_table,
|
||||
# pad, alg
|
||||
_fmt_str = '!HIHB3xH'
|
||||
# Followed by actions
|
||||
|
||||
def __init__(self,
|
||||
flags,
|
||||
zone_src,
|
||||
zone_ofs_nbits, # is zone_imm if zone_src == 0
|
||||
recirc_table,
|
||||
alg,
|
||||
actions,
|
||||
type_=None, len_=None, experimenter=None, subtype=None):
|
||||
super(NXActionCT, self).__init__()
|
||||
self.flags = flags
|
||||
self.zone_src = zone_src
|
||||
self.zone_ofs_nbits = zone_ofs_nbits
|
||||
self.recirc_table = recirc_table
|
||||
self.alg = alg
|
||||
self.actions = actions
|
||||
|
||||
@classmethod
|
||||
def parse(cls, buf):
|
||||
(flags,
|
||||
zone_src,
|
||||
zone_ofs_nbits,
|
||||
recirc_table,
|
||||
alg,) = struct.unpack_from(
|
||||
NXActionCT._fmt_str, buf, 0)
|
||||
rest = buf[struct.calcsize(NXActionCT._fmt_str):]
|
||||
# actions
|
||||
actions = []
|
||||
while len(rest) > 0:
|
||||
action = ofpp.OFPAction.parser(rest, 0)
|
||||
actions.append(action)
|
||||
rest = rest[action.len:]
|
||||
|
||||
return cls(flags, zone_src, zone_ofs_nbits, recirc_table,
|
||||
alg, actions)
|
||||
|
||||
def serialize(self, buf, offset):
|
||||
data = bytearray()
|
||||
msg_pack_into(NXActionCT._fmt_str, data, 0,
|
||||
self.flags,
|
||||
self.zone_src,
|
||||
self.zone_ofs_nbits,
|
||||
self.recirc_table,
|
||||
self.alg)
|
||||
for a in self.actions:
|
||||
a.serialize(data, len(data))
|
||||
payload_offset = (
|
||||
ofp.OFP_ACTION_EXPERIMENTER_HEADER_SIZE +
|
||||
struct.calcsize(NXAction._fmt_str)
|
||||
)
|
||||
self.len = utils.round_up(payload_offset + len(data), 8)
|
||||
super(NXActionCT, self).serialize(buf, offset)
|
||||
msg_pack_into('!%ds' % len(data), buf, offset + payload_offset,
|
||||
bytes(data))
|
||||
|
||||
def add_attr(k, v):
|
||||
v.__module__ = ofpp.__name__ # Necessary for stringify stuff
|
||||
setattr(ofpp, k, v)
|
||||
@ -427,6 +489,7 @@ def generate(ofp_name, ofpp_name):
|
||||
'NXActionLearn',
|
||||
'NXActionConjunction',
|
||||
'NXActionResubmitTable',
|
||||
'NXActionCT',
|
||||
'_NXFlowSpec', # exported for testing
|
||||
'NXFlowSpecMatch',
|
||||
'NXFlowSpecLoad',
|
||||
|
||||
@ -1202,6 +1202,10 @@ oxm_types = [
|
||||
oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
|
||||
oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
|
||||
oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),
|
||||
oxm_fields.NiciraExtended1('ct_state', 105, type_desc.Int4),
|
||||
oxm_fields.NiciraExtended1('ct_zone', 106, type_desc.Int2),
|
||||
oxm_fields.NiciraExtended1('ct_mark', 107, type_desc.Int4),
|
||||
oxm_fields.NiciraExtended1('ct_label', 108, type_desc.Int16),
|
||||
|
||||
# The following definition is merely for testing 64-bit experimenter OXMs.
|
||||
# Following Open vSwitch, we use dp_hash for this purpose.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user