From: Chengli XU Date: Wed, 11 Sep 2013 05:58:15 +0000 (+0800) Subject: Fix ovs_lib's issue of parsing flow proto field X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=515866acf292feffbb6ad7fc177c3ba337aff42e;p=openstack-build%2Fneutron-build.git Fix ovs_lib's issue of parsing flow proto field 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 --- diff --git a/neutron/agent/linux/ovs_lib.py b/neutron/agent/linux/ovs_lib.py index 2c2bd9d8b..98ad2a195 100644 --- a/neutron/agent/linux/ovs_lib.py +++ b/neutron/agent/linux/ovs_lib.py @@ -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) diff --git a/neutron/tests/unit/openvswitch/test_ovs_lib.py b/neutron/tests/unit/openvswitch/test_ovs_lib.py index 1b9486aff..d0c8f3362 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_lib.py +++ b/neutron/tests/unit/openvswitch/test_ovs_lib.py @@ -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):