ofproto/nx_actions: Support some NXAction

Actions to be added are as following.
 - NXActionSample2
 - NXActionOutputTrunc

Signed-off-by: Shinpei Muraoka <shinpei.muraoka@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Shinpei Muraoka 2016-07-11 10:44:21 +09:00 committed by FUJITA Tomonori
parent eed14371b8
commit 0288ae2cfa
3 changed files with 142 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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',