c76164c058
The regular IPTablesFirewall needs zones to support safely clearly conntrack entries. In order to support the single bridge use case, the conntrack manager had to be refactored slightly to allow zones to be either unique to ports or unique to networks. Since all ports in a network share a bridge in the IPTablesDriver use case, a zone per port cannot be used since there is no way to distinguish which zone traffic should be checked against when traffic enters the bridge from outside the system. A zone per network is adequate for the single bridge per network solution since it implicitly does not suffer from the double-bridge cross in a single network that led to per port usage in OVS.[1] This had to adjust the functional firewall tests to use the correct bridge name now that it's relevant in the non hybrid IPTables case. 1. Ibe9e49653b2a280ea72cb95c2da64cd94c7739da Closes-Bug: #1668958 Closes-Bug: #1657260 Change-Id: Ie88237d3fe4807b712a7ec61eb932748c38952cc
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import mock
|
|
|
|
from neutron.agent.linux import ip_conntrack
|
|
from neutron.tests import base
|
|
|
|
|
|
class IPConntrackTestCase(base.BaseTestCase):
|
|
|
|
def setUp(self):
|
|
super(IPConntrackTestCase, self).setUp()
|
|
self.execute = mock.Mock()
|
|
self.filtered_port = {}
|
|
self.unfiltered_port = {}
|
|
self.mgr = ip_conntrack.IpConntrackManager(
|
|
self._get_rule_for_table, self.filtered_port,
|
|
self.unfiltered_port, self.execute,
|
|
zone_per_port=True)
|
|
|
|
def _get_rule_for_table(self, table):
|
|
return ['test --physdev-in tapdevice -j CT --zone 100']
|
|
|
|
def test_delete_conntrack_state_dedupes(self):
|
|
rule = {'ethertype': 'IPv4', 'direction': 'ingress'}
|
|
dev_info = {'device': 'tapdevice', 'fixed_ips': ['1.2.3.4']}
|
|
dev_info_list = [dev_info for _ in range(10)]
|
|
self.mgr._delete_conntrack_state(dev_info_list, rule)
|
|
self.assertEqual(1, len(self.execute.mock_calls))
|