Should not add metadata filter rules if disable metadata proxy
The metadata filter rules should not be added into iptables if Neutron metadata proxy is disabled. This patchset fixes this issue by adding a condition when adding metadata filter rules to iptables. Closes-Bug #1224290 Change-Id: I7f14d281c31c1828a90abac8821635773238b2d0
This commit is contained in:
parent
0e4dd8c7d0
commit
ec1c6c98a6
@ -544,6 +544,7 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
|
|||||||
|
|
||||||
def metadata_filter_rules(self):
|
def metadata_filter_rules(self):
|
||||||
rules = []
|
rules = []
|
||||||
|
if self.conf.enable_metadata_proxy:
|
||||||
rules.append(('INPUT', '-s 0.0.0.0/0 -d 127.0.0.1 '
|
rules.append(('INPUT', '-s 0.0.0.0/0 -d 127.0.0.1 '
|
||||||
'-p tcp -m tcp --dport %s '
|
'-p tcp -m tcp --dport %s '
|
||||||
'-j ACCEPT' % self.conf.metadata_port))
|
'-j ACCEPT' % self.conf.metadata_port))
|
||||||
|
@ -672,6 +672,18 @@ class TestBasicRouterOperations(base.BaseTestCase):
|
|||||||
msg = "Error importing interface driver 'wrong_driver'"
|
msg = "Error importing interface driver 'wrong_driver'"
|
||||||
log.error.assert_called_once_with(msg)
|
log.error.assert_called_once_with(msg)
|
||||||
|
|
||||||
|
def test_metadata_filter_rules(self):
|
||||||
|
self.conf.set_override('enable_metadata_proxy', False)
|
||||||
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
self.assertEqual([], agent.metadata_filter_rules())
|
||||||
|
|
||||||
|
self.conf.set_override('metadata_port', '8775')
|
||||||
|
self.conf.set_override('enable_metadata_proxy', True)
|
||||||
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
rules = ('INPUT', '-s 0.0.0.0/0 -d 127.0.0.1 '
|
||||||
|
'-p tcp -m tcp --dport 8775 -j ACCEPT')
|
||||||
|
self.assertEqual([rules], agent.metadata_filter_rules())
|
||||||
|
|
||||||
|
|
||||||
class TestL3AgentEventHandler(base.BaseTestCase):
|
class TestL3AgentEventHandler(base.BaseTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user