summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKiyonari Harigae <lakshmi@cloudysunny14.org>2014-02-27 21:27:59 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-02-27 21:42:31 +0900
commit39b78cc2c7430b4c2f0f18388dbc0e88b0406639 (patch)
tree1f212fc0fdca1d6ea19cc1b51471b344500dcc4f
parent4e60ce00cb27ad27f07ec29d652cddb8407124ad (diff)
ofctl_v1_3:support whole of match fields
Signed-off-by: Kiyonari Harigae <lakshmi@cloudysunny14.org> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/ofctl_v1_3.py108
1 files changed, 74 insertions, 34 deletions
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 39d1366e..3e2713e8 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -87,23 +87,7 @@ def to_action(dp, dic):
elif action_type == 'SET_FIELD':
field = dic.get('field')
value = dic.get('value')
- if field == 'eth_dst':
- field = ofp.OXM_OF_ETH_DST
- value = mac.haddr_to_bin(str(value))
- elif field == 'eth_src':
- field = ofp.OXM_OF_ETH_SRC
- value = mac.haddr_to_bin(str(value))
- elif field == 'vlan_vid':
- field = ofp.OXM_OF_VLAN_VID
- value = int(value)
- elif field == 'mpls_label':
- field = ofp.OXM_OF_MPLS_LABEL
- value = int(value)
- else:
- LOG.debug('Unknown field: %s' % field)
- return None
- f = parser.OFPMatchField.make(field, value)
- result = parser.OFPActionSetField(f)
+ result = parser.OFPActionSetField(**{field: value})
elif action_type == 'PUSH_PBB':
ethertype = int(dic.get('ethertype'))
result = parser.OFPActionPushPbb(ethertype)
@@ -179,17 +163,7 @@ def action_to_str(act):
elif action_type == ofproto_v1_3.OFPAT_DEC_NW_TTL:
buf = 'DEC_NW_TTL'
elif action_type == ofproto_v1_3.OFPAT_SET_FIELD:
- if isinstance(act.field, ofproto_v1_3_parser.MTEthDst):
- field = 'eth_dst'
- elif isinstance(act.field, ofproto_v1_3_parser.MTEthSrc):
- field = 'eth_src'
- elif isinstance(act.field, ofproto_v1_3_parser.MTVlanVid):
- field = 'vlan_vid'
- elif isinstance(act.field, ofproto_v1_3_parser.MTMplsLabel):
- field = 'mpls_label'
- else:
- field = '(Unknown field)'
- buf = 'SET_FIELD: {%s:%s}' % (field, act.value)
+ buf = 'SET_FIELD: {%s:%s}' % (act.key, act.value)
elif action_type == ofproto_v1_3.OFPAT_PUSH_PBB:
buf = 'PUSH_PBB:' + str(act.ethertype)
elif action_type == ofproto_v1_3.OFPAT_POP_PBB:
@@ -234,12 +208,15 @@ def actions_to_str(instructions):
def to_match(dp, attrs):
match = dp.ofproto_parser.OFPMatch()
-
convert = {'in_port': int,
+ 'in_phy_port': int,
'dl_src': mac.haddr_to_bin,
'dl_dst': mac.haddr_to_bin,
'dl_type': int,
'dl_vlan': int,
+ 'vlan_pcp': int,
+ 'ip_dscp': int,
+ 'ip_ecn': int,
'nw_src': to_match_ip,
'nw_dst': to_match_ip,
'nw_proto': int,
@@ -258,16 +235,35 @@ def to_match(dp, attrs):
'tcp_dst': int,
'udp_src': int,
'udp_dst': int,
+ 'sctp_src': int,
+ 'sctp_dst': int,
+ 'icmpv4_type': int,
+ 'icmpv4_code': int,
+ 'arp_op': int,
'arp_spa': to_match_ip,
'arp_tpa': to_match_ip,
+ 'arp_sha': mac.haddr_to_bin,
+ 'arp_tha': mac.haddr_to_bin,
'ipv6_src': to_match_ipv6,
- 'ipv6_dst': to_match_ipv6}
+ 'ipv6_dst': to_match_ipv6,
+ 'ipv6_flabel': int,
+ 'icmpv6_type': int,
+ 'icmpv6_code': int,
+ 'ipv6_nd_target': to_match_ipv6,
+ 'ipv6_nd_sll': mac.haddr_to_bin,
+ 'ipv6_nd_tll': mac.haddr_to_bin,
+ 'mpls_tc': int,
+ 'mpls_bos': int,
+ 'pbb_isid': int,
+ 'tunnel_id': int,
+ 'ipv6_exthdr': int}
match_append = {'in_port': match.set_in_port,
'dl_src': match.set_dl_src,
'dl_dst': match.set_dl_dst,
'dl_type': match.set_dl_type,
'dl_vlan': match.set_vlan_vid,
+ 'vlan_pcp': match.set_vlan_pcp,
'nw_src': match.set_ipv4_src_masked,
'nw_dst': match.set_ipv4_dst_masked,
'nw_proto': match.set_ip_proto,
@@ -279,6 +275,8 @@ def to_match(dp, attrs):
'eth_dst': match.set_dl_dst,
'eth_type': match.set_dl_type,
'vlan_vid': match.set_vlan_vid,
+ 'ip_dscp': match.set_ip_dscp,
+ 'ip_ecn': match.set_ip_ecn,
'ipv4_src': match.set_ipv4_src_masked,
'ipv4_dst': match.set_ipv4_dst_masked,
'ip_proto': match.set_ip_proto,
@@ -286,10 +284,28 @@ def to_match(dp, attrs):
'tcp_dst': to_match_tpdst,
'udp_src': to_match_tpsrc,
'udp_dst': to_match_tpdst,
+ 'sctp_src': match.set_sctp_src,
+ 'sctp_dst': match.set_sctp_dst,
+ 'icmpv4_type': match.set_icmpv4_type,
+ 'icmpv4_code': match.set_icmpv4_code,
+ 'arp_op': match.set_arp_opcode,
'arp_spa': match.set_arp_spa_masked,
'arp_tpa': match.set_arp_tpa_masked,
+ 'arp_sha': match.set_arp_sha,
+ 'arp_tha': match.set_arp_tha,
'ipv6_src': match.set_ipv6_src_masked,
- 'ipv6_dst': match.set_ipv6_dst_masked}
+ 'ipv6_dst': match.set_ipv6_dst_masked,
+ 'ipv6_flabel': match.set_ipv6_flabel,
+ 'icmpv6_type': match.set_icmpv6_type,
+ 'icmpv6_code': match.set_icmpv6_code,
+ 'ipv6_nd_target': match.set_ipv6_nd_target,
+ 'ipv6_nd_sll': match.set_ipv6_nd_sll,
+ 'ipv6_nd_tll': match.set_ipv6_nd_tll,
+ 'mpls_tc': match.set_mpls_tc,
+ 'mpls_bos': match.set_mpls_bos,
+ 'pbb_isid': match.set_pbb_isid,
+ 'tunnel_id': match.set_tunnel_id,
+ 'ipv6_exthdr': match.set_ipv6_exthdr}
if attrs.get('dl_type') == ether.ETH_TYPE_ARP or \
attrs.get('eth_type') == ether.ETH_TYPE_ARP:
@@ -380,10 +396,14 @@ def to_match_metadata(value):
def match_to_str(ofmatch):
keys = {ofproto_v1_3.OXM_OF_IN_PORT: 'in_port',
+ ofproto_v1_3.OXM_OF_IN_PHY_PORT: 'in_phy_port',
ofproto_v1_3.OXM_OF_ETH_SRC: 'dl_src',
ofproto_v1_3.OXM_OF_ETH_DST: 'dl_dst',
ofproto_v1_3.OXM_OF_ETH_TYPE: 'dl_type',
ofproto_v1_3.OXM_OF_VLAN_VID: 'dl_vlan',
+ ofproto_v1_3.OXM_OF_VLAN_PCP: 'vlan_pcp',
+ ofproto_v1_3.OXM_OF_IP_DSCP: 'ip_dscp',
+ ofproto_v1_3.OXM_OF_IP_ECN: 'ip_ecn',
ofproto_v1_3.OXM_OF_IPV4_SRC: 'nw_src',
ofproto_v1_3.OXM_OF_IPV4_DST: 'nw_dst',
ofproto_v1_3.OXM_OF_IPV4_SRC_W: 'nw_src',
@@ -393,22 +413,42 @@ def match_to_str(ofmatch):
ofproto_v1_3.OXM_OF_TCP_DST: 'tp_dst',
ofproto_v1_3.OXM_OF_UDP_SRC: 'tp_src',
ofproto_v1_3.OXM_OF_UDP_DST: 'tp_dst',
+ ofproto_v1_3.OXM_OF_SCTP_SRC: 'sctp_src',
+ ofproto_v1_3.OXM_OF_SCTP_DST: 'sctp_dst',
+ ofproto_v1_3.OXM_OF_ICMPV4_TYPE: 'icmpv4_type',
+ ofproto_v1_3.OXM_OF_ICMPV4_CODE: 'icmpv4_code',
ofproto_v1_3.OXM_OF_MPLS_LABEL: 'mpls_label',
+ ofproto_v1_3.OXM_OF_MPLS_TC: 'mpls_tc',
+ ofproto_v1_3.OXM_OF_MPLS_BOS: 'mpls_bos',
ofproto_v1_3.OXM_OF_METADATA: 'metadata',
ofproto_v1_3.OXM_OF_METADATA_W: 'metadata',
+ ofproto_v1_3.OXM_OF_ARP_OP: 'arp_op',
ofproto_v1_3.OXM_OF_ARP_SPA: 'arp_spa',
ofproto_v1_3.OXM_OF_ARP_TPA: 'arp_tpa',
ofproto_v1_3.OXM_OF_ARP_SPA_W: 'arp_spa',
ofproto_v1_3.OXM_OF_ARP_TPA_W: 'arp_tpa',
+ ofproto_v1_3.OXM_OF_ARP_SHA: 'arp_sha',
+ ofproto_v1_3.OXM_OF_ARP_THA: 'arp_tha',
ofproto_v1_3.OXM_OF_IPV6_SRC: 'ipv6_src',
ofproto_v1_3.OXM_OF_IPV6_DST: 'ipv6_dst',
ofproto_v1_3.OXM_OF_IPV6_SRC_W: 'ipv6_src',
- ofproto_v1_3.OXM_OF_IPV6_DST_W: 'ipv6_dst'}
+ ofproto_v1_3.OXM_OF_IPV6_DST_W: 'ipv6_dst',
+ ofproto_v1_3.OXM_OF_IPV6_FLABEL: 'ipv6_flabel',
+ ofproto_v1_3.OXM_OF_ICMPV6_TYPE: 'icmpv6_type',
+ ofproto_v1_3.OXM_OF_ICMPV6_CODE: 'icmpv6_code',
+ ofproto_v1_3.OXM_OF_IPV6_ND_TARGET: 'ipv6_nd_target',
+ ofproto_v1_3.OXM_OF_IPV6_ND_SLL: 'ipv6_nd_sll',
+ ofproto_v1_3.OXM_OF_IPV6_ND_TLL: 'ipv6_nd_tll',
+ ofproto_v1_3.OXM_OF_PBB_ISID: 'pbb_isid',
+ ofproto_v1_3.OXM_OF_TUNNEL_ID: 'tunnel_id',
+ ofproto_v1_3.OXM_OF_IPV6_EXTHDR: 'ipv6_exthdr'}
match = {}
for match_field in ofmatch.fields:
key = keys[match_field.header]
- if key == 'dl_src' or key == 'dl_dst':
+ if key == 'dl_src' or key == 'dl_dst' or key == 'arp_sha' or \
+ key == 'arp_tha' or key == 'ipv6_nd_tll' or \
+ key == 'ipv6_nd_sll':
value = mac.haddr_to_str(match_field.value)
elif key == 'nw_src' or key == 'nw_dst' or \
key == 'arp_spa' or key == 'arp_tpa':
@@ -490,7 +530,7 @@ def get_desc_stats(dp, waiters):
def get_flow_stats(dp, waiters):
- table_id = 0
+ table_id = dp.ofproto.OFPTT_ALL
flags = 0
out_port = dp.ofproto.OFPP_ANY
out_group = dp.ofproto.OFPG_ANY