]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix ovs_lib's issue of parsing flow proto field
authorChengli XU <xuchengli@corp.netease.com>
Wed, 11 Sep 2013 05:58:15 +0000 (13:58 +0800)
committerChengli XU <xuchengli@corp.netease.com>
Wed, 11 Sep 2013 07:57:25 +0000 (15:57 +0800)
When 'proto' other than 'ip' and nw_src/nw_dst are provided at the same
time, the proto parameter will be ignored.

Fixes bug: 1223668

Change-Id: Ie813e66995e2a9310ec4b48c0f7de673db2097f1

neutron/agent/linux/ovs_lib.py
neutron/tests/unit/openvswitch/test_ovs_lib.py

index 2c2bd9d8b507687c89fa5f8dce47e0ce03585b1f..98ad2a195fb335041828f527044ac5da64d00804 100644 (file)
@@ -142,7 +142,7 @@ class OVSBridge:
         proto = 'proto' in kwargs and ",%s" % kwargs['proto'] or ''
         ip = ('nw_src' in kwargs or 'nw_dst' in kwargs) and ',ip' or ''
         match = (table + in_port + dl_type + dl_vlan + dl_src + dl_dst +
-                (ip or proto) + nw_src + nw_dst + tun_id)
+                (proto or ip) + nw_src + nw_dst + tun_id)
         if match:
             match = match[1:]  # strip leading comma
             flow_expr_arr.append(match)
index 1b9486affe4a5a5bfdc279b3aa4d91d59dae4675..d0c8f33620ec4a3fe26674b48c3566ded32e3f82 100644 (file)
@@ -91,6 +91,7 @@ class OVS_Lib_Test(base.BaseTestCase):
         ofport = "99"
         vid = 4000
         lsw_id = 18
+        cidr = '192.168.1.0/24'
         utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
                        "hard_timeout=0,idle_timeout=0,"
                        "priority=2,dl_src=ca:fe:de:ad:be:ef"
@@ -119,6 +120,10 @@ class OVS_Lib_Test(base.BaseTestCase):
                        "priority=3,tun_id=%s,actions="
                        "mod_vlan_vid:%s,output:%s"
                        % (lsw_id, vid, ofport)], root_helper=self.root_helper)
+        utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
+                       "hard_timeout=0,idle_timeout=0,"
+                       "priority=4,arp,nw_src=%s,actions=drop" % cidr],
+                      root_helper=self.root_helper)
         self.mox.ReplayAll()
 
         self.br.add_flow(priority=2, dl_src="ca:fe:de:ad:be:ef",
@@ -133,6 +138,7 @@ class OVS_Lib_Test(base.BaseTestCase):
         self.br.add_flow(priority=3, tun_id=lsw_id,
                          actions="mod_vlan_vid:%s,output:%s" %
                          (vid, ofport))
+        self.br.add_flow(priority=4, proto='arp', nw_src=cidr, actions='drop')
         self.mox.VerifyAll()
 
     def test_get_port_ofport(self):