ofproto: Sort out the NX OXMs definition

Because the Nicira Experimenter OXMs are independent of the OpenFlow
version, this patch separates the NX OXMs definitions into nx_match.py
and enable to use the NX OXM in all OpenFlow 1.2+.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Yusuke Iwase 2015-09-17 16:28:09 +09:00 committed by FUJITA Tomonori
parent 81208354e9
commit 4ada0bbd9c
5 changed files with 55 additions and 38 deletions

View File

@ -1,4 +1,4 @@
# Copyright (C) 2011, 2012 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011-2015 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2011, 2012 Isaku Yamahata <yamahata at valinux co jp>
# Copyright (C) 2012 Simon Horman <horms ad verge net au>
#
@ -19,10 +19,12 @@ import struct
from ryu import exception
from ryu.lib import mac
from ryu.lib import type_desc
from ryu.lib.pack_utils import msg_pack_into
from ryu.ofproto import ofproto_parser
from ryu.ofproto import ofproto_v1_0
from ryu.ofproto import inet
from ryu.ofproto import oxm_fields
import logging
LOG = logging.getLogger('ryu.ofproto.nx_match')
@ -1186,3 +1188,34 @@ class NXMatch(object):
msg_pack_into(ofproto_v1_0.NXM_HEADER_PACK_STRING,
buf, offset, self.header)
return struct.calcsize(ofproto_v1_0.NXM_HEADER_PACK_STRING)
#
# The followings are implementations for OpenFlow 1.2+
#
oxm_types = [
oxm_fields.NiciraExtended0('eth_dst_nxm', 1, type_desc.MacAddr),
oxm_fields.NiciraExtended0('eth_src_nxm', 2, type_desc.MacAddr),
oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8),
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.
# Following Open vSwitch, we use dp_hash for this purpose.
# Prefix the name with '_' to indicate this is not intended to be used
# in wild.
oxm_fields.NiciraExperimenter('_dp_hash', 0, type_desc.Int4),
# Support for matching/setting NX registers 0-7
oxm_fields.NiciraExtended1('reg0', 0, type_desc.Int4),
oxm_fields.NiciraExtended1('reg1', 1, type_desc.Int4),
oxm_fields.NiciraExtended1('reg2', 2, type_desc.Int4),
oxm_fields.NiciraExtended1('reg3', 3, type_desc.Int4),
oxm_fields.NiciraExtended1('reg4', 4, type_desc.Int4),
oxm_fields.NiciraExtended1('reg5', 5, type_desc.Int4),
oxm_fields.NiciraExtended1('reg6', 6, type_desc.Int4),
oxm_fields.NiciraExtended1('reg7', 7, type_desc.Int4),
]

View File

@ -19,6 +19,7 @@ OpenFlow 1.2 definitions.
"""
from ryu.lib import type_desc
from ryu.ofproto import nx_match
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
@ -828,7 +829,14 @@ oxm_types = [
oxm_fields.OpenFlowBasic('ipv6_nd_tll', 33, type_desc.MacAddr),
oxm_fields.OpenFlowBasic('mpls_label', 34, type_desc.Int4),
oxm_fields.OpenFlowBasic('mpls_tc', 35, type_desc.Int1),
]
# EXT-256 Old version of ONF Extension
oxm_fields.OldONFExperimenter('pbb_uca', 2560, type_desc.Int1),
# EXT-109 TCP flags match field Extension
oxm_fields.ONFExperimenter('tcp_flags', 42, type_desc.Int2),
# EXT-233 Output match Extension
# NOTE(yamamoto): The spec says uint64_t but I assume it's an error.
oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
] + nx_match.oxm_types
oxm_fields.generate(__name__)

View File

@ -19,6 +19,7 @@ OpenFlow 1.3 definitions.
"""
from ryu.lib import type_desc
from ryu.ofproto import nx_match
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
@ -1151,9 +1152,7 @@ oxm_types = [
oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4),
oxm_fields.OpenFlowBasic('metadata', 2, type_desc.Int8),
oxm_fields.OpenFlowBasic('eth_dst', 3, type_desc.MacAddr),
oxm_fields.NiciraExtended0('eth_dst_nxm', 1, type_desc.MacAddr),
oxm_fields.OpenFlowBasic('eth_src', 4, type_desc.MacAddr),
oxm_fields.NiciraExtended0('eth_src_nxm', 2, type_desc.MacAddr),
oxm_fields.OpenFlowBasic('eth_type', 5, type_desc.Int2),
oxm_fields.OpenFlowBasic('vlan_vid', 6, type_desc.Int2),
oxm_fields.OpenFlowBasic('vlan_pcp', 7, type_desc.Int1),
@ -1188,35 +1187,15 @@ oxm_types = [
oxm_fields.OpenFlowBasic('mpls_bos', 36, type_desc.Int1),
oxm_fields.OpenFlowBasic('pbb_isid', 37, type_desc.Int3),
oxm_fields.OpenFlowBasic('tunnel_id', 38, type_desc.Int8),
oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8),
oxm_fields.OpenFlowBasic('ipv6_exthdr', 39, type_desc.Int2),
# EXT-256 Old version of ONF Extension
oxm_fields.OldONFExperimenter('pbb_uca', 2560, type_desc.Int1),
# EXT-109 TCP flags match field Extension
oxm_fields.ONFExperimenter('tcp_flags', 42, type_desc.Int2),
# EXT-233 Output match Extension
# NOTE(yamamoto): The spec says uint64_t but I assume it's an error.
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.
# Following Open vSwitch, we use dp_hash for this purpose.
# Prefix the name with '_' to indicate this is not intended to be used
# in wild.
oxm_fields.NiciraExperimenter('_dp_hash', 0, type_desc.Int4),
# Support for matching/setting NX registers 1-7
oxm_fields.NiciraExtended1('reg0', 0, type_desc.Int4),
oxm_fields.NiciraExtended1('reg1', 1, type_desc.Int4),
oxm_fields.NiciraExtended1('reg2', 2, type_desc.Int4),
oxm_fields.NiciraExtended1('reg3', 3, type_desc.Int4),
oxm_fields.NiciraExtended1('reg4', 4, type_desc.Int4),
oxm_fields.NiciraExtended1('reg5', 5, type_desc.Int4),
oxm_fields.NiciraExtended1('reg6', 6, type_desc.Int4),
oxm_fields.NiciraExtended1('reg7', 7, type_desc.Int4),
]
] + nx_match.oxm_types
oxm_fields.generate(__name__)

View File

@ -19,6 +19,7 @@ OpenFlow 1.4 definitions.
"""
from ryu.lib import type_desc
from ryu.ofproto import nx_match
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
@ -390,10 +391,12 @@ oxm_types = [
oxm_fields.OpenFlowBasic('tunnel_id', 38, type_desc.Int8),
oxm_fields.OpenFlowBasic('ipv6_exthdr', 39, type_desc.Int2),
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),
]
# EXT-109 TCP flags match field Extension
oxm_fields.ONFExperimenter('tcp_flags', 42, type_desc.Int2),
# EXT-233 Output match Extension
# NOTE(yamamoto): The spec says uint64_t but I assume it's an error.
oxm_fields.ONFExperimenter('actset_output', 43, type_desc.Int4),
] + nx_match.oxm_types
oxm_fields.generate(__name__)

View File

@ -19,6 +19,7 @@ OpenFlow 1.5 definitions.
"""
from ryu.lib import type_desc
from ryu.ofproto import nx_match
from ryu.ofproto import ofproto_utils
from ryu.ofproto import oxm_fields
from ryu.ofproto import oxs_fields
@ -390,9 +391,7 @@ oxm_types = [
oxm_fields.OpenFlowBasic('in_phy_port', 1, type_desc.Int4),
oxm_fields.OpenFlowBasic('metadata', 2, type_desc.Int8),
oxm_fields.OpenFlowBasic('eth_dst', 3, type_desc.MacAddr),
oxm_fields.NiciraExtended0('eth_dst_nxm', 1, type_desc.MacAddr),
oxm_fields.OpenFlowBasic('eth_src', 4, type_desc.MacAddr),
oxm_fields.NiciraExtended0('eth_src_nxm', 2, type_desc.MacAddr),
oxm_fields.OpenFlowBasic('eth_type', 5, type_desc.Int2),
oxm_fields.OpenFlowBasic('vlan_vid', 6, type_desc.Int2),
oxm_fields.OpenFlowBasic('vlan_pcp', 7, type_desc.Int1),
@ -427,17 +426,12 @@ oxm_types = [
oxm_fields.OpenFlowBasic('mpls_bos', 36, type_desc.Int1),
oxm_fields.OpenFlowBasic('pbb_isid', 37, type_desc.Int3),
oxm_fields.OpenFlowBasic('tunnel_id', 38, type_desc.Int8),
oxm_fields.NiciraExtended1('tunnel_id_nxm', 16, type_desc.Int8),
oxm_fields.OpenFlowBasic('ipv6_exthdr', 39, type_desc.Int2),
oxm_fields.OpenFlowBasic('pbb_uca', 41, type_desc.Int1),
oxm_fields.OpenFlowBasic('tcp_flags', 42, type_desc.Int2),
oxm_fields.OpenFlowBasic('actset_output', 43, type_desc.Int4),
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),
]
] + nx_match.oxm_types
oxm_fields.generate(__name__)