Linux bridge agent "get_bridge_for_tap_device" can be optimized

Bug #1508789 reported by Lan Qi song
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
Cedric Brandily

Bug Description

Currently, when lb agent need to get bridge for a tap device, it will iterate all the bridges and all the tap devices on each bridge to check which bridge the tap device bound to . It takes too much time. code:

https://github.com/openstack/neutron/blob/master/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py#L210-L217

One better way should to check it from tap device itself. If tap device bound to a bridge, there should has a link named "master" from bridge folder to tap folder "/sys/class/net/tapxxx". So we can check the BRIDGEFS to get the related bridge.

One prototype of this change:

    def get_bridge_for_tap_device(self, tap_device_name):
        tap_master = BRIDGE_FS + tap_device_name + '/master'
        if os.path.islink(tap_master)
            return os.readlink(tap_master).split('/')[1]

tags: added: linuxbridge loadimpact
Revision history for this message
Cedric Brandily (cbrandily) wrote :

BRIDGE_FS is already used in lb agent, why not using it more :)

Changed in neutron:
assignee: nobody → Cedric Brandily (cbrandily)
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/239301

Changed in neutron:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/239301
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=75c881a748941bc6637f3eb10dd5828f32ec6830
Submitter: Jenkins
Branch: master

commit 75c881a748941bc6637f3eb10dd5828f32ec6830
Author: Cedric Brandily <email address hidden>
Date: Mon Oct 26 09:50:20 2015 +0900

    Optimize get_bridge_for_tap_device

    Currently get_bridge_for_tap_device[1] iterates over all neutron bridges
    and their interfaces.

    This change proposes to deduce interface bridge from:

     /sys/class/net/%(interface)s/brif/bridge

    which is a symlink to bridge interface path to improve performance.

    [1] neutron.plugins.ml2.drivers.linuxbridge.agent.linuxbridge_neutron_agent

    Closes-Bug: #1508789
    Change-Id: Ia40cd81f47ff082a90d17f58514942ec50553241

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/liberty)

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/241233

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/liberty)

Reviewed: https://review.openstack.org/241233
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=af90ec7dbdb3d32ea9fdd9f93e4838bb9b1d70c1
Submitter: Jenkins
Branch: stable/liberty

commit af90ec7dbdb3d32ea9fdd9f93e4838bb9b1d70c1
Author: Cedric Brandily <email address hidden>
Date: Mon Oct 26 09:50:20 2015 +0900

    Optimize get_bridge_for_tap_device

    Currently get_bridge_for_tap_device[1] iterates over all neutron bridges
    and their interfaces.

    This change proposes to deduce interface bridge from:

     /sys/class/net/%(interface)s/brif/bridge

    which is a symlink to bridge interface path to improve performance.

    [1] neutron.plugins.ml2.drivers.linuxbridge.agent.linuxbridge_neutron_agent

    Closes-Bug: #1508789
    Change-Id: Ia40cd81f47ff082a90d17f58514942ec50553241
    (cherry picked from commit 75c881a748941bc6637f3eb10dd5828f32ec6830)
    Conflicts:
     neutron/tests/functional/agent/test_l2_lb_agent.py

tags: added: in-stable-liberty
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/neutron 8.0.0.0b1

This issue was fixed in the openstack/neutron 8.0.0.0b1 development milestone.

Changed in neutron:
status: Fix Committed → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/neutron 7.0.1

This issue was fixed in the openstack/neutron 7.0.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.