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 <[email protected]>
---
 ryu/lib/ofctl_v1_2.py |   15 +++++++++++++++
 ryu/lib/ofctl_v1_3.py |   15 +++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index ef76b7b..2eca850 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 9f99680..4bb6ca2 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]
-- 
1.7.10.4


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to