this patch gets match field names to support OXM field names.
NOTE: OpenFlow1.0 does not support OXM field names.
the compatibility is as follows:
dl_src eth_src
dl_dst eth_dst
dl_type eth_type
dl_vlan vlan_vid
nw_src ipv4_src
nw_dst ipv4_dst
nw_proto ip_proto
tp_src tcp_src or udp_src
tp_dst tcp_dst or udp_dst
for example, the following commands for ofctl_rest install the same flow entry.
curl -X POST -d '{"dpid": 1,
"match": {"dl_type": 2048,
"nw_src": "192.168.1.1"},
"actions": [{"type": "OUTPUT",
"port": 2}]}'
http://localhost:8080/stats/flowentry/add
curl -X POST -d '{"dpid": 1,
"match": {"eth_type": 2048,
"ipv4_src": 192.168.1.1"},
"actions": [{"type": "OUTPUT",
"port": 2}]}'
http://localhost:8080/stats/flowentry/add
Signed-off-by: Yuichi Ito <[email protected]>
---
ryu/lib/ofctl_v1_2.py | 37 +++++++++++++++++++++++++++++++------
ryu/lib/ofctl_v1_3.py | 37 +++++++++++++++++++++++++++++++------
2 files changed, 62 insertions(+), 12 deletions(-)
diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index 1591c35..c0da95a 100644
--- a/ryu/lib/ofctl_v1_2.py
+++ b/ryu/lib/ofctl_v1_2.py
@@ -79,7 +79,18 @@ def to_match(dp, attrs):
'nw_dst': to_match_ip,
'nw_proto': int,
'tp_src': int,
- 'tp_dst': int}
+ 'tp_dst': int,
+ 'eth_src': mac.haddr_to_bin,
+ 'eth_dst': mac.haddr_to_bin,
+ 'eth_type': int,
+ 'vlan_vid': int,
+ 'ipv4_src': to_match_ip,
+ 'ipv4_dst': to_match_ip,
+ 'ip_proto': int,
+ 'tcp_src': int,
+ 'tcp_dst': int,
+ 'udp_src': int,
+ 'udp_dst': int}
match_append = {'in_port': match.set_in_port,
'dl_src': match.set_dl_src,
@@ -90,18 +101,32 @@ def to_match(dp, attrs):
'nw_dst': match.set_ipv4_dst_masked,
'nw_proto': match.set_ip_proto,
'tp_src': to_match_tpsrc,
- 'tp_dst': to_match_tpdst}
+ 'tp_dst': to_match_tpdst,
+ 'eth_src': match.set_dl_src,
+ 'eth_dst': match.set_dl_dst,
+ 'eth_type': match.set_dl_type,
+ 'vlan_vid': match.set_vlan_vid,
+ 'ipv4_src': match.set_ipv4_src_masked,
+ 'ipv4_dst': match.set_ipv4_dst_masked,
+ 'ip_proto': match.set_ip_proto,
+ 'tcp_src': to_match_tpsrc,
+ 'tcp_dst': to_match_tpdst,
+ 'udp_src': to_match_tpsrc,
+ 'udp_dst': to_match_tpdst}
for key, value in attrs.items():
if key in convert:
value = convert[key](value)
if key in match_append:
- if key == 'nw_src' or key == 'nw_dst':
+ if key == 'nw_src' or key == 'nw_dst' or \
+ key == 'ipv4_src' or key == 'ipv4_dst':
# IP address
ip = value[0]
mask = value[1]
match_append[key](ip, mask)
- elif key == 'tp_src' or key == 'tp_dst':
+ elif key == 'tp_src' or key == 'tp_dst' or \
+ key == 'tcp_src' or key == 'tcp_dst' or \
+ key == 'udp_src' or key == 'udp_dst':
# tp_src/dst
match = match_append[key](value, match, attrs)
else:
@@ -115,7 +140,7 @@ def to_match_tpsrc(value, match, rest):
match_append = {inet.IPPROTO_TCP: match.set_tcp_src,
inet.IPPROTO_UDP: match.set_udp_src}
- nw_proto = rest.get('nw_proto', 0)
+ nw_proto = rest.get('nw_proto', rest.get('ip_proto', 0))
if nw_proto in match_append:
match_append[nw_proto](value)
@@ -126,7 +151,7 @@ def to_match_tpdst(value, match, rest):
match_append = {inet.IPPROTO_TCP: match.set_tcp_dst,
inet.IPPROTO_UDP: match.set_udp_dst}
- nw_proto = rest.get('nw_proto', 0)
+ nw_proto = rest.get('nw_proto', rest.get('ip_proto', 0))
if nw_proto in match_append:
match_append[nw_proto](value)
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 107220c..4516a56 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -212,7 +212,18 @@ def to_match(dp, attrs):
'tp_src': int,
'tp_dst': int,
'mpls_label': int,
- 'metadata': to_match_metadata}
+ 'metadata': to_match_metadata,
+ 'eth_src': mac.haddr_to_bin,
+ 'eth_dst': mac.haddr_to_bin,
+ 'eth_type': int,
+ 'vlan_vid': int,
+ 'ipv4_src': to_match_ip,
+ 'ipv4_dst': to_match_ip,
+ 'ip_proto': int,
+ 'tcp_src': int,
+ 'tcp_dst': int,
+ 'udp_src': int,
+ 'udp_dst': int}
match_append = {'in_port': match.set_in_port,
'dl_src': match.set_dl_src,
@@ -225,18 +236,32 @@ def to_match(dp, attrs):
'tp_src': to_match_tpsrc,
'tp_dst': to_match_tpdst,
'mpls_label': match.set_mpls_label,
- 'metadata': match.set_metadata_masked}
+ 'metadata': match.set_metadata_masked,
+ 'eth_src': match.set_dl_src,
+ 'eth_dst': match.set_dl_dst,
+ 'eth_type': match.set_dl_type,
+ 'vlan_vid': match.set_vlan_vid,
+ 'ipv4_src': match.set_ipv4_src_masked,
+ 'ipv4_dst': match.set_ipv4_dst_masked,
+ 'ip_proto': match.set_ip_proto,
+ 'tcp_src': to_match_tpsrc,
+ 'tcp_dst': to_match_tpdst,
+ 'udp_src': to_match_tpsrc,
+ 'udp_dst': to_match_tpdst}
for key, value in attrs.items():
if key in convert:
value = convert[key](value)
if key in match_append:
- if key == 'nw_src' or key == 'nw_dst':
+ if key == 'nw_src' or key == 'nw_dst' or \
+ key == 'ipv4_src' or key == 'ipv4_dst':
# IP address
ip = value[0]
mask = value[1]
match_append[key](ip, mask)
- elif key == 'tp_src' or key == 'tp_dst':
+ elif key == 'tp_src' or key == 'tp_dst' or \
+ key == 'tcp_src' or key == 'tcp_dst' or \
+ key == 'udp_src' or key == 'udp_dst':
# tp_src/dst
match_append[key](value, match, attrs)
elif key == 'metadata':
@@ -255,7 +280,7 @@ def to_match_tpsrc(value, match, rest):
match_append = {inet.IPPROTO_TCP: match.set_tcp_src,
inet.IPPROTO_UDP: match.set_udp_src}
- nw_proto = rest.get('nw_proto', 0)
+ nw_proto = rest.get('nw_proto', rest.get('ip_proto', 0))
if nw_proto in match_append:
match_append[nw_proto](value)
@@ -266,7 +291,7 @@ def to_match_tpdst(value, match, rest):
match_append = {inet.IPPROTO_TCP: match.set_tcp_dst,
inet.IPPROTO_UDP: match.set_udp_dst}
- nw_proto = rest.get('nw_proto', 0)
+ nw_proto = rest.get('nw_proto', rest.get('ip_proto', 0))
if nw_proto in match_append:
match_append[nw_proto](value)
--
1.7.10.4
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel