Add support for pkt_mark nicira ext (NXM_NX_PKT_MARK)

Add support for pkt_mark match and set

Signed-off-by: Eran Gampel <eran@gampel.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Eran 2015-06-26 01:08:03 -07:00 committed by FUJITA Tomonori
parent 645ae7633f
commit 815dc505b7
5 changed files with 30 additions and 0 deletions

View File

@ -90,6 +90,7 @@ class Flow(object):
self.nw_frag = 0
self.regs = [0] * FLOW_N_REGS
self.ipv6_label = 0
self.pkt_mark = 0
class FlowWildcards(object):
@ -111,6 +112,7 @@ class FlowWildcards(object):
self.regs_bits = 0
self.regs_mask = [0] * FLOW_N_REGS
self.wildcards = ofproto_v1_0.OFPFW_ALL
self.pkt_mark_mask = 0
class ClsRule(object):
@ -291,6 +293,10 @@ class ClsRule(object):
self.flow.regs[reg_idx] = value
self.wc.regs_bits |= (1 << reg_idx)
def set_pkt_mark_masked(self, pkt_mark, mask):
self.flow.pkt_mark = pkt_mark
self.wc.pkt_mark_mask = mask
def flow_format(self):
# Tunnel ID is only supported by NXM
if self.wc.tun_id_mask != 0:
@ -914,6 +920,17 @@ class MFRegister(MFField):
return self._put(buf, offset, rule.flow.regs[i])
@_register_make
@_set_nxm_headers([ofproto_v1_0.NXM_NX_PKT_MARK, ofproto_v1_0.NXM_NX_PKT_MARK_W])
class MFPktMark(MFField):
@classmethod
def make(cls, header):
return cls(header, MF_PACK_STRING_BE32)
def put(self, buf, offset, rule):
return self.putm(buf, offset, rule.flow.pkt_mark, rule.wc.pkt_mark_mask)
def serialize_nxm_match(rule, buf, offset):
old_offset = offset
@ -1071,6 +1088,13 @@ def serialize_nxm_match(rule, buf, offset):
header = ofproto_v1_0.NXM_NX_IP_FRAG_W
offset += nxm_put(buf, offset, header, rule)
if rule.flow.pkt_mark != 0:
if rule.wc.pkt_mark_mask == UINT32_MAX:
header = ofproto_v1_0.NXM_NX_PKT_MARK
else:
header = ofproto_v1_0.NXM_NX_PKT_MARK_W
offset += nxm_put(buf, offset, header, rule)
# Tunnel Id
if rule.wc.tun_id_mask != 0:
if rule.wc.tun_id_mask == UINT64_MAX:

View File

@ -582,6 +582,9 @@ NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)
NXM_NX_IP_TTL = nxm_header(0x0001, 29, 1)
NXM_NX_PKT_MARK = nxm_header(0x0001, 33, 4)
NXM_NX_PKT_MARK_W = nxm_header_w(0x0001, 33, 4)
def nxm_nx_reg(idx):
return nxm_header(0x0001, idx, 4)

View File

@ -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('pkt_mark', 33, type_desc.Int4),
oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),
# The following definition is merely for testing 64-bit experimenter OXMs.

View File

@ -391,6 +391,7 @@ oxm_types = [
oxm_fields.OpenFlowBasic('pbb_uca', 41, type_desc.Int1),
oxm_fields.NiciraExtended1('tun_ipv4_src', 31, type_desc.IPv4Addr),
oxm_fields.NiciraExtended1('tun_ipv4_dst', 32, type_desc.IPv4Addr),
oxm_fields.NiciraExtended1('pkt_mark', 33, type_desc.Int4),
]
oxm_fields.generate(__name__)

View File

@ -434,6 +434,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('pkt_mark', 33, type_desc.Int4),
oxm_fields.NiciraExtended1('conj_id', 37, type_desc.Int4),
]