From 50769ac83724ff4ed2952c8d70c4f7fa44792589 Mon Sep 17 00:00:00 2001 From: IWAMOTO Toshihiro Date: Fri, 29 May 2015 12:16:01 +0900 Subject: [PATCH] Implement NXActionConjunction and conj_id match for OF1.3 and OF1.5 Signed-off-by: IWAMOTO Toshihiro Signed-off-by: FUJITA Tomonori --- ryu/ofproto/nicira_ext.py | 1 + ryu/ofproto/nx_actions.py | 40 +++++++++++++++++++++++++++++++++++++ ryu/ofproto/ofproto_v1_3.py | 1 + ryu/ofproto/ofproto_v1_5.py | 1 + 4 files changed, 43 insertions(+) diff --git a/ryu/ofproto/nicira_ext.py b/ryu/ofproto/nicira_ext.py index 5c261949..f96c8876 100644 --- a/ryu/ofproto/nicira_ext.py +++ b/ryu/ofproto/nicira_ext.py @@ -42,6 +42,7 @@ NXAST_EXIT = 17 NXAST_DEC_TTL = 18 NXAST_FIN_TIMEOUT = 19 NXAST_CONTROLLER = 20 +NXAST_CONJUNCTION = 34 NX_ACTION_RESUBMIT_PACK_STR = '!HHIHHB3x' NX_ACTION_RESUBMIT_SIZE = 16 diff --git a/ryu/ofproto/nx_actions.py b/ryu/ofproto/nx_actions.py index 1f2324ed..4a955389 100644 --- a/ryu/ofproto/nx_actions.py +++ b/ryu/ofproto/nx_actions.py @@ -341,6 +341,45 @@ def generate(ofp_name, ofpp_name): msg_pack_into('!%ds' % len(data), buf, offset + payload_offset, bytes(data)) + class NXActionConjunction(NXAction): + _subtype = nicira_ext.NXAST_CONJUNCTION + + # clause, n_clauses, id + _fmt_str = '!BBI' + + def __init__(self, + clause, + n_clauses, + id_, + type_=None, len_=None, experimenter=None, subtype=None): + super(NXActionConjunction, self).__init__() + self.clause = clause + self.n_clauses = n_clauses + self.id = id_ + + @classmethod + def parse(cls, buf): + (clause, + n_clauses, + id_,) = struct.unpack_from( + NXActionConjunction._fmt_str, buf, 0) + return cls(clause, n_clauses, id_) + + def serialize(self, buf, offset): + data = bytearray() + msg_pack_into(NXActionConjunction._fmt_str, data, 0, + self.clause, + self.n_clauses, + self.id) + payload_offset = ( + ofp.OFP_ACTION_EXPERIMENTER_HEADER_SIZE + + struct.calcsize(NXAction._fmt_str) + ) + self.len = utils.round_up(payload_offset + len(data), 8) + super(NXActionConjunction, 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) @@ -351,6 +390,7 @@ def generate(ofp_name, ofpp_name): classes = [ 'NXActionRegMove', 'NXActionLearn', + 'NXActionConjunction', '_NXFlowSpec', # exported for testing 'NXFlowSpecMatch', 'NXFlowSpecLoad', diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py index a1eefb2f..f6da98a5 100644 --- a/ryu/ofproto/ofproto_v1_3.py +++ b/ryu/ofproto/ofproto_v1_3.py @@ -1192,6 +1192,7 @@ oxm_types = [ oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr), + oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4), # The following definition is merely for testing 64-bit experimenter OXMs. # Following Open vSwitch, we use dp_hash for this purpose. diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py index f9a36687..6043a2ee 100644 --- a/ryu/ofproto/ofproto_v1_5.py +++ b/ryu/ofproto/ofproto_v1_5.py @@ -435,6 +435,7 @@ oxm_types = [ oxm_fields.OpenFlowBasic('packet_type', 44, type_desc.Int4), oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr), oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr), + oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4), ] oxm_fields.generate(__name__)