Browse Source

Merge "Check SG members instead of ports to skip flow update" into stable/stein

changes/48/708748/2
Zuul 2 years ago committed by Gerrit Code Review
parent
commit
024b1a7d66
  1. 2
      neutron/agent/linux/openvswitch_firewall/firewall.py
  2. 19
      neutron/tests/unit/agent/linux/openvswitch_firewall/test_firewall.py
  3. 8
      releasenotes/notes/fix-remote-security-group-no-port-on-host-9177e66d4b16e90c.yaml

2
neutron/agent/linux/openvswitch_firewall/firewall.py

@ -294,7 +294,7 @@ class ConjIPFlowManager(object):
addr_to_conj = collections.defaultdict(list)
for remote_id, conj_id_set in sg_conj_id_map.items():
remote_group = self.driver.sg_port_map.get_sg(remote_id)
if not remote_group or not remote_group.ports:
if not remote_group or not remote_group.members:
LOG.debug('No member for SG %s', remote_id)
continue
for addr in remote_group.get_ethertype_filtered_addresses(

19
neutron/tests/unit/agent/linux/openvswitch_firewall/test_firewall.py

@ -302,9 +302,9 @@ class TestConjIPFlowManager(base.BaseTestCase):
self.vlan_tag = 100
self.conj_id = 16
def test_update_flows_for_vlan_no_ports(self):
def test_update_flows_for_vlan_no_members(self):
remote_group = self.driver.sg_port_map.get_sg.return_value
remote_group.ports = {}
remote_group.members = {}
with mock.patch.object(self.manager.conj_id_map,
'get_conj_id') as get_conj_id_mock:
get_conj_id_mock.return_value = self.conj_id
@ -314,6 +314,21 @@ class TestConjIPFlowManager(base.BaseTestCase):
self.assertFalse(remote_group.get_ethertype_filtered_addresses.called)
self.assertFalse(self.driver._add_flow.called)
def test_update_flows_for_vlan_no_ports_but_members(self):
remote_group = self.driver.sg_port_map.get_sg.return_value
remote_group.ports = set()
remote_group.members = {constants.IPv4: ['10.22.3.4']}
remote_group.get_ethertype_filtered_addresses.return_value = [
'10.22.3.4']
with mock.patch.object(self.manager.conj_id_map,
'get_conj_id') as get_conj_id_mock:
get_conj_id_mock.return_value = self.conj_id
self.manager.add(self.vlan_tag, 'sg', 'remote_id',
constants.INGRESS_DIRECTION, constants.IPv4, 0)
self.manager.update_flows_for_vlan(self.vlan_tag)
self.assertTrue(remote_group.get_ethertype_filtered_addresses.called)
self.assertTrue(self.driver._add_flow.called)
def test_update_flows_for_vlan(self):
remote_group = self.driver.sg_port_map.get_sg.return_value
remote_group.get_ethertype_filtered_addresses.return_value = [

8
releasenotes/notes/fix-remote-security-group-no-port-on-host-9177e66d4b16e90c.yaml

@ -0,0 +1,8 @@
---
fixes:
- |
Fixes an issue that the OVS firewall driver does not configure security
group rules using remote group properly when a corresponding remote group
has no port on a local hypervisor. For more information
see bugs: `1862703 <https://bugs.launchpad.net/neutron/+bug/1862703>`_
and `1854131 <https://bugs.launchpad.net/neutron/+bug/1854131>`__.
Loading…
Cancel
Save