Fix generation of thousands of DHCP tap interfaces

As reported in the bug, there may be an case where an empty
namespace file in /run/netns, but the namespace not
actually exist. In such case the DHCP agent throws an error
when pluging the interface in the dhcp namespace.
This may also result in many tap interfaces
getting generated in OVS bridge or Linux bridge.

This patch fixes the above bug by unpluging the tap device
in the bridge if exception occurs, this can prevents the tap
interfaces generate.

Co-Authored-By: Brian Haley <bhaley@redhat.com>

Change-Id: I4a197edd180887ad36317ddb2f0c0e7bd2e34e30
Closes-Bug: #1561695
This commit is contained in:
Dongcan Ye 2017-07-11 15:15:23 +08:00 committed by Dongcan Ye
parent a51271d760
commit 38d058c2cf
2 changed files with 4 additions and 0 deletions

View File

@ -1422,6 +1422,8 @@ class DeviceManager(object):
LOG.exception(_LE('Unable to plug DHCP port for '
'network %s. Releasing port.'),
network.id)
# We should unplug the interface in bridge side.
self.unplug(interface_name, network)
self.plugin.release_dhcp_port(network.id, port.device_id)
self.fill_dhcp_udp_checksums(namespace=network.namespace)

View File

@ -1571,6 +1571,8 @@ class TestDeviceManager(base.BaseTestCase):
dh.driver.plug.side_effect = OSError()
net = copy.deepcopy(fake_network)
self.assertRaises(OSError, dh.setup, net)
dh.driver.unplug.assert_called_once_with(mock.ANY,
namespace=net.namespace)
plugin.release_dhcp_port.assert_called_once_with(
net.id, mock.ANY)