From 484dc0d0ffb420951b41a6a6b5a55a61c41a25e6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 21 Feb 2019 17:55:50 +0300 Subject: [PATCH] MacvtapManager->get_all_devices(): reducing race window there's a race window in "get_all_devices" between scanning all devices and a loop over device list requesting device mac address. Device could easily be removed and a whole process crushed. This patch doesn't remove this possibility (sort of interlocking required) but reducing it ruther well, to ~1% probability. --- .../ml2/drivers/macvtap/agent/macvtap_neutron_agent.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py index 0f2e44d..df66f4d 100644 --- a/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py @@ -134,9 +134,10 @@ class MacvtapManager(amb.CommonAgentManagerBase): self.mac_device_name_mappings = dict() for device_name in all_device_names: if device_name.startswith(constants.MACVTAP_DEVICE_PREFIX): - mac = ip_lib.get_device_mac(device_name) - self.mac_device_name_mappings[mac] = device_name - devices.add(mac) + if ip_lib.device_exists(device_name): + mac = ip_lib.get_device_mac(device_name) + self.mac_device_name_mappings[mac] = device_name + devices.add(mac) return devices def get_extension_driver_type(self): -- 2.17.1