summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/source/nicira_ext_ref.rst2
-rw-r--r--ryu/ofproto/nicira_ext.py2
-rw-r--r--ryu/ofproto/nx_actions.py138
3 files changed, 142 insertions, 0 deletions
diff --git a/doc/source/nicira_ext_ref.rst b/doc/source/nicira_ext_ref.rst
index 2518536f..13850796 100644
--- a/doc/source/nicira_ext_ref.rst
+++ b/doc/source/nicira_ext_ref.rst
@@ -45,6 +45,7 @@ The followings shows the supported NXAction classes in OpenFlow1.0 or later
.. autoclass:: NXActionStackPush
.. autoclass:: NXActionStackPop
.. autoclass:: NXActionSample
+.. autoclass:: NXActionSample2
.. autoclass:: NXActionFinTimeout
.. autoclass:: NXActionConjunction
.. autoclass:: NXActionMultipath
@@ -52,6 +53,7 @@ The followings shows the supported NXAction classes in OpenFlow1.0 or later
.. autoclass:: NXActionBundleLoad
.. autoclass:: NXActionCT
.. autoclass:: NXActionNAT
+.. autoclass:: NXActionOutputTrunc
.. autoclass:: NXFlowSpecMatch
.. autoclass:: NXFlowSpecLoad
.. autoclass:: NXFlowSpecOutput
diff --git a/ryu/ofproto/nicira_ext.py b/ryu/ofproto/nicira_ext.py
index 5306b59f..57c62c6b 100644
--- a/ryu/ofproto/nicira_ext.py
+++ b/ryu/ofproto/nicira_ext.py
@@ -60,6 +60,8 @@ NXAST_CONJUNCTION = 34
NXAST_CT = 35
NXAST_NAT = 36
NXAST_CONTROLLER2 = 37
+NXAST_SAMPLE2 = 38
+NXAST_OUTPUT_TRUNC = 39
NX_ACTION_RESUBMIT_PACK_STR = '!HHIHHB3x'
NX_ACTION_RESUBMIT_SIZE = 16
diff --git a/ryu/ofproto/nx_actions.py b/ryu/ofproto/nx_actions.py
index 7f3a7641..94c2213a 100644
--- a/ryu/ofproto/nx_actions.py
+++ b/ryu/ofproto/nx_actions.py
@@ -2163,6 +2163,87 @@ def generate(ofp_name, ofpp_name):
self.obs_point_id)
return data
+ class NXActionSample2(NXAction):
+ """
+ Sample packets action
+
+ This action samples packets and sends one sample for
+ every sampled packet.
+ 'sampling_port' can be equal to ingress port or one of egress ports.
+
+ And equivalent to the followings action of ovs-ofctl command.
+
+ ..
+ sample(argument[,argument]...)
+ ..
+
+ +----------------------------------------------------+
+ | **sample(**\ *argument*\[,\ *argument*\]...\ **)** |
+ +----------------------------------------------------+
+
+ ================ ======================================================
+ Attribute Description
+ ================ ======================================================
+ probability The number of sampled packets
+ collector_set_id The unsigned 32-bit integer identifier of
+ the set of sample collectors to send sampled packets to
+ obs_domain_id The Unsigned 32-bit integer Observation Domain ID
+ obs_point_id The unsigned 32-bit integer Observation Point ID
+ sampling_port Sampling port number
+ ================ ======================================================
+
+ Example::
+
+ actions += [parser.NXActionSample2(probability=3,
+ collector_set_id=1,
+ obs_domain_id=2,
+ obs_point_id=3,
+ sampling_port=8080)]
+ """
+ _subtype = nicira_ext.NXAST_SAMPLE2
+
+ # probability, collector_set_id, obs_domain_id,
+ # obs_point_id, sampling_port
+ _fmt_str = '!HIIIH6x'
+
+ def __init__(self,
+ probability,
+ collector_set_id=0,
+ obs_domain_id=0,
+ obs_point_id=0,
+ sampling_port=0,
+ type_=None, len_=None, experimenter=None, subtype=None):
+ super(NXActionSample2, self).__init__()
+ self.probability = probability
+ self.collector_set_id = collector_set_id
+ self.obs_domain_id = obs_domain_id
+ self.obs_point_id = obs_point_id
+ self.sampling_port = sampling_port
+
+ @classmethod
+ def parser(cls, buf):
+ (probability,
+ collector_set_id,
+ obs_domain_id,
+ obs_point_id,
+ sampling_port) = struct.unpack_from(
+ cls._fmt_str, buf, 0)
+ return cls(probability,
+ collector_set_id,
+ obs_domain_id,
+ obs_point_id,
+ sampling_port)
+
+ def serialize_body(self):
+ data = bytearray()
+ msg_pack_into(self._fmt_str, data, 0,
+ self.probability,
+ self.collector_set_id,
+ self.obs_domain_id,
+ self.obs_point_id,
+ self.sampling_port)
+ return data
+
class NXActionFinTimeout(NXAction):
"""
Change TCP timeout action
@@ -2864,6 +2945,61 @@ def generate(ofp_name, ofpp_name):
return data
+ class NXActionOutputTrunc(NXAction):
+ """
+ Truncate output action
+
+ This action truncate a packet into the specified size and outputs it.
+
+ And equivalent to the followings action of ovs-ofctl command.
+
+ ..
+ output(port=port,max_len=max_len)
+ ..
+
+ +--------------------------------------------------------------+
+ | **output(port**\=\ *port*\,\ **max_len**\=\ *max_len*\ **)** |
+ +--------------------------------------------------------------+
+
+ ================ ======================================================
+ Attribute Description
+ ================ ======================================================
+ port Output port
+ max_len Max bytes to send
+ ================ ======================================================
+
+ Example::
+
+ actions += [parser.NXActionOutputTrunc(port=8080,
+ max_len=1024)]
+ """
+ _subtype = nicira_ext.NXAST_OUTPUT_TRUNC
+
+ # port, max_len
+ _fmt_str = '!HI'
+
+ def __init__(self,
+ port,
+ max_len,
+ type_=None, len_=None, experimenter=None, subtype=None):
+ super(NXActionOutputTrunc, self).__init__()
+ self.port = port
+ self.max_len = max_len
+
+ @classmethod
+ def parser(cls, buf):
+ (port,
+ max_len) = struct.unpack_from(
+ cls._fmt_str, buf, 0)
+ return cls(port, max_len)
+
+ def serialize_body(self):
+ data = bytearray()
+ msg_pack_into(self._fmt_str, data, 0,
+ self.port,
+ self.max_len)
+ return data
+
def add_attr(k, v):
v.__module__ = ofpp.__name__ # Necessary for stringify stuff
setattr(ofpp, k, v)
@@ -2899,6 +3035,7 @@ def generate(ofp_name, ofpp_name):
'NXActionStackPush',
'NXActionStackPop',
'NXActionSample',
+ 'NXActionSample2',
'NXActionFinTimeout',
'NXActionConjunction',
'NXActionMultipath',
@@ -2906,6 +3043,7 @@ def generate(ofp_name, ofpp_name):
'NXActionBundleLoad',
'NXActionCT',
'NXActionNAT',
+ 'NXActionOutputTrunc',
'_NXFlowSpec', # exported for testing
'NXFlowSpecMatch',
'NXFlowSpecLoad',