2013-07-23 21:04:04 +09:00
|
|
|
# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
|
|
# implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2014-01-06 16:46:51 +09:00
|
|
|
import base64
|
2013-07-23 21:04:04 +09:00
|
|
|
import logging
|
|
|
|
|
ofctl_v1_2/3: fix match conditions about ARP
ofctl_v1_0 has changed nw_src/dst into ipv4_src/dst or arp_spa/tpa automatically like ovs-ofctl.
since ofctl_v1_2/3 change nw_src/dst only into ipv4_src/dst, it cannot create the match conditions which use arp_spa/tpa.
this patch fixes this problem.
before applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
no flow entry was installed.
after applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=2.555s, table=0, n_packets=0, n_bytes=0, priority=0,arp,arp_spa=192.168.0.0/24 actions=output:2
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-14 13:58:20 +09:00
|
|
|
from ryu.ofproto import ether
|
2013-07-23 21:04:04 +09:00
|
|
|
from ryu.ofproto import inet
|
2016-03-29 19:18:37 +00:00
|
|
|
from ryu.ofproto import ofproto_common
|
2013-07-23 21:04:04 +09:00
|
|
|
from ryu.ofproto import ofproto_v1_3
|
|
|
|
from ryu.ofproto import ofproto_v1_3_parser
|
2016-03-29 19:18:37 +00:00
|
|
|
from ryu.lib import ofctl_nicira_ext
|
2016-01-19 13:46:10 +09:00
|
|
|
from ryu.lib import ofctl_utils
|
2013-07-23 21:04:04 +09:00
|
|
|
|
|
|
|
|
|
|
|
LOG = logging.getLogger('ryu.lib.ofctl_v1_3')
|
|
|
|
|
|
|
|
DEFAULT_TIMEOUT = 1.0
|
|
|
|
|
2016-01-19 13:46:10 +09:00
|
|
|
UTIL = ofctl_utils.OFCtlUtil(ofproto_v1_3)
|
2017-02-09 16:44:35 +09:00
|
|
|
str_to_int = ofctl_utils.str_to_int
|
2013-12-20 11:42:45 +09:00
|
|
|
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
def to_action(dp, dic):
|
|
|
|
ofp = dp.ofproto
|
|
|
|
parser = dp.ofproto_parser
|
|
|
|
action_type = dic.get('type')
|
2016-03-29 19:18:38 +00:00
|
|
|
return ofctl_utils.to_action(dic, ofp, parser, action_type, UTIL)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
|
2013-07-23 21:04:04 +09:00
|
|
|
def to_actions(dp, acts):
|
|
|
|
inst = []
|
|
|
|
actions = []
|
|
|
|
ofp = dp.ofproto
|
|
|
|
parser = dp.ofproto_parser
|
|
|
|
|
|
|
|
for a in acts:
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
action = to_action(dp, a)
|
ofctl_v1_[23]: Add support for OFPIT_[WRITE/CLEAR]_ACTIONS
This patch makes ofctl_rest enable setting instruction type of OFPIT_WRITE/CLEAR_ACTIONS.
e.g.)
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_ACTIONS",
"actions":[
{
"type":"POP_VLAN",
},
{
"type":"OUTPUT",
"port": 2
}
]
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"CLEAR_ACTIONS"
}
]
}' http://localhost:8080/stats/flowentry/add
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-09-08 09:14:07 +09:00
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
if action is not None:
|
|
|
|
actions.append(action)
|
2013-07-23 21:04:04 +09:00
|
|
|
else:
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
action_type = a.get('type')
|
ofctl_v1_[23]: Add support for OFPIT_[WRITE/CLEAR]_ACTIONS
This patch makes ofctl_rest enable setting instruction type of OFPIT_WRITE/CLEAR_ACTIONS.
e.g.)
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_ACTIONS",
"actions":[
{
"type":"POP_VLAN",
},
{
"type":"OUTPUT",
"port": 2
}
]
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"CLEAR_ACTIONS"
}
]
}' http://localhost:8080/stats/flowentry/add
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-09-08 09:14:07 +09:00
|
|
|
if action_type == 'WRITE_ACTIONS':
|
|
|
|
write_actions = []
|
|
|
|
write_acts = a.get('actions')
|
2016-08-08 16:49:40 +09:00
|
|
|
for act in write_acts:
|
|
|
|
action = to_action(dp, act)
|
ofctl_v1_[23]: Add support for OFPIT_[WRITE/CLEAR]_ACTIONS
This patch makes ofctl_rest enable setting instruction type of OFPIT_WRITE/CLEAR_ACTIONS.
e.g.)
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_ACTIONS",
"actions":[
{
"type":"POP_VLAN",
},
{
"type":"OUTPUT",
"port": 2
}
]
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"CLEAR_ACTIONS"
}
]
}' http://localhost:8080/stats/flowentry/add
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-09-08 09:14:07 +09:00
|
|
|
if action is not None:
|
|
|
|
write_actions.append(action)
|
|
|
|
else:
|
|
|
|
LOG.error('Unknown action type: %s', action_type)
|
|
|
|
if write_actions:
|
2016-03-29 19:18:26 +00:00
|
|
|
inst.append(
|
|
|
|
parser.OFPInstructionActions(ofp.OFPIT_WRITE_ACTIONS,
|
|
|
|
write_actions))
|
ofctl_v1_[23]: Add support for OFPIT_[WRITE/CLEAR]_ACTIONS
This patch makes ofctl_rest enable setting instruction type of OFPIT_WRITE/CLEAR_ACTIONS.
e.g.)
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_ACTIONS",
"actions":[
{
"type":"POP_VLAN",
},
{
"type":"OUTPUT",
"port": 2
}
]
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"CLEAR_ACTIONS"
}
]
}' http://localhost:8080/stats/flowentry/add
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-09-08 09:14:07 +09:00
|
|
|
elif action_type == 'CLEAR_ACTIONS':
|
2016-08-08 16:49:40 +09:00
|
|
|
inst.append(
|
|
|
|
parser.OFPInstructionActions(ofp.OFPIT_CLEAR_ACTIONS, []))
|
ofctl_v1_[23]: Add support for OFPIT_[WRITE/CLEAR]_ACTIONS
This patch makes ofctl_rest enable setting instruction type of OFPIT_WRITE/CLEAR_ACTIONS.
e.g.)
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_ACTIONS",
"actions":[
{
"type":"POP_VLAN",
},
{
"type":"OUTPUT",
"port": 2
}
]
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"CLEAR_ACTIONS"
}
]
}' http://localhost:8080/stats/flowentry/add
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-09-08 09:14:07 +09:00
|
|
|
elif action_type == 'GOTO_TABLE':
|
2016-01-19 13:46:10 +09:00
|
|
|
table_id = UTIL.ofp_table_from_user(a.get('table_id'))
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
inst.append(parser.OFPInstructionGotoTable(table_id))
|
|
|
|
elif action_type == 'WRITE_METADATA':
|
2017-02-09 16:44:35 +09:00
|
|
|
metadata = str_to_int(a.get('metadata'))
|
|
|
|
metadata_mask = (str_to_int(a['metadata_mask'])
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
if 'metadata_mask' in a
|
|
|
|
else parser.UINT64_MAX)
|
|
|
|
inst.append(
|
|
|
|
parser.OFPInstructionWriteMetadata(
|
|
|
|
metadata, metadata_mask))
|
|
|
|
elif action_type == 'METER':
|
2016-01-19 13:46:10 +09:00
|
|
|
meter_id = UTIL.ofp_meter_from_user(a.get('meter_id'))
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
inst.append(parser.OFPInstructionMeter(meter_id))
|
|
|
|
else:
|
2015-03-16 21:11:10 +09:00
|
|
|
LOG.error('Unknown action type: %s', action_type)
|
2013-07-23 21:04:04 +09:00
|
|
|
|
ofctl_v1_[23]: Add support for OFPIT_[WRITE/CLEAR]_ACTIONS
This patch makes ofctl_rest enable setting instruction type of OFPIT_WRITE/CLEAR_ACTIONS.
e.g.)
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"WRITE_ACTIONS",
"actions":[
{
"type":"POP_VLAN",
},
{
"type":"OUTPUT",
"port": 2
}
]
}
]
}' http://localhost:8080/stats/flowentry/add
$ curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 30,
"hard_timeout": 30,
"priority": 11111,
"flags": 1,
"match":{
"in_port":1
},
"actions":[
{
"type":"CLEAR_ACTIONS"
}
]
}' http://localhost:8080/stats/flowentry/add
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-09-08 09:14:07 +09:00
|
|
|
if actions:
|
|
|
|
inst.append(parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS,
|
|
|
|
actions))
|
2013-07-23 21:04:04 +09:00
|
|
|
return inst
|
|
|
|
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
def action_to_str(act):
|
|
|
|
action_type = act.cls_action_type
|
|
|
|
|
|
|
|
if action_type == ofproto_v1_3.OFPAT_OUTPUT:
|
2016-01-19 13:46:10 +09:00
|
|
|
port = UTIL.ofp_port_to_user(act.port)
|
|
|
|
buf = 'OUTPUT:' + str(port)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
elif action_type == ofproto_v1_3.OFPAT_COPY_TTL_OUT:
|
|
|
|
buf = 'COPY_TTL_OUT'
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_COPY_TTL_IN:
|
|
|
|
buf = 'COPY_TTL_IN'
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_SET_MPLS_TTL:
|
|
|
|
buf = 'SET_MPLS_TTL:' + str(act.mpls_ttl)
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_DEC_MPLS_TTL:
|
|
|
|
buf = 'DEC_MPLS_TTL'
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_PUSH_VLAN:
|
|
|
|
buf = 'PUSH_VLAN:' + str(act.ethertype)
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_POP_VLAN:
|
|
|
|
buf = 'POP_VLAN'
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_PUSH_MPLS:
|
|
|
|
buf = 'PUSH_MPLS:' + str(act.ethertype)
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_POP_MPLS:
|
2014-07-10 13:21:16 +09:00
|
|
|
buf = 'POP_MPLS:' + str(act.ethertype)
|
2014-01-23 13:03:27 +09:00
|
|
|
elif action_type == ofproto_v1_3.OFPAT_SET_QUEUE:
|
2016-01-19 13:46:10 +09:00
|
|
|
queue_id = UTIL.ofp_queue_to_user(act.queue_id)
|
|
|
|
buf = 'SET_QUEUE:' + str(queue_id)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
elif action_type == ofproto_v1_3.OFPAT_GROUP:
|
2016-01-19 13:46:10 +09:00
|
|
|
group_id = UTIL.ofp_group_to_user(act.group_id)
|
|
|
|
buf = 'GROUP:' + str(group_id)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
elif action_type == ofproto_v1_3.OFPAT_SET_NW_TTL:
|
|
|
|
buf = 'SET_NW_TTL:' + str(act.nw_ttl)
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_DEC_NW_TTL:
|
|
|
|
buf = 'DEC_NW_TTL'
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_SET_FIELD:
|
2014-02-27 21:27:59 +09:00
|
|
|
buf = 'SET_FIELD: {%s:%s}' % (act.key, act.value)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
elif action_type == ofproto_v1_3.OFPAT_PUSH_PBB:
|
|
|
|
buf = 'PUSH_PBB:' + str(act.ethertype)
|
|
|
|
elif action_type == ofproto_v1_3.OFPAT_POP_PBB:
|
|
|
|
buf = 'POP_PBB'
|
2016-03-10 13:19:18 +09:00
|
|
|
elif action_type == ofproto_v1_3.OFPAT_EXPERIMENTER:
|
2016-03-29 19:18:37 +00:00
|
|
|
if act.experimenter == ofproto_common.NX_EXPERIMENTER_ID:
|
|
|
|
try:
|
|
|
|
return ofctl_nicira_ext.action_to_str(act, action_to_str)
|
2016-08-08 16:49:40 +09:00
|
|
|
except Exception:
|
2016-03-29 19:18:37 +00:00
|
|
|
LOG.debug('Error parsing NX_ACTION(%s)',
|
|
|
|
act.__class__.__name__, exc_info=True)
|
|
|
|
|
2016-03-10 13:19:18 +09:00
|
|
|
data_str = base64.b64encode(act.data)
|
|
|
|
buf = 'EXPERIMENTER: {experimenter:%s, data:%s}' % \
|
|
|
|
(act.experimenter, data_str.decode('utf-8'))
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
else:
|
|
|
|
buf = 'UNKNOWN'
|
|
|
|
return buf
|
|
|
|
|
|
|
|
|
2013-11-26 10:34:50 +09:00
|
|
|
def actions_to_str(instructions):
|
|
|
|
actions = []
|
|
|
|
|
|
|
|
for instruction in instructions:
|
2013-12-20 11:42:45 +09:00
|
|
|
if isinstance(instruction,
|
|
|
|
ofproto_v1_3_parser.OFPInstructionActions):
|
ofctl_v1_[23]: Fix the output result of get_flow_stats()
Add flows OFPIT_APPLY_ACTIONS and OFPIT_WRITE_ACTIONS and
OFPIT_CLEAR_ACTIONS as the type of instructions, respectively.
Then, the output results of get_flow_stats() are the same.
This patch fix this problem.
before applying this patch:
* case OFPIT_APPLY_ACTIONS and OFPIT_WRITE_ACTIONS
{
"1": [
{
"actions": [
"OUTPUT:2",
"OUTPUT:3"
],
...
}
]
}
* case OFPIT_CLEAR_ACTIONS
{
"1": [
{
"actions": [],
...
}
]
}
after apply this patch:
* case OFPIT_APPLY_ACTIONS
{
"1": [
{
"actions": [
"OUTPUT:2",
"OUTPUT:3"
],
...
}
]
}
* case OFPIT_WRITE_ACTIONS
{
"1": [
{
"actions": [
{
"WRITE_ACTIONS": [
"OUTPUT:4",
"OUTPUT:5"
]
}
],
...
}
]
}
* case OFPIT_CLEAR_ACTIONS
{
"1": [
{
"actions": [
"CLEAR_ACTIONS"
],
...
}
]
}
Reported-by: Liu, Weijie <wliu43@illinois.edu>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-09-02 13:20:28 +09:00
|
|
|
if instruction.type == ofproto_v1_3.OFPIT_APPLY_ACTIONS:
|
|
|
|
for a in instruction.actions:
|
|
|
|
actions.append(action_to_str(a))
|
|
|
|
elif instruction.type == ofproto_v1_3.OFPIT_WRITE_ACTIONS:
|
|
|
|
write_actions = []
|
|
|
|
for a in instruction.actions:
|
|
|
|
write_actions.append(action_to_str(a))
|
|
|
|
if write_actions:
|
|
|
|
actions.append({'WRITE_ACTIONS': write_actions})
|
|
|
|
elif instruction.type == ofproto_v1_3.OFPIT_CLEAR_ACTIONS:
|
|
|
|
actions.append('CLEAR_ACTIONS')
|
|
|
|
else:
|
|
|
|
actions.append('UNKNOWN')
|
2013-12-20 11:42:45 +09:00
|
|
|
elif isinstance(instruction,
|
|
|
|
ofproto_v1_3_parser.OFPInstructionGotoTable):
|
2016-01-19 13:46:10 +09:00
|
|
|
table_id = UTIL.ofp_table_to_user(instruction.table_id)
|
|
|
|
buf = 'GOTO_TABLE:' + str(table_id)
|
2013-12-20 11:42:45 +09:00
|
|
|
actions.append(buf)
|
|
|
|
|
|
|
|
elif isinstance(instruction,
|
|
|
|
ofproto_v1_3_parser.OFPInstructionWriteMetadata):
|
|
|
|
buf = ('WRITE_METADATA:0x%x/0x%x' % (instruction.metadata,
|
|
|
|
instruction.metadata_mask)
|
|
|
|
if instruction.metadata_mask
|
|
|
|
else 'WRITE_METADATA:0x%x' % instruction.metadata)
|
2013-11-26 10:34:50 +09:00
|
|
|
actions.append(buf)
|
|
|
|
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
elif isinstance(instruction,
|
|
|
|
ofproto_v1_3_parser.OFPInstructionMeter):
|
2016-01-19 13:46:10 +09:00
|
|
|
meter_id = UTIL.ofp_meter_to_user(instruction.meter_id)
|
|
|
|
buf = 'METER:' + str(meter_id)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
actions.append(buf)
|
|
|
|
|
2013-12-20 11:42:45 +09:00
|
|
|
else:
|
|
|
|
continue
|
|
|
|
|
2013-11-26 10:34:50 +09:00
|
|
|
return actions
|
|
|
|
|
|
|
|
|
2013-07-23 21:04:04 +09:00
|
|
|
def to_match(dp, attrs):
|
2016-01-19 13:46:10 +09:00
|
|
|
convert = {'in_port': UTIL.ofp_port_from_user,
|
2017-02-09 16:44:35 +09:00
|
|
|
'in_phy_port': str_to_int,
|
2016-03-29 19:18:38 +00:00
|
|
|
'metadata': ofctl_utils.to_match_masked_int,
|
|
|
|
'dl_dst': ofctl_utils.to_match_eth,
|
|
|
|
'dl_src': ofctl_utils.to_match_eth,
|
|
|
|
'eth_dst': ofctl_utils.to_match_eth,
|
|
|
|
'eth_src': ofctl_utils.to_match_eth,
|
2017-02-09 16:44:35 +09:00
|
|
|
'dl_type': str_to_int,
|
|
|
|
'eth_type': str_to_int,
|
2014-11-28 16:47:02 +09:00
|
|
|
'dl_vlan': to_match_vid,
|
|
|
|
'vlan_vid': to_match_vid,
|
2017-02-09 16:44:35 +09:00
|
|
|
'vlan_pcp': str_to_int,
|
|
|
|
'ip_dscp': str_to_int,
|
|
|
|
'ip_ecn': str_to_int,
|
|
|
|
'nw_proto': str_to_int,
|
|
|
|
'ip_proto': str_to_int,
|
2016-03-29 19:18:38 +00:00
|
|
|
'nw_src': ofctl_utils.to_match_ip,
|
|
|
|
'nw_dst': ofctl_utils.to_match_ip,
|
|
|
|
'ipv4_src': ofctl_utils.to_match_ip,
|
|
|
|
'ipv4_dst': ofctl_utils.to_match_ip,
|
2017-02-09 16:44:35 +09:00
|
|
|
'tp_src': str_to_int,
|
|
|
|
'tp_dst': str_to_int,
|
|
|
|
'tcp_src': str_to_int,
|
|
|
|
'tcp_dst': str_to_int,
|
|
|
|
'udp_src': str_to_int,
|
|
|
|
'udp_dst': str_to_int,
|
|
|
|
'sctp_src': str_to_int,
|
|
|
|
'sctp_dst': str_to_int,
|
|
|
|
'icmpv4_type': str_to_int,
|
|
|
|
'icmpv4_code': str_to_int,
|
|
|
|
'arp_op': str_to_int,
|
2016-03-29 19:18:38 +00:00
|
|
|
'arp_spa': ofctl_utils.to_match_ip,
|
|
|
|
'arp_tpa': ofctl_utils.to_match_ip,
|
|
|
|
'arp_sha': ofctl_utils.to_match_eth,
|
|
|
|
'arp_tha': ofctl_utils.to_match_eth,
|
|
|
|
'ipv6_src': ofctl_utils.to_match_ip,
|
|
|
|
'ipv6_dst': ofctl_utils.to_match_ip,
|
2017-02-09 16:44:35 +09:00
|
|
|
'ipv6_flabel': str_to_int,
|
|
|
|
'icmpv6_type': str_to_int,
|
|
|
|
'icmpv6_code': str_to_int,
|
2016-03-29 19:18:38 +00:00
|
|
|
'ipv6_nd_target': ofctl_utils.to_match_ip,
|
|
|
|
'ipv6_nd_sll': ofctl_utils.to_match_eth,
|
|
|
|
'ipv6_nd_tll': ofctl_utils.to_match_eth,
|
2017-02-09 16:44:35 +09:00
|
|
|
'mpls_label': str_to_int,
|
|
|
|
'mpls_tc': str_to_int,
|
|
|
|
'mpls_bos': str_to_int,
|
2016-03-29 19:18:38 +00:00
|
|
|
'pbb_isid': ofctl_utils.to_match_masked_int,
|
|
|
|
'tunnel_id': ofctl_utils.to_match_masked_int,
|
|
|
|
'ipv6_exthdr': ofctl_utils.to_match_masked_int}
|
2013-07-23 21:04:04 +09:00
|
|
|
|
2014-11-25 10:53:02 +09:00
|
|
|
keys = {'dl_dst': 'eth_dst',
|
|
|
|
'dl_src': 'eth_src',
|
|
|
|
'dl_type': 'eth_type',
|
|
|
|
'dl_vlan': 'vlan_vid',
|
|
|
|
'nw_src': 'ipv4_src',
|
|
|
|
'nw_dst': 'ipv4_dst',
|
|
|
|
'nw_proto': 'ip_proto'}
|
2013-07-23 21:04:04 +09:00
|
|
|
|
ofctl_v1_2/3: fix match conditions about ARP
ofctl_v1_0 has changed nw_src/dst into ipv4_src/dst or arp_spa/tpa automatically like ovs-ofctl.
since ofctl_v1_2/3 change nw_src/dst only into ipv4_src/dst, it cannot create the match conditions which use arp_spa/tpa.
this patch fixes this problem.
before applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
no flow entry was installed.
after applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=2.555s, table=0, n_packets=0, n_bytes=0, priority=0,arp,arp_spa=192.168.0.0/24 actions=output:2
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-14 13:58:20 +09:00
|
|
|
if attrs.get('dl_type') == ether.ETH_TYPE_ARP or \
|
|
|
|
attrs.get('eth_type') == ether.ETH_TYPE_ARP:
|
2014-05-13 19:58:29 +09:00
|
|
|
if 'nw_src' in attrs and 'arp_spa' not in attrs:
|
ofctl_v1_2/3: fix match conditions about ARP
ofctl_v1_0 has changed nw_src/dst into ipv4_src/dst or arp_spa/tpa automatically like ovs-ofctl.
since ofctl_v1_2/3 change nw_src/dst only into ipv4_src/dst, it cannot create the match conditions which use arp_spa/tpa.
this patch fixes this problem.
before applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
no flow entry was installed.
after applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=2.555s, table=0, n_packets=0, n_bytes=0, priority=0,arp,arp_spa=192.168.0.0/24 actions=output:2
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-14 13:58:20 +09:00
|
|
|
attrs['arp_spa'] = attrs['nw_src']
|
|
|
|
del attrs['nw_src']
|
2014-05-13 19:58:29 +09:00
|
|
|
if 'nw_dst' in attrs and 'arp_tpa' not in attrs:
|
ofctl_v1_2/3: fix match conditions about ARP
ofctl_v1_0 has changed nw_src/dst into ipv4_src/dst or arp_spa/tpa automatically like ovs-ofctl.
since ofctl_v1_2/3 change nw_src/dst only into ipv4_src/dst, it cannot create the match conditions which use arp_spa/tpa.
this patch fixes this problem.
before applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
no flow entry was installed.
after applying this patch (using ofctl_rest):
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=3.602s, table=0, n_packets=0, n_bytes=0, priority=0,ip,nw_src=192.168.0.0/24 actions=output:2
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2054,
"nw_src": "192.168.0.0/24"},
"actions": [{"type": "OUTPUT",
"port": 2}]}' http://localhost:8080/stats/flowentry/add
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=2.555s, table=0, n_packets=0, n_bytes=0, priority=0,arp,arp_spa=192.168.0.0/24 actions=output:2
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-14 13:58:20 +09:00
|
|
|
attrs['arp_tpa'] = attrs['nw_dst']
|
|
|
|
del attrs['nw_dst']
|
|
|
|
|
2014-11-25 10:53:02 +09:00
|
|
|
kwargs = {}
|
2013-07-23 21:04:04 +09:00
|
|
|
for key, value in attrs.items():
|
2014-11-25 10:53:02 +09:00
|
|
|
if key in keys:
|
|
|
|
# For old field name
|
|
|
|
key = keys[key]
|
2015-03-30 11:45:30 +09:00
|
|
|
if key in convert:
|
|
|
|
value = convert[key](value)
|
|
|
|
if key == 'tp_src' or key == 'tp_dst':
|
|
|
|
# TCP/UDP port
|
|
|
|
conv = {inet.IPPROTO_TCP: {'tp_src': 'tcp_src',
|
|
|
|
'tp_dst': 'tcp_dst'},
|
|
|
|
inet.IPPROTO_UDP: {'tp_src': 'udp_src',
|
|
|
|
'tp_dst': 'udp_dst'}}
|
|
|
|
ip_proto = attrs.get('nw_proto', attrs.get('ip_proto', 0))
|
|
|
|
key = conv[ip_proto][key]
|
|
|
|
kwargs[key] = value
|
|
|
|
else:
|
|
|
|
# others
|
|
|
|
kwargs[key] = value
|
2014-11-25 10:53:02 +09:00
|
|
|
else:
|
2015-03-30 11:45:30 +09:00
|
|
|
LOG.error('Unknown match field: %s', key)
|
2013-07-23 21:04:04 +09:00
|
|
|
|
2014-11-25 10:53:02 +09:00
|
|
|
return dp.ofproto_parser.OFPMatch(**kwargs)
|
2013-07-23 21:04:04 +09:00
|
|
|
|
|
|
|
|
2014-11-28 16:47:02 +09:00
|
|
|
def to_match_vid(value):
|
2016-03-29 19:18:38 +00:00
|
|
|
return ofctl_utils.to_match_vid(value, ofproto_v1_3.OFPVID_PRESENT)
|
2013-12-20 11:42:45 +09:00
|
|
|
|
|
|
|
|
2013-11-26 10:34:50 +09:00
|
|
|
def match_to_str(ofmatch):
|
2014-11-25 10:52:36 +09:00
|
|
|
|
|
|
|
keys = {'eth_src': 'dl_src',
|
|
|
|
'eth_dst': 'dl_dst',
|
|
|
|
'eth_type': 'dl_type',
|
|
|
|
'vlan_vid': 'dl_vlan',
|
|
|
|
'ipv4_src': 'nw_src',
|
|
|
|
'ipv4_dst': 'nw_dst',
|
|
|
|
'ip_proto': 'nw_proto',
|
|
|
|
'tcp_src': 'tp_src',
|
|
|
|
'tcp_dst': 'tp_dst',
|
|
|
|
'udp_src': 'tp_src',
|
2016-08-08 16:49:40 +09:00
|
|
|
'udp_dst': 'tp_dst'}
|
2013-11-26 10:34:50 +09:00
|
|
|
|
|
|
|
match = {}
|
2014-11-25 10:52:36 +09:00
|
|
|
|
|
|
|
ofmatch = ofmatch.to_jsondict()['OFPMatch']
|
|
|
|
ofmatch = ofmatch['oxm_fields']
|
|
|
|
|
|
|
|
for match_field in ofmatch:
|
|
|
|
key = match_field['OXMTlv']['field']
|
|
|
|
if key in keys:
|
|
|
|
key = keys[key]
|
|
|
|
mask = match_field['OXMTlv']['mask']
|
|
|
|
value = match_field['OXMTlv']['value']
|
|
|
|
if key == 'dl_vlan':
|
2017-02-09 16:44:36 +09:00
|
|
|
value = match_vid_to_str(value, mask)
|
2016-01-19 13:46:10 +09:00
|
|
|
elif key == 'in_port':
|
|
|
|
value = UTIL.ofp_port_to_user(value)
|
2013-11-26 10:34:50 +09:00
|
|
|
else:
|
2014-11-25 10:52:36 +09:00
|
|
|
if mask is not None:
|
2015-08-25 16:02:15 +09:00
|
|
|
value = str(value) + '/' + str(mask)
|
2013-11-26 10:34:50 +09:00
|
|
|
match.setdefault(key, value)
|
|
|
|
|
|
|
|
return match
|
|
|
|
|
|
|
|
|
2017-02-09 16:44:36 +09:00
|
|
|
def match_vid_to_str(value, mask):
|
|
|
|
return ofctl_utils.match_vid_to_str(
|
|
|
|
value, mask, ofproto_v1_3.OFPVID_PRESENT)
|
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def wrap_dpid_dict(dp, value, to_user=True):
|
|
|
|
if to_user:
|
|
|
|
return {str(dp.id): value}
|
|
|
|
|
|
|
|
return {dp.id: value}
|
|
|
|
|
|
|
|
|
|
|
|
def get_desc_stats(dp, waiters, to_user=True):
|
2013-11-06 15:01:34 +08:00
|
|
|
stats = dp.ofproto_parser.OFPDescStatsRequest(dp, 0)
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
2014-06-25 21:24:41 -07:00
|
|
|
s = {}
|
2013-11-06 15:01:34 +08:00
|
|
|
|
|
|
|
for msg in msgs:
|
|
|
|
stats = msg.body
|
2017-03-17 14:29:43 +09:00
|
|
|
s = stats.to_jsondict()[stats.__class__.__name__]
|
2013-11-06 15:01:34 +08:00
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, s, to_user)
|
2013-11-06 15:01:34 +08:00
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
def get_queue_stats(dp, waiters, port=None, queue_id=None, to_user=True):
|
2014-05-07 12:04:49 +09:00
|
|
|
ofp = dp.ofproto
|
2016-03-22 09:51:45 +09:00
|
|
|
|
|
|
|
if port is None:
|
|
|
|
port = ofp.OFPP_ANY
|
|
|
|
else:
|
2017-02-09 16:44:35 +09:00
|
|
|
port = str_to_int(port)
|
2016-03-22 09:51:45 +09:00
|
|
|
|
|
|
|
if queue_id is None:
|
|
|
|
queue_id = ofp.OFPQ_ALL
|
|
|
|
else:
|
2017-02-09 16:44:35 +09:00
|
|
|
queue_id = str_to_int(queue_id)
|
2016-03-22 09:51:45 +09:00
|
|
|
|
|
|
|
stats = dp.ofproto_parser.OFPQueueStatsRequest(dp, 0, port,
|
|
|
|
queue_id)
|
2014-05-07 12:04:49 +09:00
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
2014-05-07 12:04:49 +09:00
|
|
|
|
|
|
|
s = []
|
|
|
|
for msg in msgs:
|
|
|
|
stats = msg.body
|
|
|
|
for stat in stats:
|
|
|
|
s.append({'duration_nsec': stat.duration_nsec,
|
|
|
|
'duration_sec': stat.duration_sec,
|
|
|
|
'port_no': stat.port_no,
|
|
|
|
'queue_id': stat.queue_id,
|
|
|
|
'tx_bytes': stat.tx_bytes,
|
|
|
|
'tx_errors': stat.tx_errors,
|
|
|
|
'tx_packets': stat.tx_packets})
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
return wrap_dpid_dict(dp, s, to_user)
|
2014-05-07 12:04:49 +09:00
|
|
|
|
|
|
|
|
2016-05-10 14:29:34 +09:00
|
|
|
def get_queue_config(dp, waiters, port=None, to_user=True):
|
|
|
|
ofp = dp.ofproto
|
|
|
|
if port is None:
|
|
|
|
port = ofp.OFPP_ANY
|
|
|
|
else:
|
2017-02-09 16:44:35 +09:00
|
|
|
port = UTIL.ofp_port_from_user(str_to_int(port))
|
ofctl_rest: support OFPQueueGetConfig Message
this patch makes ofctl_rest enable use of OFPQueueGetConfig message.
Get queues config:
usage)
URI: /stats/queueconfig/<dpid>/<port>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/queueconfig/1/1
{
"1": [
{
"port": 1,
"queues": [
{
"properties": [
{
"property": "MIN_RATE",
"rate": 80
}
],
"port": 0,
"queue_id": 1
},
{
"properties": [
{
"property": "MAX_RATE",
"rate": 120
}
],
"port": 2,
"queue_id": 2
},
{
"properties": [
{
"property": "EXPERIMENTER",
"data": [],
"experimenter": 999
}
],
"port": 3,
"queue_id": 3
}
]
}
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:35 +09:00
|
|
|
stats = dp.ofproto_parser.OFPQueueGetConfigRequest(dp, port)
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_rest: support OFPQueueGetConfig Message
this patch makes ofctl_rest enable use of OFPQueueGetConfig message.
Get queues config:
usage)
URI: /stats/queueconfig/<dpid>/<port>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/queueconfig/1/1
{
"1": [
{
"port": 1,
"queues": [
{
"properties": [
{
"property": "MIN_RATE",
"rate": 80
}
],
"port": 0,
"queue_id": 1
},
{
"properties": [
{
"property": "MAX_RATE",
"rate": 120
}
],
"port": 2,
"queue_id": 2
},
{
"properties": [
{
"property": "EXPERIMENTER",
"data": [],
"experimenter": 999
}
],
"port": 3,
"queue_id": 3
}
]
}
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:35 +09:00
|
|
|
|
|
|
|
prop_type = {dp.ofproto.OFPQT_MIN_RATE: 'MIN_RATE',
|
|
|
|
dp.ofproto.OFPQT_MAX_RATE: 'MAX_RATE',
|
2016-08-08 16:49:40 +09:00
|
|
|
dp.ofproto.OFPQT_EXPERIMENTER: 'EXPERIMENTER'}
|
ofctl_rest: support OFPQueueGetConfig Message
this patch makes ofctl_rest enable use of OFPQueueGetConfig message.
Get queues config:
usage)
URI: /stats/queueconfig/<dpid>/<port>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/queueconfig/1/1
{
"1": [
{
"port": 1,
"queues": [
{
"properties": [
{
"property": "MIN_RATE",
"rate": 80
}
],
"port": 0,
"queue_id": 1
},
{
"properties": [
{
"property": "MAX_RATE",
"rate": 120
}
],
"port": 2,
"queue_id": 2
},
{
"properties": [
{
"property": "EXPERIMENTER",
"data": [],
"experimenter": 999
}
],
"port": 3,
"queue_id": 3
}
]
}
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:35 +09:00
|
|
|
|
|
|
|
configs = []
|
|
|
|
for config in msgs:
|
|
|
|
queue_list = []
|
|
|
|
for queue in config.queues:
|
|
|
|
prop_list = []
|
|
|
|
for prop in queue.properties:
|
|
|
|
p = {'property': prop_type.get(prop.property, 'UNKNOWN')}
|
|
|
|
if prop.property == dp.ofproto.OFPQT_MIN_RATE or \
|
|
|
|
prop.property == dp.ofproto.OFPQT_MAX_RATE:
|
|
|
|
p['rate'] = prop.rate
|
|
|
|
elif prop.property == dp.ofproto.OFPQT_EXPERIMENTER:
|
|
|
|
p['experimenter'] = prop.experimenter
|
|
|
|
p['data'] = prop.data
|
|
|
|
prop_list.append(p)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
q = {'properties': prop_list}
|
|
|
|
|
|
|
|
if to_user:
|
|
|
|
q['port'] = UTIL.ofp_port_to_user(queue.port)
|
|
|
|
q['queue_id'] = UTIL.ofp_queue_to_user(queue.queue_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
q['port'] = queue.port
|
|
|
|
q['queue_id'] = queue.queue_id
|
|
|
|
|
ofctl_rest: support OFPQueueGetConfig Message
this patch makes ofctl_rest enable use of OFPQueueGetConfig message.
Get queues config:
usage)
URI: /stats/queueconfig/<dpid>/<port>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/queueconfig/1/1
{
"1": [
{
"port": 1,
"queues": [
{
"properties": [
{
"property": "MIN_RATE",
"rate": 80
}
],
"port": 0,
"queue_id": 1
},
{
"properties": [
{
"property": "MAX_RATE",
"rate": 120
}
],
"port": 2,
"queue_id": 2
},
{
"properties": [
{
"property": "EXPERIMENTER",
"data": [],
"experimenter": 999
}
],
"port": 3,
"queue_id": 3
}
]
}
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:35 +09:00
|
|
|
queue_list.append(q)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
c = {'queues': queue_list}
|
|
|
|
|
|
|
|
if to_user:
|
|
|
|
c['port'] = UTIL.ofp_port_to_user(config.port)
|
|
|
|
|
|
|
|
else:
|
|
|
|
c['port'] = config.port
|
|
|
|
|
ofctl_rest: support OFPQueueGetConfig Message
this patch makes ofctl_rest enable use of OFPQueueGetConfig message.
Get queues config:
usage)
URI: /stats/queueconfig/<dpid>/<port>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/queueconfig/1/1
{
"1": [
{
"port": 1,
"queues": [
{
"properties": [
{
"property": "MIN_RATE",
"rate": 80
}
],
"port": 0,
"queue_id": 1
},
{
"properties": [
{
"property": "MAX_RATE",
"rate": 120
}
],
"port": 2,
"queue_id": 2
},
{
"properties": [
{
"property": "EXPERIMENTER",
"data": [],
"experimenter": 999
}
],
"port": 3,
"queue_id": 3
}
]
}
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:35 +09:00
|
|
|
configs.append(c)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, configs, to_user)
|
ofctl_rest: support OFPQueueGetConfig Message
this patch makes ofctl_rest enable use of OFPQueueGetConfig message.
Get queues config:
usage)
URI: /stats/queueconfig/<dpid>/<port>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/queueconfig/1/1
{
"1": [
{
"port": 1,
"queues": [
{
"properties": [
{
"property": "MIN_RATE",
"rate": 80
}
],
"port": 0,
"queue_id": 1
},
{
"properties": [
{
"property": "MAX_RATE",
"rate": 120
}
],
"port": 2,
"queue_id": 2
},
{
"properties": [
{
"property": "EXPERIMENTER",
"data": [],
"experimenter": 999
}
],
"port": 3,
"queue_id": 3
}
]
}
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:35 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_flow_stats(dp, waiters, flow=None, to_user=True):
|
2015-12-24 16:48:07 +09:00
|
|
|
flow = flow if flow else {}
|
2016-01-19 13:46:10 +09:00
|
|
|
table_id = UTIL.ofp_table_from_user(
|
|
|
|
flow.get('table_id', dp.ofproto.OFPTT_ALL))
|
2017-02-09 16:44:35 +09:00
|
|
|
flags = str_to_int(flow.get('flags', 0))
|
2016-01-19 13:46:10 +09:00
|
|
|
out_port = UTIL.ofp_port_from_user(
|
|
|
|
flow.get('out_port', dp.ofproto.OFPP_ANY))
|
|
|
|
out_group = UTIL.ofp_group_from_user(
|
|
|
|
flow.get('out_group', dp.ofproto.OFPG_ANY))
|
2017-02-09 16:44:35 +09:00
|
|
|
cookie = str_to_int(flow.get('cookie', 0))
|
|
|
|
cookie_mask = str_to_int(flow.get('cookie_mask', 0))
|
2014-08-20 14:27:19 +09:00
|
|
|
match = to_match(dp, flow.get('match', {}))
|
2016-12-08 16:49:00 +09:00
|
|
|
# Note: OpenFlow does not allow to filter flow entries by priority,
|
|
|
|
# but for efficiency, ofctl provides the way to do it.
|
2017-02-09 16:44:35 +09:00
|
|
|
priority = str_to_int(flow.get('priority', -1))
|
2013-07-23 21:04:04 +09:00
|
|
|
|
|
|
|
stats = dp.ofproto_parser.OFPFlowStatsRequest(
|
|
|
|
dp, flags, table_id, out_port, out_group, cookie, cookie_mask,
|
|
|
|
match)
|
|
|
|
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
2013-07-23 21:04:04 +09:00
|
|
|
|
|
|
|
flows = []
|
|
|
|
for msg in msgs:
|
|
|
|
for stats in msg.body:
|
2016-12-08 16:49:00 +09:00
|
|
|
if 0 <= priority != stats.priority:
|
|
|
|
continue
|
|
|
|
|
2013-07-23 21:04:04 +09:00
|
|
|
s = {'priority': stats.priority,
|
|
|
|
'cookie': stats.cookie,
|
|
|
|
'idle_timeout': stats.idle_timeout,
|
|
|
|
'hard_timeout': stats.hard_timeout,
|
|
|
|
'byte_count': stats.byte_count,
|
|
|
|
'duration_sec': stats.duration_sec,
|
|
|
|
'duration_nsec': stats.duration_nsec,
|
|
|
|
'packet_count': stats.packet_count,
|
2014-09-17 17:06:25 -07:00
|
|
|
'length': stats.length,
|
|
|
|
'flags': stats.flags}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
s['actions'] = actions_to_str(stats.instructions)
|
|
|
|
s['match'] = match_to_str(stats.match)
|
|
|
|
s['table_id'] = UTIL.ofp_table_to_user(stats.table_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
s['actions'] = stats.instructions
|
|
|
|
s['instructions'] = stats.instructions
|
|
|
|
s['match'] = stats.match
|
|
|
|
s['table_id'] = stats.table_id
|
|
|
|
|
2013-07-23 21:04:04 +09:00
|
|
|
flows.append(s)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, flows, to_user)
|
2013-07-23 21:04:04 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_aggregate_flow_stats(dp, waiters, flow=None, to_user=True):
|
2015-12-24 16:48:07 +09:00
|
|
|
flow = flow if flow else {}
|
2016-01-19 13:46:10 +09:00
|
|
|
table_id = UTIL.ofp_table_from_user(
|
|
|
|
flow.get('table_id', dp.ofproto.OFPTT_ALL))
|
2017-02-09 16:44:35 +09:00
|
|
|
flags = str_to_int(flow.get('flags', 0))
|
2016-01-19 13:46:10 +09:00
|
|
|
out_port = UTIL.ofp_port_from_user(
|
|
|
|
flow.get('out_port', dp.ofproto.OFPP_ANY))
|
|
|
|
out_group = UTIL.ofp_group_from_user(
|
|
|
|
flow.get('out_group', dp.ofproto.OFPG_ANY))
|
2017-02-09 16:44:35 +09:00
|
|
|
cookie = str_to_int(flow.get('cookie', 0))
|
|
|
|
cookie_mask = str_to_int(flow.get('cookie_mask', 0))
|
2015-01-19 10:56:23 +09:00
|
|
|
match = to_match(dp, flow.get('match', {}))
|
|
|
|
|
|
|
|
stats = dp.ofproto_parser.OFPAggregateStatsRequest(
|
|
|
|
dp, flags, table_id, out_port, out_group, cookie, cookie_mask,
|
|
|
|
match)
|
|
|
|
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
2015-01-19 10:56:23 +09:00
|
|
|
|
|
|
|
flows = []
|
|
|
|
for msg in msgs:
|
|
|
|
stats = msg.body
|
|
|
|
s = {'packet_count': stats.packet_count,
|
|
|
|
'byte_count': stats.byte_count,
|
|
|
|
'flow_count': stats.flow_count}
|
|
|
|
flows.append(s)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, flows, to_user)
|
2015-01-19 10:56:23 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_table_stats(dp, waiters, to_user=True):
|
2015-10-22 17:31:33 +09:00
|
|
|
stats = dp.ofproto_parser.OFPTableStatsRequest(dp, 0)
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
2015-10-22 17:31:33 +09:00
|
|
|
|
|
|
|
tables = []
|
|
|
|
for msg in msgs:
|
|
|
|
stats = msg.body
|
|
|
|
for stat in stats:
|
2016-03-29 19:18:36 +00:00
|
|
|
s = {'active_count': stat.active_count,
|
2015-10-22 17:31:33 +09:00
|
|
|
'lookup_count': stat.lookup_count,
|
|
|
|
'matched_count': stat.matched_count}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
s['table_id'] = UTIL.ofp_table_to_user(stat.table_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
s['table_id'] = stat.table_id
|
|
|
|
|
2015-10-22 17:31:33 +09:00
|
|
|
tables.append(s)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, tables, to_user)
|
2015-10-22 17:31:33 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_table_features(dp, waiters, to_user=True):
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
stats = dp.ofproto_parser.OFPTableFeaturesStatsRequest(dp, 0, [])
|
|
|
|
msgs = []
|
|
|
|
ofproto = dp.ofproto
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
|
|
|
|
prop_type = {ofproto.OFPTFPT_INSTRUCTIONS: 'INSTRUCTIONS',
|
|
|
|
ofproto.OFPTFPT_INSTRUCTIONS_MISS: 'INSTRUCTIONS_MISS',
|
|
|
|
ofproto.OFPTFPT_NEXT_TABLES: 'NEXT_TABLES',
|
|
|
|
ofproto.OFPTFPT_NEXT_TABLES_MISS: 'NEXT_TABLES_MISS',
|
|
|
|
ofproto.OFPTFPT_WRITE_ACTIONS: 'WRITE_ACTIONS',
|
|
|
|
ofproto.OFPTFPT_WRITE_ACTIONS_MISS: 'WRITE_ACTIONS_MISS',
|
|
|
|
ofproto.OFPTFPT_APPLY_ACTIONS: 'APPLY_ACTIONS',
|
|
|
|
ofproto.OFPTFPT_APPLY_ACTIONS_MISS: 'APPLY_ACTIONS_MISS',
|
|
|
|
ofproto.OFPTFPT_MATCH: 'MATCH',
|
|
|
|
ofproto.OFPTFPT_WILDCARDS: 'WILDCARDS',
|
|
|
|
ofproto.OFPTFPT_WRITE_SETFIELD: 'WRITE_SETFIELD',
|
|
|
|
ofproto.OFPTFPT_WRITE_SETFIELD_MISS: 'WRITE_SETFIELD_MISS',
|
|
|
|
ofproto.OFPTFPT_APPLY_SETFIELD: 'APPLY_SETFIELD',
|
|
|
|
ofproto.OFPTFPT_APPLY_SETFIELD_MISS: 'APPLY_SETFIELD_MISS',
|
|
|
|
ofproto.OFPTFPT_EXPERIMENTER: 'EXPERIMENTER',
|
2016-08-08 16:49:40 +09:00
|
|
|
ofproto.OFPTFPT_EXPERIMENTER_MISS: 'EXPERIMENTER_MISS'}
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
if not to_user:
|
|
|
|
prop_type = dict((k, k) for k in prop_type.keys())
|
|
|
|
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
p_type_instructions = [ofproto.OFPTFPT_INSTRUCTIONS,
|
|
|
|
ofproto.OFPTFPT_INSTRUCTIONS_MISS]
|
|
|
|
|
|
|
|
p_type_next_tables = [ofproto.OFPTFPT_NEXT_TABLES,
|
|
|
|
ofproto.OFPTFPT_NEXT_TABLES_MISS]
|
|
|
|
|
|
|
|
p_type_actions = [ofproto.OFPTFPT_WRITE_ACTIONS,
|
|
|
|
ofproto.OFPTFPT_WRITE_ACTIONS_MISS,
|
|
|
|
ofproto.OFPTFPT_APPLY_ACTIONS,
|
|
|
|
ofproto.OFPTFPT_APPLY_ACTIONS_MISS]
|
|
|
|
|
|
|
|
p_type_oxms = [ofproto.OFPTFPT_MATCH,
|
|
|
|
ofproto.OFPTFPT_WILDCARDS,
|
|
|
|
ofproto.OFPTFPT_WRITE_SETFIELD,
|
|
|
|
ofproto.OFPTFPT_WRITE_SETFIELD_MISS,
|
|
|
|
ofproto.OFPTFPT_APPLY_SETFIELD,
|
|
|
|
ofproto.OFPTFPT_APPLY_SETFIELD_MISS]
|
|
|
|
|
|
|
|
p_type_experimenter = [ofproto.OFPTFPT_EXPERIMENTER,
|
|
|
|
ofproto.OFPTFPT_EXPERIMENTER_MISS]
|
|
|
|
|
|
|
|
tables = []
|
|
|
|
for msg in msgs:
|
|
|
|
stats = msg.body
|
|
|
|
for stat in stats:
|
|
|
|
properties = []
|
|
|
|
for prop in stat.properties:
|
|
|
|
p = {'type': prop_type.get(prop.type, 'UNKNOWN')}
|
|
|
|
if prop.type in p_type_instructions:
|
|
|
|
instruction_ids = []
|
2016-08-08 16:49:40 +09:00
|
|
|
for i in prop.instruction_ids:
|
|
|
|
inst = {'len': i.len,
|
|
|
|
'type': i.type}
|
|
|
|
instruction_ids.append(inst)
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
p['instruction_ids'] = instruction_ids
|
|
|
|
elif prop.type in p_type_next_tables:
|
|
|
|
table_ids = []
|
2016-08-08 16:49:40 +09:00
|
|
|
for i in prop.table_ids:
|
|
|
|
table_ids.append(i)
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
p['table_ids'] = table_ids
|
|
|
|
elif prop.type in p_type_actions:
|
|
|
|
action_ids = []
|
2016-08-08 16:49:40 +09:00
|
|
|
for i in prop.action_ids:
|
|
|
|
act = {'len': i.len,
|
|
|
|
'type': i.type}
|
|
|
|
action_ids.append(act)
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
p['action_ids'] = action_ids
|
|
|
|
elif prop.type in p_type_oxms:
|
|
|
|
oxm_ids = []
|
2016-08-08 16:49:40 +09:00
|
|
|
for i in prop.oxm_ids:
|
|
|
|
oxm = {'hasmask': i.hasmask,
|
|
|
|
'length': i.length,
|
|
|
|
'type': i.type}
|
|
|
|
oxm_ids.append(oxm)
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
p['oxm_ids'] = oxm_ids
|
|
|
|
elif prop.type in p_type_experimenter:
|
|
|
|
pass
|
|
|
|
properties.append(p)
|
2016-08-08 16:49:40 +09:00
|
|
|
s = {
|
|
|
|
'name': stat.name.decode('utf-8'),
|
|
|
|
'metadata_match': stat.metadata_match,
|
|
|
|
'metadata_write': stat.metadata_write,
|
|
|
|
'config': stat.config,
|
|
|
|
'max_entries': stat.max_entries,
|
|
|
|
'properties': properties,
|
|
|
|
}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
s['table_id'] = UTIL.ofp_table_to_user(stat.table_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
s['table_id'] = stat.table_id
|
|
|
|
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
tables.append(s)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, tables, to_user)
|
ofctl_rest: support OFPTableFeaturesStats Message
this patch makes ofctl_rest enable use of OFPTableFeaturesStats message.
Get table features:
usage)
URI: /stats/tablefeatures/<dpid>
method: GET
e.g.)
$ curl -X GET http://localhost:8080/stats/tablefeatures/1
{
"1": [
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 0,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_0"
},
{
"metadata_write": 18446744073709552000,
"config": 0,
"table_id": 1,
"metadata_match": 18446744073709552000,
"max_entries": 4096,
"properties": [
{
"type": "INSTRUCTIONS",
"instruction_ids": [
{
"len": 4,
"type": 1
},
....
]
},
...
],
"name": "table_1"
},
...
]
}
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2015-10-22 17:31:34 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_port_stats(dp, waiters, port=None, to_user=True):
|
2016-03-22 09:51:41 +09:00
|
|
|
if port is None:
|
|
|
|
port = dp.ofproto.OFPP_ANY
|
|
|
|
else:
|
2017-02-09 16:44:35 +09:00
|
|
|
port = str_to_int(port)
|
2016-03-22 09:51:41 +09:00
|
|
|
|
2013-11-06 15:01:34 +08:00
|
|
|
stats = dp.ofproto_parser.OFPPortStatsRequest(
|
2016-03-22 09:51:41 +09:00
|
|
|
dp, 0, port)
|
2013-11-06 15:01:34 +08:00
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
2013-11-06 15:01:34 +08:00
|
|
|
|
|
|
|
ports = []
|
|
|
|
for msg in msgs:
|
|
|
|
for stats in msg.body:
|
2016-03-29 19:18:36 +00:00
|
|
|
s = {'rx_packets': stats.rx_packets,
|
2013-11-06 15:01:34 +08:00
|
|
|
'tx_packets': stats.tx_packets,
|
|
|
|
'rx_bytes': stats.rx_bytes,
|
|
|
|
'tx_bytes': stats.tx_bytes,
|
|
|
|
'rx_dropped': stats.rx_dropped,
|
|
|
|
'tx_dropped': stats.tx_dropped,
|
|
|
|
'rx_errors': stats.rx_errors,
|
|
|
|
'tx_errors': stats.tx_errors,
|
|
|
|
'rx_frame_err': stats.rx_frame_err,
|
|
|
|
'rx_over_err': stats.rx_over_err,
|
|
|
|
'rx_crc_err': stats.rx_crc_err,
|
2014-09-17 17:06:25 -07:00
|
|
|
'collisions': stats.collisions,
|
|
|
|
'duration_sec': stats.duration_sec,
|
|
|
|
'duration_nsec': stats.duration_nsec}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
s['port_no'] = UTIL.ofp_port_to_user(stats.port_no)
|
|
|
|
|
|
|
|
else:
|
|
|
|
s['port_no'] = stats.port_no
|
|
|
|
|
2013-11-06 15:01:34 +08:00
|
|
|
ports.append(s)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
return wrap_dpid_dict(dp, ports, to_user)
|
2013-11-06 15:01:34 +08:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_meter_stats(dp, waiters, meter_id=None, to_user=True):
|
2016-03-22 09:51:43 +09:00
|
|
|
if meter_id is None:
|
|
|
|
meter_id = dp.ofproto.OFPM_ALL
|
|
|
|
else:
|
2017-02-09 16:44:35 +09:00
|
|
|
meter_id = str_to_int(meter_id)
|
2016-03-22 09:51:43 +09:00
|
|
|
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
stats = dp.ofproto_parser.OFPMeterStatsRequest(
|
2016-03-22 09:51:43 +09:00
|
|
|
dp, 0, meter_id)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
|
|
|
meters = []
|
|
|
|
for msg in msgs:
|
|
|
|
for stats in msg.body:
|
|
|
|
bands = []
|
|
|
|
for band in stats.band_stats:
|
|
|
|
b = {'packet_band_count': band.packet_band_count,
|
|
|
|
'byte_band_count': band.byte_band_count}
|
|
|
|
bands.append(b)
|
2016-03-29 19:18:36 +00:00
|
|
|
s = {'len': stats.len,
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
'flow_count': stats.flow_count,
|
|
|
|
'packet_in_count': stats.packet_in_count,
|
|
|
|
'byte_in_count': stats.byte_in_count,
|
2014-09-17 17:06:25 -07:00
|
|
|
'duration_sec': stats.duration_sec,
|
|
|
|
'duration_nsec': stats.duration_nsec,
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
'band_stats': bands}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
s['meter_id'] = UTIL.ofp_meter_to_user(stats.meter_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
s['meter_id'] = stats.meter_id
|
|
|
|
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
meters.append(s)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, meters, to_user)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
def get_meter_features(dp, waiters, to_user=True):
|
2014-01-08 14:29:36 +09:00
|
|
|
|
|
|
|
ofp = dp.ofproto
|
|
|
|
type_convert = {ofp.OFPMBT_DROP: 'DROP',
|
|
|
|
ofp.OFPMBT_DSCP_REMARK: 'DSCP_REMARK'}
|
|
|
|
|
2014-12-05 09:31:00 +09:00
|
|
|
capa_convert = {ofp.OFPMF_KBPS: 'KBPS',
|
|
|
|
ofp.OFPMF_PKTPS: 'PKTPS',
|
|
|
|
ofp.OFPMF_BURST: 'BURST',
|
|
|
|
ofp.OFPMF_STATS: 'STATS'}
|
|
|
|
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
stats = dp.ofproto_parser.OFPMeterFeaturesStatsRequest(dp, 0)
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
|
|
|
features = []
|
|
|
|
for msg in msgs:
|
|
|
|
for feature in msg.body:
|
2014-01-08 14:29:36 +09:00
|
|
|
band_types = []
|
|
|
|
for k, v in type_convert.items():
|
|
|
|
if (1 << k) & feature.band_types:
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
band_types.append(v)
|
|
|
|
|
|
|
|
else:
|
|
|
|
band_types.append(k)
|
|
|
|
|
2014-12-05 09:31:00 +09:00
|
|
|
capabilities = []
|
2016-02-10 13:47:04 +09:00
|
|
|
for k, v in sorted(capa_convert.items()):
|
2014-12-05 09:31:00 +09:00
|
|
|
if k & feature.capabilities:
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
capabilities.append(v)
|
|
|
|
|
|
|
|
else:
|
|
|
|
capabilities.append(k)
|
|
|
|
|
2013-12-20 14:46:13 +09:00
|
|
|
f = {'max_meter': feature.max_meter,
|
2014-01-08 14:29:36 +09:00
|
|
|
'band_types': band_types,
|
2014-12-05 09:31:00 +09:00
|
|
|
'capabilities': capabilities,
|
2014-09-17 17:06:25 -07:00
|
|
|
'max_bands': feature.max_bands,
|
2013-12-20 14:46:13 +09:00
|
|
|
'max_color': feature.max_color}
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
features.append(f)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
return wrap_dpid_dict(dp, features, to_user)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_meter_config(dp, waiters, meter_id=None, to_user=True):
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
flags = {dp.ofproto.OFPMF_KBPS: 'KBPS',
|
|
|
|
dp.ofproto.OFPMF_PKTPS: 'PKTPS',
|
|
|
|
dp.ofproto.OFPMF_BURST: 'BURST',
|
|
|
|
dp.ofproto.OFPMF_STATS: 'STATS'}
|
|
|
|
|
|
|
|
band_type = {dp.ofproto.OFPMBT_DROP: 'DROP',
|
2014-09-21 17:15:00 -07:00
|
|
|
dp.ofproto.OFPMBT_DSCP_REMARK: 'DSCP_REMARK',
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
dp.ofproto.OFPMBT_EXPERIMENTER: 'EXPERIMENTER'}
|
|
|
|
|
2016-03-22 09:51:44 +09:00
|
|
|
if meter_id is None:
|
|
|
|
meter_id = dp.ofproto.OFPM_ALL
|
|
|
|
else:
|
2017-02-09 16:44:35 +09:00
|
|
|
meter_id = str_to_int(meter_id)
|
2016-03-22 09:51:44 +09:00
|
|
|
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
stats = dp.ofproto_parser.OFPMeterConfigStatsRequest(
|
2016-03-22 09:51:44 +09:00
|
|
|
dp, 0, meter_id)
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
|
|
|
|
configs = []
|
|
|
|
for msg in msgs:
|
|
|
|
for config in msg.body:
|
|
|
|
bands = []
|
|
|
|
for band in config.bands:
|
2016-03-29 19:18:36 +00:00
|
|
|
b = {'rate': band.rate,
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
'burst_size': band.burst_size}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
b['type'] = band_type.get(band.type, '')
|
|
|
|
|
|
|
|
else:
|
|
|
|
b['type'] = band.type
|
|
|
|
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
if band.type == dp.ofproto.OFPMBT_DSCP_REMARK:
|
|
|
|
b['prec_level'] = band.prec_level
|
|
|
|
elif band.type == dp.ofproto.OFPMBT_EXPERIMENTER:
|
|
|
|
b['experimenter'] = band.experimenter
|
|
|
|
bands.append(b)
|
ofctl_v1_3: Fix to enable using meter flags multiply
ofctl_rest is now enabled to parse flags multiply as follows:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": ["KBPS", "BURST"],
"bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
And now enabled to show flags as follows:
curl http://localhost:8080/stats/meterconfig/1
{
"1": [
{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"}],
"flags": ["KBPS", "BURST"], "meter_id": 1}
]
}
Reported-by: cheers <cnmjbm@gmail.com>
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-03-31 14:51:03 +09:00
|
|
|
c_flags = []
|
2016-02-10 13:47:04 +09:00
|
|
|
for k, v in sorted(flags.items()):
|
ofctl_v1_3: Fix to enable using meter flags multiply
ofctl_rest is now enabled to parse flags multiply as follows:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": ["KBPS", "BURST"],
"bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
And now enabled to show flags as follows:
curl http://localhost:8080/stats/meterconfig/1
{
"1": [
{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"}],
"flags": ["KBPS", "BURST"], "meter_id": 1}
]
}
Reported-by: cheers <cnmjbm@gmail.com>
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-03-31 14:51:03 +09:00
|
|
|
if k & config.flags:
|
2016-03-29 19:18:36 +00:00
|
|
|
if to_user:
|
|
|
|
c_flags.append(v)
|
|
|
|
|
|
|
|
else:
|
|
|
|
c_flags.append(k)
|
|
|
|
|
ofctl_v1_3: Fix to enable using meter flags multiply
ofctl_rest is now enabled to parse flags multiply as follows:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": ["KBPS", "BURST"],
"bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
And now enabled to show flags as follows:
curl http://localhost:8080/stats/meterconfig/1
{
"1": [
{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"}],
"flags": ["KBPS", "BURST"], "meter_id": 1}
]
}
Reported-by: cheers <cnmjbm@gmail.com>
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-03-31 14:51:03 +09:00
|
|
|
c = {'flags': c_flags,
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
'bands': bands}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
c['meter_id'] = UTIL.ofp_meter_to_user(config.meter_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
c['meter_id'] = config.meter_id
|
|
|
|
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
configs.append(c)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, configs, to_user)
|
ofctl_v1_3: support OFPMeterConfigStats
Changes v2 -> v3:
- correct the following description
this patch implements a REST API for OFPMeterConfigStats.
e.g., when you send a MeterMod message as:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": "KBPS",
"bands": [{"type": "DROP", "rate": 1000},
{"type": "REMARK", "rate": 2000},
{"type": "EXPERIMENTER", "rate": 3000}
]}' http://localhost:8080/stats/meterentry/add
and you do the following command:
curl http://localhost:8080/stats/meterconfig/1
then you will get the configuration as:
{"1": [{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"},
{"prec_level": 0, "burst_size": 0, "rate": 2000, "type": "REMARK"},
{"burst_size": 0, "rate": 3000, "experimenter": 0, "type": "EXPERIMENTER"}],
"flags": "KBPS",
"meter_id": 1}]}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 16:10:40 +09:00
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
def get_group_stats(dp, waiters, group_id=None, to_user=True):
|
2016-03-22 09:51:42 +09:00
|
|
|
if group_id is None:
|
|
|
|
group_id = dp.ofproto.OFPG_ALL
|
|
|
|
else:
|
2017-02-09 16:44:35 +09:00
|
|
|
group_id = str_to_int(group_id)
|
2016-03-22 09:51:42 +09:00
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
stats = dp.ofproto_parser.OFPGroupStatsRequest(
|
2016-03-22 09:51:42 +09:00
|
|
|
dp, 0, group_id)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
groups = []
|
|
|
|
for msg in msgs:
|
|
|
|
for stats in msg.body:
|
|
|
|
bucket_stats = []
|
|
|
|
for bucket_stat in stats.bucket_stats:
|
|
|
|
c = {'packet_count': bucket_stat.packet_count,
|
|
|
|
'byte_count': bucket_stat.byte_count}
|
|
|
|
bucket_stats.append(c)
|
2014-09-17 17:06:25 -07:00
|
|
|
g = {'length': stats.length,
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
'ref_count': stats.ref_count,
|
|
|
|
'packet_count': stats.packet_count,
|
|
|
|
'byte_count': stats.byte_count,
|
|
|
|
'duration_sec': stats.duration_sec,
|
|
|
|
'duration_nsec': stats.duration_nsec,
|
|
|
|
'bucket_stats': bucket_stats}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
g['group_id'] = UTIL.ofp_group_to_user(stats.group_id)
|
|
|
|
|
|
|
|
else:
|
|
|
|
g['group_id'] = stats.group_id
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
groups.append(g)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
return wrap_dpid_dict(dp, groups, to_user)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_group_features(dp, waiters, to_user=True):
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
ofp = dp.ofproto
|
|
|
|
type_convert = {ofp.OFPGT_ALL: 'ALL',
|
|
|
|
ofp.OFPGT_SELECT: 'SELECT',
|
|
|
|
ofp.OFPGT_INDIRECT: 'INDIRECT',
|
|
|
|
ofp.OFPGT_FF: 'FF'}
|
|
|
|
cap_convert = {ofp.OFPGFC_SELECT_WEIGHT: 'SELECT_WEIGHT',
|
|
|
|
ofp.OFPGFC_SELECT_LIVENESS: 'SELECT_LIVENESS',
|
|
|
|
ofp.OFPGFC_CHAINING: 'CHAINING',
|
2014-09-21 17:15:00 -07:00
|
|
|
ofp.OFPGFC_CHAINING_CHECKS: 'CHAINING_CHECKS'}
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
act_convert = {ofp.OFPAT_OUTPUT: 'OUTPUT',
|
|
|
|
ofp.OFPAT_COPY_TTL_OUT: 'COPY_TTL_OUT',
|
|
|
|
ofp.OFPAT_COPY_TTL_IN: 'COPY_TTL_IN',
|
|
|
|
ofp.OFPAT_SET_MPLS_TTL: 'SET_MPLS_TTL',
|
|
|
|
ofp.OFPAT_DEC_MPLS_TTL: 'DEC_MPLS_TTL',
|
|
|
|
ofp.OFPAT_PUSH_VLAN: 'PUSH_VLAN',
|
|
|
|
ofp.OFPAT_POP_VLAN: 'POP_VLAN',
|
|
|
|
ofp.OFPAT_PUSH_MPLS: 'PUSH_MPLS',
|
|
|
|
ofp.OFPAT_POP_MPLS: 'POP_MPLS',
|
|
|
|
ofp.OFPAT_SET_QUEUE: 'SET_QUEUE',
|
|
|
|
ofp.OFPAT_GROUP: 'GROUP',
|
|
|
|
ofp.OFPAT_SET_NW_TTL: 'SET_NW_TTL',
|
|
|
|
ofp.OFPAT_DEC_NW_TTL: 'DEC_NW_TTL',
|
|
|
|
ofp.OFPAT_SET_FIELD: 'SET_FIELD',
|
|
|
|
ofp.OFPAT_PUSH_PBB: 'PUSH_PBB',
|
|
|
|
ofp.OFPAT_POP_PBB: 'POP_PBB'}
|
|
|
|
|
|
|
|
stats = dp.ofproto_parser.OFPGroupFeaturesStatsRequest(dp, 0)
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
features = []
|
|
|
|
for msg in msgs:
|
|
|
|
feature = msg.body
|
|
|
|
types = []
|
|
|
|
for k, v in type_convert.items():
|
|
|
|
if (1 << k) & feature.types:
|
2016-03-29 19:18:36 +00:00
|
|
|
if to_user:
|
|
|
|
types.append(v)
|
|
|
|
|
|
|
|
else:
|
|
|
|
types.append(k)
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
capabilities = []
|
|
|
|
for k, v in cap_convert.items():
|
|
|
|
if k & feature.capabilities:
|
2016-03-29 19:18:36 +00:00
|
|
|
if to_user:
|
|
|
|
capabilities.append(v)
|
|
|
|
|
|
|
|
else:
|
|
|
|
capabilities.append(k)
|
|
|
|
|
|
|
|
if to_user:
|
|
|
|
max_groups = []
|
|
|
|
for k, v in type_convert.items():
|
|
|
|
max_groups.append({v: feature.max_groups[k]})
|
|
|
|
|
|
|
|
else:
|
|
|
|
max_groups = feature.max_groups
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
actions = []
|
|
|
|
for k1, v1 in type_convert.items():
|
|
|
|
acts = []
|
|
|
|
for k2, v2 in act_convert.items():
|
|
|
|
if (1 << k2) & feature.actions[k1]:
|
2016-03-29 19:18:36 +00:00
|
|
|
if to_user:
|
|
|
|
acts.append(v2)
|
|
|
|
|
|
|
|
else:
|
|
|
|
acts.append(k2)
|
|
|
|
|
|
|
|
if to_user:
|
|
|
|
actions.append({v1: acts})
|
|
|
|
|
|
|
|
else:
|
|
|
|
actions.append({k1: acts})
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
f = {'types': types,
|
|
|
|
'capabilities': capabilities,
|
|
|
|
'max_groups': max_groups,
|
|
|
|
'actions': actions}
|
|
|
|
features.append(f)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
return wrap_dpid_dict(dp, features, to_user)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
def get_group_desc(dp, waiters, to_user=True):
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
type_convert = {dp.ofproto.OFPGT_ALL: 'ALL',
|
|
|
|
dp.ofproto.OFPGT_SELECT: 'SELECT',
|
|
|
|
dp.ofproto.OFPGT_INDIRECT: 'INDIRECT',
|
|
|
|
dp.ofproto.OFPGT_FF: 'FF'}
|
|
|
|
|
|
|
|
stats = dp.ofproto_parser.OFPGroupDescStatsRequest(dp, 0)
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
descs = []
|
|
|
|
for msg in msgs:
|
|
|
|
for stats in msg.body:
|
|
|
|
buckets = []
|
|
|
|
for bucket in stats.buckets:
|
|
|
|
actions = []
|
|
|
|
for action in bucket.actions:
|
2016-03-29 19:18:36 +00:00
|
|
|
if to_user:
|
|
|
|
actions.append(action_to_str(action))
|
|
|
|
|
|
|
|
else:
|
|
|
|
actions.append(action)
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
b = {'weight': bucket.weight,
|
|
|
|
'watch_port': bucket.watch_port,
|
|
|
|
'watch_group': bucket.watch_group,
|
|
|
|
'actions': actions}
|
|
|
|
buckets.append(b)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
d = {'buckets': buckets}
|
|
|
|
if to_user:
|
|
|
|
d['group_id'] = UTIL.ofp_group_to_user(stats.group_id)
|
|
|
|
d['type'] = type_convert.get(stats.type)
|
|
|
|
|
|
|
|
else:
|
|
|
|
d['group_id'] = stats.group_id
|
|
|
|
d['type'] = stats.type
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
descs.append(d)
|
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
return wrap_dpid_dict(dp, descs, to_user)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
def get_port_desc(dp, waiters, to_user=True):
|
ofctl_rest: enable getting Description of a port
this patch makes ofctl_rest enable getting Description of a port.
usage)
URI: /stats/portdesc/<dpid>
method: GET
e.g. )
curl http://localhost:8080/stats/portdesc/1
{"1": [{"hw_addr": "c6:d8:19:4a:e1:4f", "curr": 0, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 4294967294, "curr_speed": 0, "name": "s1",
"state": 1, "config": 1},
{"hw_addr": "8e:96:a1:14:d8:a1", "curr": 2112, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 1, "curr_speed": 10000000, "name": "s1-eth1",
"state": 0, "config": 0}]}
Signed-off-by: TAKAHASHI Minoru <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-07-08 15:02:34 +09:00
|
|
|
|
|
|
|
stats = dp.ofproto_parser.OFPPortDescStatsRequest(dp, 0)
|
|
|
|
msgs = []
|
2016-03-29 19:18:35 +00:00
|
|
|
ofctl_utils.send_stats_request(dp, stats, waiters, msgs, LOG)
|
ofctl_rest: enable getting Description of a port
this patch makes ofctl_rest enable getting Description of a port.
usage)
URI: /stats/portdesc/<dpid>
method: GET
e.g. )
curl http://localhost:8080/stats/portdesc/1
{"1": [{"hw_addr": "c6:d8:19:4a:e1:4f", "curr": 0, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 4294967294, "curr_speed": 0, "name": "s1",
"state": 1, "config": 1},
{"hw_addr": "8e:96:a1:14:d8:a1", "curr": 2112, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 1, "curr_speed": 10000000, "name": "s1-eth1",
"state": 0, "config": 0}]}
Signed-off-by: TAKAHASHI Minoru <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-07-08 15:02:34 +09:00
|
|
|
|
|
|
|
descs = []
|
|
|
|
|
|
|
|
for msg in msgs:
|
|
|
|
stats = msg.body
|
|
|
|
for stat in stats:
|
2016-03-29 19:18:36 +00:00
|
|
|
d = {'hw_addr': stat.hw_addr,
|
2016-10-05 15:56:43 +02:00
|
|
|
'name': stat.name.decode('utf-8', errors='replace'),
|
ofctl_rest: enable getting Description of a port
this patch makes ofctl_rest enable getting Description of a port.
usage)
URI: /stats/portdesc/<dpid>
method: GET
e.g. )
curl http://localhost:8080/stats/portdesc/1
{"1": [{"hw_addr": "c6:d8:19:4a:e1:4f", "curr": 0, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 4294967294, "curr_speed": 0, "name": "s1",
"state": 1, "config": 1},
{"hw_addr": "8e:96:a1:14:d8:a1", "curr": 2112, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 1, "curr_speed": 10000000, "name": "s1-eth1",
"state": 0, "config": 0}]}
Signed-off-by: TAKAHASHI Minoru <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-07-08 15:02:34 +09:00
|
|
|
'config': stat.config,
|
|
|
|
'state': stat.state,
|
|
|
|
'curr': stat.curr,
|
|
|
|
'advertised': stat.advertised,
|
|
|
|
'supported': stat.supported,
|
|
|
|
'peer': stat.peer,
|
|
|
|
'curr_speed': stat.curr_speed,
|
|
|
|
'max_speed': stat.max_speed}
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
if to_user:
|
|
|
|
d['port_no'] = UTIL.ofp_port_to_user(stat.port_no)
|
|
|
|
|
|
|
|
else:
|
|
|
|
d['port_no'] = stat.port_no
|
|
|
|
|
ofctl_rest: enable getting Description of a port
this patch makes ofctl_rest enable getting Description of a port.
usage)
URI: /stats/portdesc/<dpid>
method: GET
e.g. )
curl http://localhost:8080/stats/portdesc/1
{"1": [{"hw_addr": "c6:d8:19:4a:e1:4f", "curr": 0, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 4294967294, "curr_speed": 0, "name": "s1",
"state": 1, "config": 1},
{"hw_addr": "8e:96:a1:14:d8:a1", "curr": 2112, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 1, "curr_speed": 10000000, "name": "s1-eth1",
"state": 0, "config": 0}]}
Signed-off-by: TAKAHASHI Minoru <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-07-08 15:02:34 +09:00
|
|
|
descs.append(d)
|
2016-03-29 19:18:36 +00:00
|
|
|
|
|
|
|
return wrap_dpid_dict(dp, descs, to_user)
|
ofctl_rest: enable getting Description of a port
this patch makes ofctl_rest enable getting Description of a port.
usage)
URI: /stats/portdesc/<dpid>
method: GET
e.g. )
curl http://localhost:8080/stats/portdesc/1
{"1": [{"hw_addr": "c6:d8:19:4a:e1:4f", "curr": 0, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 4294967294, "curr_speed": 0, "name": "s1",
"state": 1, "config": 1},
{"hw_addr": "8e:96:a1:14:d8:a1", "curr": 2112, "supported": 0,
"max_speed": 0, "advertised": 0, "peer": 0,
"port_no": 1, "curr_speed": 10000000, "name": "s1-eth1",
"state": 0, "config": 0}]}
Signed-off-by: TAKAHASHI Minoru <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-07-08 15:02:34 +09:00
|
|
|
|
|
|
|
|
2017-03-22 13:23:07 +09:00
|
|
|
def get_role(dp, waiters, to_user=True):
|
|
|
|
return ofctl_utils.get_role(dp, waiters, to_user)
|
|
|
|
|
|
|
|
|
2013-07-23 21:04:04 +09:00
|
|
|
def mod_flow_entry(dp, flow, cmd):
|
2017-02-09 16:44:35 +09:00
|
|
|
cookie = str_to_int(flow.get('cookie', 0))
|
|
|
|
cookie_mask = str_to_int(flow.get('cookie_mask', 0))
|
2016-01-19 13:46:10 +09:00
|
|
|
table_id = UTIL.ofp_table_from_user(flow.get('table_id', 0))
|
2017-02-09 16:44:35 +09:00
|
|
|
idle_timeout = str_to_int(flow.get('idle_timeout', 0))
|
|
|
|
hard_timeout = str_to_int(flow.get('hard_timeout', 0))
|
|
|
|
priority = str_to_int(flow.get('priority', 0))
|
2016-01-19 13:46:10 +09:00
|
|
|
buffer_id = UTIL.ofp_buffer_from_user(
|
|
|
|
flow.get('buffer_id', dp.ofproto.OFP_NO_BUFFER))
|
|
|
|
out_port = UTIL.ofp_port_from_user(
|
|
|
|
flow.get('out_port', dp.ofproto.OFPP_ANY))
|
|
|
|
out_group = UTIL.ofp_group_from_user(
|
|
|
|
flow.get('out_group', dp.ofproto.OFPG_ANY))
|
2017-02-09 16:44:35 +09:00
|
|
|
flags = str_to_int(flow.get('flags', 0))
|
2013-07-23 21:04:04 +09:00
|
|
|
match = to_match(dp, flow.get('match', {}))
|
2013-08-08 17:51:54 +09:00
|
|
|
inst = to_actions(dp, flow.get('actions', []))
|
2013-07-23 21:04:04 +09:00
|
|
|
|
|
|
|
flow_mod = dp.ofproto_parser.OFPFlowMod(
|
|
|
|
dp, cookie, cookie_mask, table_id, cmd, idle_timeout,
|
|
|
|
hard_timeout, priority, buffer_id, out_port, out_group,
|
|
|
|
flags, match, inst)
|
|
|
|
|
2016-03-29 19:18:34 +00:00
|
|
|
ofctl_utils.send_msg(dp, flow_mod, LOG)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
|
|
|
|
2015-12-24 16:48:07 +09:00
|
|
|
def mod_meter_entry(dp, meter, cmd):
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
|
|
|
flags_convert = {'KBPS': dp.ofproto.OFPMF_KBPS,
|
|
|
|
'PKTPS': dp.ofproto.OFPMF_PKTPS,
|
|
|
|
'BURST': dp.ofproto.OFPMF_BURST,
|
|
|
|
'STATS': dp.ofproto.OFPMF_STATS}
|
|
|
|
|
ofctl_v1_3: Fix to enable using meter flags multiply
ofctl_rest is now enabled to parse flags multiply as follows:
curl -X POST -d '{"dpid": 1,
"meter_id": 1,
"flags": ["KBPS", "BURST"],
"bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
And now enabled to show flags as follows:
curl http://localhost:8080/stats/meterconfig/1
{
"1": [
{"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"}],
"flags": ["KBPS", "BURST"], "meter_id": 1}
]
}
Reported-by: cheers <cnmjbm@gmail.com>
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-03-31 14:51:03 +09:00
|
|
|
flags = 0
|
2015-12-24 16:48:07 +09:00
|
|
|
if 'flags' in meter:
|
|
|
|
meter_flags = meter['flags']
|
|
|
|
if not isinstance(meter_flags, list):
|
|
|
|
meter_flags = [meter_flags]
|
|
|
|
for flag in meter_flags:
|
2015-11-09 13:57:23 +09:00
|
|
|
if flag not in flags_convert:
|
2015-12-24 16:48:07 +09:00
|
|
|
LOG.error('Unknown meter flag: %s', flag)
|
2015-11-09 13:57:23 +09:00
|
|
|
continue
|
|
|
|
flags |= flags_convert.get(flag)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
2016-01-19 13:46:10 +09:00
|
|
|
meter_id = UTIL.ofp_meter_from_user(meter.get('meter_id', 0))
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
|
|
|
bands = []
|
2015-12-24 16:48:07 +09:00
|
|
|
for band in meter.get('bands', []):
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
band_type = band.get('type')
|
2017-02-09 16:44:35 +09:00
|
|
|
rate = str_to_int(band.get('rate', 0))
|
|
|
|
burst_size = str_to_int(band.get('burst_size', 0))
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
if band_type == 'DROP':
|
|
|
|
bands.append(
|
|
|
|
dp.ofproto_parser.OFPMeterBandDrop(rate, burst_size))
|
2014-09-21 17:15:00 -07:00
|
|
|
elif band_type == 'DSCP_REMARK':
|
2017-02-09 16:44:35 +09:00
|
|
|
prec_level = str_to_int(band.get('prec_level', 0))
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
bands.append(
|
|
|
|
dp.ofproto_parser.OFPMeterBandDscpRemark(
|
|
|
|
rate, burst_size, prec_level))
|
|
|
|
elif band_type == 'EXPERIMENTER':
|
2017-02-09 16:44:35 +09:00
|
|
|
experimenter = str_to_int(band.get('experimenter', 0))
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
bands.append(
|
|
|
|
dp.ofproto_parser.OFPMeterBandExperimenter(
|
|
|
|
rate, burst_size, experimenter))
|
|
|
|
else:
|
2015-01-08 13:45:31 +09:00
|
|
|
LOG.error('Unknown band type: %s', band_type)
|
ofctl_v1_3: support meter
Support meter in FlowMod instructions and support MeterMod, MeterStats, MeterFeatures.
see following examples.
FlowMod with the meter instruction:
flow = {'match': {},
'actions': [{'type': 'METER',
'meter_id': 1}]
curl -X POST -d '{"dpid": 1, "match": {}, "actions": [{"type": "METER", "meter_id": 1}]}' http://localhost:8080/stats/flowentry/add
MeterMod:
meter = {'meter_id': 1,
'flags': 'KBPS',
'bands': [{'type': 'DROP',
'rate': 1000}]}
curl -X POST -d '{"dpid": 1, "meter_id": 1, "flags": "KBPS", "bands": [{"type": "DROP", "rate": 1000}]}' http://localhost:8080/stats/meterentry/add
NOTE: flags: 'KBPS', 'PKTPS', 'BURST', 'STATS'
type: 'DROP', 'REMARK', 'EXPERIMENTER'
MeterStats:
curl http://localhost:8080/stats/meter/1
MetetFeatures:
curl http://localhost:8080/stats/meterfeatures/1
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2013-12-20 11:43:01 +09:00
|
|
|
|
|
|
|
meter_mod = dp.ofproto_parser.OFPMeterMod(
|
|
|
|
dp, cmd, flags, meter_id, bands)
|
|
|
|
|
2016-03-29 19:18:34 +00:00
|
|
|
ofctl_utils.send_msg(dp, meter_mod, LOG)
|
2014-01-06 16:46:51 +09:00
|
|
|
|
|
|
|
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
def mod_group_entry(dp, group, cmd):
|
|
|
|
|
|
|
|
type_convert = {'ALL': dp.ofproto.OFPGT_ALL,
|
|
|
|
'SELECT': dp.ofproto.OFPGT_SELECT,
|
|
|
|
'INDIRECT': dp.ofproto.OFPGT_INDIRECT,
|
|
|
|
'FF': dp.ofproto.OFPGT_FF}
|
|
|
|
|
2014-09-26 15:58:02 +09:00
|
|
|
type_ = type_convert.get(group.get('type', 'ALL'))
|
2014-03-13 07:04:50 +00:00
|
|
|
if type_ is None:
|
2015-12-24 16:48:07 +09:00
|
|
|
LOG.error('Unknown group type: %s', group.get('type'))
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
2016-01-19 13:46:10 +09:00
|
|
|
group_id = UTIL.ofp_group_from_user(group.get('group_id', 0))
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
buckets = []
|
|
|
|
for bucket in group.get('buckets', []):
|
2017-02-09 16:44:35 +09:00
|
|
|
weight = str_to_int(bucket.get('weight', 0))
|
|
|
|
watch_port = str_to_int(
|
|
|
|
bucket.get('watch_port', dp.ofproto.OFPP_ANY))
|
|
|
|
watch_group = str_to_int(
|
|
|
|
bucket.get('watch_group', dp.ofproto.OFPG_ANY))
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
actions = []
|
|
|
|
for dic in bucket.get('actions', []):
|
|
|
|
action = to_action(dp, dic)
|
|
|
|
if action is not None:
|
|
|
|
actions.append(action)
|
|
|
|
buckets.append(dp.ofproto_parser.OFPBucket(
|
|
|
|
weight, watch_port, watch_group, actions))
|
|
|
|
|
|
|
|
group_mod = dp.ofproto_parser.OFPGroupMod(
|
|
|
|
dp, cmd, type_, group_id, buckets)
|
|
|
|
|
2016-03-29 19:18:34 +00:00
|
|
|
ofctl_utils.send_msg(dp, group_mod, LOG)
|
ofctl_rest: support group-related messages
this patch makes ofctl_rest possible to:
- support the GROUP action in the FlowMod message
- support the GroupMod message
- support the GroupStats message
- support the GroupFeatures message
- support the GroupDesc message
see following examples.
FlowMod with the group action:
e.g.)
curl -X POST -d '{"dpid": 1,
"match": {},
"actions": [{"type": "GROUP,
"group_id": 1}]}' http://localhost:8080/stats/flowentry/add
GroupMod:
usage)
URI: /stats/groupentry/{cmd}
METHOD: POST
NOTE: the value of 'cmd' is one of follows: 'add', 'modify', or 'delete'.
the message body is as follows:
type Group types. 'ALL', 'SELECT', 'INDIRECT', or 'FF'.
group_id Group Identifier. (default: 0)
buckets a list of buckets.
where each bucket has the following members:
weight Relative weight of bucket. (default: 0)
watch_port Port whose state affects whether this bucket is live. (default: OFPP_ANY)
watch_group Group whose state affects whether this bucket is live. (default: OFPG_ANY)
actions a list of actions. the format is the same as that of FlowMod.
e.g.)
curl -X POST -d '{"dpid": 1,
"type": "FF",
"group_id": 1,
"buckets": [{"watch_port": 2,
"actions": [{"type": "OUTPUT",
"port": 3}]}]}' http://localhost:8080/stats/groupentry/add
GroupStats:
usage)
URI: /stats/group/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/group/1
{
"1": [
{
"bucket_stats": [
{
"packet_count": 0,
"byte_count": 0
}
],
"byte_count": 0,
"ref_count": 0,
"duration_nsec": 231000000,
"packet_count": 0,
"duration_sec": 11238,
"group_id": 1
}
]
}
GroupFeatures:
usage)
URI: /stats/groupfeatures/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupfeatures/1
{
"1": [
{
"actions": [
{"ALL": ["OUTPUT", "COPY_TTL_OUT", "COPY_TTL_IN", "SET_MPLS_TTL", "DEC_MPLS_TTL", "PUSH_VLAN", "POP_VLAN", "PUSH_MPLS", "POP_MPLS", "SET_QUEUE", "GROUP", "SET_NW_TTL", "DEC_NW_TTL", "SET_FIELD"]},
{"SELECT": []},
{"INDIRECT": []},
{"FF": []}
],
"max_groups": [
{"ALL": 4294967040},
{"SELECT": 4294967040},
{"INDIRECT": 4294967040},
{"FF": 4294967040}
],
"capabilities": ["SELECT_WEIGHT", "SELECT_LIVENESS", "CHAINING"],
"types": []
}
]
}
GroupDesc:
usage)
URI: /stats/groupdesc/{dpid}
METHOD: GET
e.g.)
curl http://localhost:8080/stats/groupdesc/1
{
"1": [
{
"buckets": [
{
"actions": ["OUTPUT:2"],
"watch_group": 4294967295,
"weight": 0,
"watch_port": 3
}
],
"group_id": 1,
"type": "FF"
}
]
}
Signed-off-by: Yuichi Ito <ito.yuichi0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
2014-01-08 14:29:21 +09:00
|
|
|
|
|
|
|
|
2014-07-08 15:00:51 +09:00
|
|
|
def mod_port_behavior(dp, port_config):
|
2016-01-19 13:46:10 +09:00
|
|
|
port_no = UTIL.ofp_port_from_user(port_config.get('port_no', 0))
|
2016-01-18 10:53:09 +09:00
|
|
|
hw_addr = str(port_config.get('hw_addr'))
|
2017-02-09 16:44:35 +09:00
|
|
|
config = str_to_int(port_config.get('config', 0))
|
|
|
|
mask = str_to_int(port_config.get('mask', 0))
|
|
|
|
advertise = str_to_int(port_config.get('advertise'))
|
2014-07-08 15:00:51 +09:00
|
|
|
|
|
|
|
port_mod = dp.ofproto_parser.OFPPortMod(
|
|
|
|
dp, port_no, hw_addr, config, mask, advertise)
|
|
|
|
|
2016-03-29 19:18:34 +00:00
|
|
|
ofctl_utils.send_msg(dp, port_mod, LOG)
|
2014-07-08 15:00:51 +09:00
|
|
|
|
|
|
|
|
2016-08-25 15:53:17 +08:00
|
|
|
def set_role(dp, role):
|
|
|
|
r = UTIL.ofp_role_from_user(role.get('role', dp.ofproto.OFPCR_ROLE_EQUAL))
|
|
|
|
role_request = dp.ofproto_parser.OFPRoleRequest(dp, r, 0)
|
|
|
|
ofctl_utils.send_msg(dp, role_request, LOG)
|
|
|
|
|
|
|
|
|
2016-03-29 19:18:39 +00:00
|
|
|
# NOTE(jkoelker) Alias common funcitons
|
|
|
|
send_experimenter = ofctl_utils.send_experimenter
|