nxm: add NXM_NX_IP_TTL support

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Reviewed-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
FUJITA Tomonori
2012-06-10 09:37:00 +09:00
parent 500c744f96
commit b7d38440f8
2 changed files with 21 additions and 0 deletions

View File

@@ -38,6 +38,7 @@ FWW_DL_TYPE = 1 << 4
FWW_ETH_MCAST = 1 << 1
FWW_NW_DSCP = 1 << 6
FWW_NW_ECN = 1 << 7
FWW_NW_TTL = 1 << 8
FWW_ALL = (1 << 13) - 1
# Ethernet types, for set_dl_type()
@@ -66,6 +67,7 @@ class Flow(object):
self.dl_type = 0
self.nw_tos = 0
self.vlan_tci = 0
self.nw_ttl = 0
class FlowWildcards(object):
@@ -165,6 +167,10 @@ class ClsRule(object):
self.flow.nw_tos &= ~IP_ECN_MASK
self.flow.nw_tos |= nw_ecn & IP_ECN_MASK
def set_nw_ttl(self, nw_ttl):
self.wc.wildcards &= ~FWW_NW_TTL
self.flow.nw_ttl = nw_ttl
def flow_format(self):
# Tunnel ID is only supported by NXM
if self.wc.tun_id_mask != 0:
@@ -359,6 +365,17 @@ class MFIPECN(MFField):
rule.flow.nw_tos & IP_ECN_MASK)
@_register_make
@_set_nxm_headers([ofproto_v1_0.NXM_NX_IP_TTL])
class MFIPTTL(MFField):
@classmethod
def make(cls):
return cls(MF_PACK_STRING_8)
def put(self, buf, offset, rule):
return self._put(buf, offset, rule.flow.nw_ttl)
def serialize_nxm_match(rule, buf, offset):
old_offset = offset
@@ -385,6 +402,8 @@ def serialize_nxm_match(rule, buf, offset):
offset += nxm_put(buf, offset, ofproto_v1_0.NXM_OF_IP_TOS, rule)
if not rule.wc.wildcards & FWW_NW_ECN:
offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_IP_ECN, rule)
if not rule.wc.wildcards & FWW_NW_TTL:
offset += nxm_put(buf, offset, ofproto_v1_0.NXM_NX_IP_TTL, rule)
# XXX: IP Source and Destination
# XXX: IPv6
# XXX: ARP

View File

@@ -715,6 +715,8 @@ NXM_NX_ND_TLL = nxm_header(0x0001, 25, 6)
NXM_NX_IP_ECN = nxm_header(0x0001, 28, 1)
NXM_NX_IP_TTL = nxm_header(0x0001, 29, 1)
def nxm_nx_reg(idx):
return nxm_header(0x0001, idx, 4)