nxm: add NXM_NX_ND_TARGET

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori 2012-06-21 14:55:03 +09:00
parent 111d331dd9
commit 0a3760130a
2 changed files with 34 additions and 0 deletions

View File

@ -87,6 +87,7 @@ class Flow(object):
self.arp_tpa = 0 self.arp_tpa = 0
self.ipv6_src = [] self.ipv6_src = []
self.ipv6_dst = [] self.ipv6_dst = []
self.nd_target = []
self.ipv6_label = 0 self.ipv6_label = 0
@ -104,6 +105,7 @@ class FlowWildcards(object):
self.vlan_tci_mask = 0 self.vlan_tci_mask = 0
self.ipv6_src_mask = [] self.ipv6_src_mask = []
self.ipv6_dst_mask = [] self.ipv6_dst_mask = []
self.nd_target_mask = []
self.wildcards = FWW_ALL self.wildcards = FWW_ALL
@ -247,6 +249,14 @@ class ClsRule(object):
def set_ipv6_dst(self, dst): def set_ipv6_dst(self, dst):
self.flow.ipv6_dst = dst self.flow.ipv6_dst = dst
def set_nd_target_masked(self, target, mask):
self.wc.nd_target_mask = mask
self.flow.nd_target = [x & y for (x, y) in
itertools.izip(target, mask)]
def set_nd_target(self, target):
self.flow.nd_target = target
def flow_format(self): def flow_format(self):
# Tunnel ID is only supported by NXM # Tunnel ID is only supported by NXM
if self.wc.tun_id_mask != 0: if self.wc.tun_id_mask != 0:
@ -565,6 +575,20 @@ class MFIPV6Dst(MFField):
rule.wc.ipv6_dst_mask) rule.wc.ipv6_dst_mask)
@_register_make
@_set_nxm_headers([ofproto_v1_0.NXM_NX_ND_TARGET,
ofproto_v1_0.NXM_NX_ND_TARGET_W])
class MFNdTarget(MFField):
@classmethod
def make(cls):
return cls('!4I')
def put(self, buf, offset, rule):
return self.putv6(buf, offset,
rule.flow.nd_target,
rule.wc.nd_target_mask)
@_register_make @_register_make
@_set_nxm_headers([ofproto_v1_0.NXM_NX_ARP_THA]) @_set_nxm_headers([ofproto_v1_0.NXM_NX_ARP_THA])
class MFArpTha(MFField): class MFArpTha(MFField):
@ -754,6 +778,13 @@ def serialize_nxm_match(rule, buf, offset):
header = ofproto_v1_0.NXM_NX_IPV6_DST header = ofproto_v1_0.NXM_NX_IPV6_DST
offset += nxm_put(buf, offset, header, rule) offset += nxm_put(buf, offset, header, rule)
if len(rule.flow.nd_target):
if len(rule.wc.nd_target_mask):
header = ofproto_v1_0.NXM_NX_ND_TARGET_W
else:
header = ofproto_v1_0.NXM_NX_ND_TARGET
offset += nxm_put(buf, offset, header, rule)
# ARP # ARP
if rule.flow.arp_spa != 0: if rule.flow.arp_spa != 0:
if rule.wc.arp_spa_mask == UINT32_MAX: if rule.wc.arp_spa_mask == UINT32_MAX:

View File

@ -715,6 +715,9 @@ NXM_NX_IPV6_DST_W = nxm_header_w(0x0001, 20, 16)
NXM_NX_ICMPV6_TYPE = nxm_header(0x0001, 21, 1) NXM_NX_ICMPV6_TYPE = nxm_header(0x0001, 21, 1)
NXM_NX_ICMPV6_CODE = nxm_header(0x0001, 22, 1) NXM_NX_ICMPV6_CODE = nxm_header(0x0001, 22, 1)
NXM_NX_ND_TARGET = nxm_header(0x0001, 23, 16)
NXM_NX_ND_TARGET_W = nxm_header_w(0x0001, 23, 16)
NXM_NX_ND_SLL = nxm_header(0x0001, 24, 6) NXM_NX_ND_SLL = nxm_header(0x0001, 24, 6)
NXM_NX_ND_TLL = nxm_header(0x0001, 25, 6) NXM_NX_ND_TLL = nxm_header(0x0001, 25, 6)