of14: Update get async reply and set async implementation to follow spec

The current get async reply and get async implementations follows that of
of_protocol and OpenFlow 1.3. However, OpenFlow 1.4 defines a rather
different format. This patch updates the implementation to follow the
OpenFlow 1.4 specification.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Simon Horman 2014-03-11 10:42:07 +09:00 committed by FUJITA Tomonori
parent f9888ba941
commit c0a1fd6d99
7 changed files with 361 additions and 118 deletions

View File

@ -5680,7 +5680,7 @@ class OFPAsyncConfigPropReasons(StringifyMixin):
@OFPAsyncConfigProp.register_type(ofproto.OFPTFPT_EXPERIMENTER_SLAVE)
@OFPAsyncConfigProp.register_type(ofproto.OFPTFPT_EXPERIMENTER_MASTER)
class OFPQueueDescPropExperimenter(OFPPropCommonExperimenter4ByteData):
class OFPAsyncConfigPropExperimenter(OFPPropCommonExperimenter4ByteData):
pass
@ -5715,24 +5715,7 @@ class OFPGetAsyncReply(MsgBase):
================== ====================================================
Attribute Description
================== ====================================================
packet_in_mask 2-element array: element 0, when the controller has a
OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER role. element 1,
OFPCR_ROLE_SLAVE role controller.
Bitmasks of following values.
OFPR_NO_MATCH
OFPR_ACTION
OFPR_INVALID_TTL
port_status_mask 2-element array.
Bitmasks of following values.
OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY
flow_removed_mask 2-element array.
Bitmasks of following values.
OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE
properties List of ``OFPAsyncConfigProp`` subclass instances
================== ====================================================
Example::
@ -5742,36 +5725,24 @@ class OFPGetAsyncReply(MsgBase):
msg = ev.msg
self.logger.debug('OFPGetAsyncReply received: '
'packet_in_mask=0x%08x:0x%08x '
'port_status_mask=0x%08x:0x%08x '
'flow_removed_mask=0x%08x:0x%08x',
msg.packet_in_mask[0],
msg.packet_in_mask[1],
msg.port_status_mask[0],
msg.port_status_mask[1],
msg.flow_removed_mask[0],
msg.flow_removed_mask[1])
'properties=%s', repr(msg.properties))
"""
def __init__(self, datapath, packet_in_mask=None, port_status_mask=None,
flow_removed_mask=None):
def __init__(self, datapath, properties=None):
super(OFPGetAsyncReply, self).__init__(datapath)
self.packet_in_mask = packet_in_mask
self.port_status_mask = port_status_mask
self.flow_removed_mask = flow_removed_mask
self.properties = properties
@classmethod
def parser(cls, datapath, version, msg_type, msg_len, xid, buf):
msg = super(OFPGetAsyncReply, cls).parser(datapath, version,
msg_type, msg_len,
xid, buf)
(packet_in_mask_m, packet_in_mask_s,
port_status_mask_m, port_status_mask_s,
flow_removed_mask_m, flow_removed_mask_s) = struct.unpack_from(
ofproto.OFP_ASYNC_CONFIG_PACK_STR, msg.buf,
ofproto.OFP_HEADER_SIZE)
msg.packet_in_mask = [packet_in_mask_m, packet_in_mask_s]
msg.port_status_mask = [port_status_mask_m, port_status_mask_s]
msg.flow_removed_mask = [flow_removed_mask_m, flow_removed_mask_s]
msg.properties = []
rest = msg.buf[ofproto.OFP_HEADER_SIZE:]
while rest:
p, rest = OFPAsyncConfigProp.parse(rest)
msg.properties.append(p)
return msg
@ -5786,24 +5757,7 @@ class OFPSetAsync(MsgBase):
================== ====================================================
Attribute Description
================== ====================================================
packet_in_mask 2-element array: element 0, when the controller has a
OFPCR_ROLE_EQUAL or OFPCR_ROLE_MASTER role. element 1,
OFPCR_ROLE_SLAVE role controller.
Bitmasks of following values.
OFPR_NO_MATCH
OFPR_ACTION
OFPR_INVALID_TTL
port_status_mask 2-element array.
Bitmasks of following values.
OFPPR_ADD
OFPPR_DELETE
OFPPR_MODIFY
flow_removed_mask 2-element array.
Bitmasks of following values.
OFPRR_IDLE_TIMEOUT
OFPRR_HARD_TIMEOUT
OFPRR_DELETE
OFPRR_GROUP_DELETE
properties List of ``OFPAsyncConfigProp`` subclass instances
================== ====================================================
Example::
@ -5812,28 +5766,23 @@ class OFPSetAsync(MsgBase):
ofp = datapath.ofproto
ofp_parser = datapath.ofproto_parser
packet_in_mask = ofp.OFPR_ACTION | ofp.OFPR_INVALID_TTL
port_status_mask = (ofp.OFPPR_ADD | ofp.OFPPR_DELETE |
ofp.OFPPR_MODIFY)
flow_removed_mask = (ofp.OFPRR_IDLE_TIMEOUT |
ofp.OFPRR_HARD_TIMEOUT |
ofp.OFPRR_DELETE)
req = ofp_parser.OFPSetAsync(datapath,
[packet_in_mask, 0],
[port_status_mask, 0],
[flow_removed_mask, 0])
properties = [ofp_parser.OFPAsyncConfigPropReasons(
8, ofp_parser.OFPACPT_PACKET_IN_SLAVE,
(ofp_parser.OFPR_APPLY_ACTION |
ofp_parser.OFPR_INVALID_TTL)),
ofp_parser.OFPAsyncConfigPropExperimenter(
ofproto.OFPTFPT_EXPERIMENTER_MASTER,
16, 100, 2, bytearray())]
req = ofp_parser.OFPSetAsync(datapath, properties)
datapath.send_msg(req)
"""
def __init__(self, datapath,
packet_in_mask, port_status_mask, flow_removed_mask):
def __init__(self, datapath, properties=None):
super(OFPSetAsync, self).__init__(datapath)
self.packet_in_mask = packet_in_mask
self.port_status_mask = port_status_mask
self.flow_removed_mask = flow_removed_mask
self.properties = properties
def _serialize_body(self):
msg_pack_into(ofproto.OFP_ASYNC_CONFIG_PACK_STR, self.buf,
ofproto.OFP_HEADER_SIZE,
self.packet_in_mask[0], self.packet_in_mask[1],
self.port_status_mask[0], self.port_status_mask[1],
self.flow_removed_mask[0], self.flow_removed_mask[1])
bin_props = bytearray()
for p in self.properties:
bin_props += p.serialize()
self.buf += bin_props

View File

@ -18,9 +18,12 @@
[{of_protocol, ".*",
% {git, "https://github.com/FlowForwarding/of_protocol.git",
% "5d6a938bcac91d03e4542845bc014a271bab363a"}},
% use local branch for merge of v5 branch and pull/66
% use local branch for merge of upstream v5 branch with pull 66 and 71
% https://github.com/FlowForwarding/of_protocol/tree/v5
% https://github.com/FlowForwarding/of_protocol/pull/66
% https://github.com/FlowForwarding/of_protocol/pull/71
{git, "https://github.com/horms/of_protocol.git",
"36f81a2390586c4298c34b8a6dd7c929edbac707"}},
"6764e8f0ed5c4dee913310bf2bd908ab1768603e"}},
{flower, ".*",
{git, "http://github.com/travelping/flower.git",
"d783d8f722cb1eb2fa598d4521b309cfcc703fdb"}}]}.

View File

@ -701,22 +701,111 @@ x() ->
},
#ofp_get_async_request{},
#ofp_get_async_reply{
packet_in_mask = {[table_miss, invalid_ttl], [table_miss]},
port_status_mask = {[add, delete, modify], [add, delete]},
flow_removed_mask = {
[idle_timeout, hard_timeout, delete, group_delete],
[idle_timeout, hard_timeout]
}
},
properties =
[#ofp_async_config_prop_reasons{
type = packet_in_slave,
mask = [table_miss, apply_action]},
#ofp_async_config_prop_reasons{
type = packet_in_master,
mask = [table_miss, apply_action]},
#ofp_async_config_prop_reasons{
type = port_status_slave,
mask = [add, delete]},
#ofp_async_config_prop_reasons{
type = port_status_master,
mask = [add, delete]},
#ofp_async_config_prop_reasons{
type = flow_removed_slave,
mask = [idle_timeout, hard_timeout]},
#ofp_async_config_prop_reasons{
type = flow_removed_master,
mask = [idle_timeout, hard_timeout]},
#ofp_async_config_prop_reasons{
type = role_status_slave,
mask = [master_request, config]},
#ofp_async_config_prop_reasons{
type = role_status_master,
mask = [master_request, config]},
#ofp_async_config_prop_reasons{
type = table_status_slave,
mask = [vacancy_down, vacancy_up]},
#ofp_async_config_prop_reasons{
type = table_status_master,
mask = [vacancy_down, vacancy_up]},
#ofp_async_config_prop_reasons{
type = requestforward_slave,
mask = [group_mod, meter_mod]},
#ofp_async_config_prop_reasons{
type = requestforward_master,
mask = [group_mod, meter_mod]},
#ofp_async_config_prop_experimenter{
type = experimenter_slave,
experimenter = 101,
exp_type = 0,
data = <<>>},
#ofp_async_config_prop_experimenter{
type = experimenter_master,
experimenter = 101,
exp_type = 1,
data = <<1:32>>},
#ofp_async_config_prop_experimenter{
type = experimenter_master,
experimenter = 101,
exp_type = 2,
data = <<1:32, 2:32>>}]},
#ofp_set_async{
packet_in_mask = {[table_miss, invalid_ttl], [table_miss]},
port_status_mask = {[add, delete, modify], [add, delete]},
flow_removed_mask = {
[idle_timeout, hard_timeout, delete, group_delete],
[idle_timeout, hard_timeout]
}
},
properties =
[#ofp_async_config_prop_reasons{
type = packet_in_slave,
mask = [table_miss, apply_action]},
#ofp_async_config_prop_reasons{
type = packet_in_master,
mask = [table_miss, apply_action]},
#ofp_async_config_prop_reasons{
type = port_status_slave,
mask = [add, delete]},
#ofp_async_config_prop_reasons{
type = port_status_master,
mask = [add, delete]},
#ofp_async_config_prop_reasons{
type = flow_removed_slave,
mask = [idle_timeout, hard_timeout]},
#ofp_async_config_prop_reasons{
type = flow_removed_master,
mask = [idle_timeout, hard_timeout]},
#ofp_async_config_prop_reasons{
type = role_status_slave,
mask = [master_request, config]},
#ofp_async_config_prop_reasons{
type = role_status_master,
mask = [master_request, config]},
#ofp_async_config_prop_reasons{
type = table_status_slave,
mask = [vacancy_down, vacancy_up]},
#ofp_async_config_prop_reasons{
type = table_status_master,
mask = [vacancy_down, vacancy_up]},
#ofp_async_config_prop_reasons{
type = requestforward_slave,
mask = [group_mod, meter_mod]},
#ofp_async_config_prop_reasons{
type = requestforward_master,
mask = [group_mod, meter_mod]},
#ofp_async_config_prop_experimenter{
type = experimenter_slave,
experimenter = 101,
exp_type = 0,
data = <<>>},
#ofp_async_config_prop_experimenter{
type = experimenter_master,
experimenter = 101,
exp_type = 1,
data = <<1:32>>},
#ofp_async_config_prop_experimenter{
type = experimenter_master,
experimenter = 101,
exp_type = 2,
data = <<1:32, 2:32>>}]},
#ofp_meter_mod{
command = add,
flags = [pktps, burst, stats],

View File

@ -1,16 +1,117 @@
{
"OFPGetAsyncReply": {
"flow_removed_mask": [
15,
3
],
"packet_in_mask": [
5,
1
],
"port_status_mask": [
7,
3
"properties": [
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 0
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 1
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 2
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 3
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 4
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 5
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 6
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 7
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 24,
"type": 8
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 24,
"type": 9
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 10
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 11
}
},
{
"OFPAsyncConfigPropExperimenter": {
"data": "",
"exp_type": 0,
"experimenter": 101,
"length": 12,
"type": 65534
}
},
{
"OFPAsyncConfigPropExperimenter": {
"data": "AAAAAQ==",
"exp_type": 1,
"experimenter": 101,
"length": 16,
"type": 65535
}
},
{
"OFPAsyncConfigPropExperimenter": {
"data": "AAAAAQAAAAI=",
"exp_type": 2,
"experimenter": 101,
"length": 20,
"type": 65535
}
}
]
}
}

View File

@ -1,16 +1,117 @@
{
"OFPSetAsync": {
"flow_removed_mask": [
15,
3
],
"packet_in_mask": [
5,
1
],
"port_status_mask": [
7,
3
"properties": [
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 0
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 1
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 2
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 3
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 4
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 5
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 6
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 7
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 24,
"type": 8
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 24,
"type": 9
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 10
}
},
{
"OFPAsyncConfigPropReasons": {
"length": 8,
"mask": 3,
"type": 11
}
},
{
"OFPAsyncConfigPropExperimenter": {
"data": "",
"exp_type": 0,
"experimenter": 101,
"length": 12,
"type": 65534
}
},
{
"OFPAsyncConfigPropExperimenter": {
"data": "AAAAAQ==",
"exp_type": 1,
"experimenter": 101,
"length": 16,
"type": 65535
}
},
{
"OFPAsyncConfigPropExperimenter": {
"data": "AAAAAQAAAAI=",
"exp_type": 2,
"experimenter": 101,
"length": 20,
"type": 65535
}
}
]
}
}