summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYusuke Iwase <iwase.yusuke0@gmail.com>2015-09-17 16:28:09 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-18 08:30:29 +0900
commit4ada0bbd9c5855ea1273a19a75082c4726554ea3 (patch)
tree759f53e891fb1593337acfa3899521d524447aa2
parent81208354e95569cbf8dbee5c8c4d0a6500fec0ca (diff)
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>
-rw-r--r--ryu/ofproto/nx_match.py35
-rw-r--r--ryu/ofproto/ofproto_v1_2.py10
-rw-r--r--ryu/ofproto/ofproto_v1_3.py27
-rw-r--r--ryu/ofproto/ofproto_v1_4.py11
-rw-r--r--ryu/ofproto/ofproto_v1_5.py10
5 files changed, 55 insertions, 38 deletions
diff --git a/ryu/ofproto/nx_match.py b/ryu/ofproto/nx_match.py
index 86d39a84..b48888d9 100644
--- a/ryu/ofproto/nx_match.py
+++ b/ryu/ofproto/nx_match.py
@@ -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),
+]
diff --git a/ryu/ofproto/ofproto_v1_2.py b/ryu/ofproto/ofproto_v1_2.py
index a53b4bf1..adf131cf 100644
--- a/ryu/ofproto/ofproto_v1_2.py
+++ b/ryu/ofproto/ofproto_v1_2.py
@@ -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__)
diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index cf7a48d5..6b31ec2a 100644
--- a/ryu/ofproto/ofproto_v1_3.py
+++ b/ryu/ofproto/ofproto_v1_3.py
@@ -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__)
diff --git a/ryu/ofproto/ofproto_v1_4.py b/ryu/ofproto/ofproto_v1_4.py
index 250c0e12..3f107eb7 100644
--- a/ryu/ofproto/ofproto_v1_4.py
+++ b/ryu/ofproto/ofproto_v1_4.py
@@ -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__)
diff --git a/ryu/ofproto/ofproto_v1_5.py b/ryu/ofproto/ofproto_v1_5.py
index 9e58e798..45191dd8 100644
--- a/ryu/ofproto/ofproto_v1_5.py
+++ b/ryu/ofproto/ofproto_v1_5.py
@@ -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__)