From 1fa38ebae0bf98567558c166c9f167f7647a1848 Mon Sep 17 00:00:00 2001 From: Thomas Bechtold Date: Mon, 9 Feb 2015 13:25:56 +0100 Subject: [PATCH] Search in /sys/class/net for network devices When using /sys/devices/net/virtual to search for tap devices, not all devices are listed there (i.e. when using Xen). Also according to the Linux kernel documentation (see ABI/testing/sysfs-devices), /sys/class should be used instead of /sys/devices. Change-Id: I9b4981332b66b6d3f9c36511c81432d3e7644bdd Closes-Bug: #1419754 (cherry picked from commit e228a3dc69eca08896c4e22d6a2d51b60a9a0a94) --- .../plugins/linuxbridge/agent/linuxbridge_neutron_agent.py | 4 +++- neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py index d9f7f686f5e..bb60db0d6ec 100755 --- a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -51,7 +51,9 @@ from neutron.plugins.linuxbridge.common import constants as lconst LOG = logging.getLogger(__name__) BRIDGE_NAME_PREFIX = "brq" -BRIDGE_FS = "/sys/devices/virtual/net/" +# NOTE(toabctl): Don't use /sys/devices/virtual/net here because not all tap +# devices are listed here (i.e. when using Xen) +BRIDGE_FS = "/sys/class/net/" BRIDGE_NAME_PLACEHOLDER = "bridge_name" BRIDGE_INTERFACES_FS = BRIDGE_FS + BRIDGE_NAME_PLACEHOLDER + "/brif/" DEVICE_NAME_PLACEHOLDER = "device_name" diff --git a/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py b/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py index 1a2bbc4d2e4..1347787dcff 100644 --- a/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py +++ b/neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py @@ -446,7 +446,7 @@ class TestLinuxBridgeManager(base.BaseTestCase): exists_fn.return_value = True self.assertTrue(self.lbm.is_device_on_bridge("tap1")) exists_fn.assert_called_with( - "/sys/devices/virtual/net/tap1/brport" + "/sys/class/net/tap1/brport" ) def test_get_interface_details(self):