Merge "Ignore IPv6 link local addresses"

This commit is contained in:
Zuul 2017-11-21 16:55:26 +00:00 committed by Gerrit Code Review
commit 831576c906
3 changed files with 21 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import threading
import time
from wsgiref import simple_server
import netaddr
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log
@ -214,7 +215,12 @@ class IronicPythonAgent(base.ExecuteCommandMixin):
return
try:
return out.strip().split('\n')[0].split('src')[1].split()[0]
source = out.strip().split('\n')[0].split('src')[1].split()[0]
if netaddr.IPAddress(source).is_link_local():
LOG.info('Ignoring link-local source to %(dest)s: %(rec)s',
{'dest': dest, 'rec': out})
return
return source
except IndexError:
LOG.warning('No route to host %(dest)s, route record: %(rec)s',
{'dest': dest, 'rec': out})

View File

@ -504,6 +504,14 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest):
source = self.agent._get_route_source('XXX')
self.assertEqual('1:2::3:4', source)
@mock.patch.object(utils, 'execute', autospec=True)
def test_get_route_source_ipv6_linklocal(self, mock_execute):
mock_execute.return_value = (
'XXX src fe80::1234:1234:1234:1234 metric XXX\n cache', None)
source = self.agent._get_route_source('XXX')
self.assertIsNone(source)
@mock.patch.object(agent, 'LOG', autospec=True)
@mock.patch.object(utils, 'execute', autospec=True)
def test_get_route_source_indexerror(self, mock_execute, mock_log):

View File

@ -0,0 +1,6 @@
---
fixes:
- Fixes the issue where link-local IP addresses were sometimes used as part
of the callback URL given to ironic. The routable address is used instead.
See `bug 1732692 <https://bugs.launchpad.net/ironic-python-agent/+bug/1732692>`_
for more details.