summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYuichi Ito <ito.yuichi0@gmail.com>2014-01-14 13:58:20 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-01-15 19:54:23 +0900
commitfaebcd2b3f273338ea01e0ff54229a5052eb41c3 (patch)
treea61f92f37a002d571b30419b9ffc07a3f4286d95
parent328385df862af06e5d43a46a5694c35908a74047 (diff)
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>
-rw-r--r--ryu/lib/ofctl_v1_2.py15
-rw-r--r--ryu/lib/ofctl_v1_3.py15
2 files changed, 30 insertions, 0 deletions
diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index ef76b7b9..2eca8508 100644
--- a/ryu/lib/ofctl_v1_2.py
+++ b/ryu/lib/ofctl_v1_2.py
@@ -19,6 +19,7 @@ import socket
import logging
import netaddr
+from ryu.ofproto import ether
from ryu.ofproto import inet
from ryu.ofproto import ofproto_v1_2
from ryu.ofproto import ofproto_v1_2_parser
@@ -228,6 +229,8 @@ def to_match(dp, attrs):
'tcp_dst': int,
'udp_src': int,
'udp_dst': int,
+ 'arp_spa': to_match_ip,
+ 'arp_tpa': to_match_ip,
'ipv6_src': to_match_ipv6,
'ipv6_dst': to_match_ipv6}
@@ -252,15 +255,27 @@ def to_match(dp, attrs):
'tcp_dst': to_match_tpdst,
'udp_src': to_match_tpsrc,
'udp_dst': to_match_tpdst,
+ 'arp_spa': match.set_arp_spa_masked,
+ 'arp_tpa': match.set_arp_tpa_masked,
'ipv6_src': match.set_ipv6_src_masked,
'ipv6_dst': match.set_ipv6_dst_masked}
+ if attrs.get('dl_type') == ether.ETH_TYPE_ARP or \
+ attrs.get('eth_type') == ether.ETH_TYPE_ARP:
+ if 'nw_src' in attrs and not 'arp_spa' in attrs:
+ attrs['arp_spa'] = attrs['nw_src']
+ del attrs['nw_src']
+ if 'nw_dst' in attrs and not 'arp_tpa' in attrs:
+ attrs['arp_tpa'] = attrs['nw_dst']
+ del attrs['nw_dst']
+
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' or \
key == 'ipv4_src' or key == 'ipv4_dst' or \
+ key == 'arp_spa' or key == 'arp_tpa' or \
key == 'ipv6_src' or key == 'ipv6_dst':
# IP address
ip = value[0]
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 9f996800..4bb6ca24 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -19,6 +19,7 @@ import socket
import logging
import netaddr
+from ryu.ofproto import ether
from ryu.ofproto import inet
from ryu.ofproto import ofproto_v1_3
from ryu.ofproto import ofproto_v1_3_parser
@@ -247,6 +248,8 @@ def to_match(dp, attrs):
'tcp_dst': int,
'udp_src': int,
'udp_dst': int,
+ 'arp_spa': to_match_ip,
+ 'arp_tpa': to_match_ip,
'ipv6_src': to_match_ipv6,
'ipv6_dst': to_match_ipv6}
@@ -273,15 +276,27 @@ def to_match(dp, attrs):
'tcp_dst': to_match_tpdst,
'udp_src': to_match_tpsrc,
'udp_dst': to_match_tpdst,
+ 'arp_spa': match.set_arp_spa_masked,
+ 'arp_tpa': match.set_arp_tpa_masked,
'ipv6_src': match.set_ipv6_src_masked,
'ipv6_dst': match.set_ipv6_dst_masked}
+ if attrs.get('dl_type') == ether.ETH_TYPE_ARP or \
+ attrs.get('eth_type') == ether.ETH_TYPE_ARP:
+ if 'nw_src' in attrs and not 'arp_spa' in attrs:
+ attrs['arp_spa'] = attrs['nw_src']
+ del attrs['nw_src']
+ if 'nw_dst' in attrs and not 'arp_tpa' in attrs:
+ attrs['arp_tpa'] = attrs['nw_dst']
+ del attrs['nw_dst']
+
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' or \
key == 'ipv4_src' or key == 'ipv4_dst' or \
+ key == 'arp_spa' or key == 'arp_tpa' or \
key == 'ipv6_src' or key == 'ipv6_dst':
# IP address
ip = value[0]