Wrong use of ">" to try to redirect output in _enable_hairpin

Bug #943316 reported by Thierry Carrez
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Vish Ishaya

Bug Description

nova/virt/libvirt/connection.py shows in _enable_hairpin function:

utils.execute('tee',
                         '/sys/class/net/%s/brport/hairpin_mode' % interface,
                         '>',
                         '/dev/null',
                         process_input='1',
                         run_as_root=True,
                         check_exit_code=[0, 1])

This doesn't do what the author thinks it would do, since ">" is not interpreted as a redirection. It will actually copy stdin to 3 different locations. Luckily, this code probably works, though.

Revision history for this message
Evan Callicoat (diopter) wrote :

Good catch. I'm the author of this code and I was under the impression that utils.execute implied shell=True in the internal subprocess.popen call, but I see in utils.py that it assumes shell=False unless you specify a value, same as the popen default. I'll update my patch branch and either set shell=True or modify the code to use (sudo) sh -c "echo 1 > ..." instead of having tee's stdout to worry about in the first place.

It turns out that the code does indeed work just fine, enabling hairpin_mode on bridge ports successfully, but I'd definitely rather have it do so minus the cruft I stuffed in here.

Evan Callicoat (diopter)
Changed in nova:
assignee: nobody → Evan Callicoat (diopter)
Revision history for this message
Vish Ishaya (vishvananda) wrote : Re: [Bug 943316] Re: Wrong use of ">" to try to redirect output in _enable_hairpin

I would just remove the redirect via > the output will go to an internal pipe and be discarded.

Revision history for this message
Thierry Carrez (ttx) wrote :

Yes, suppressing the redirection is the right (and simple) way to fix this.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
assignee: Evan Callicoat (diopter) → Vish Ishaya (vishvananda)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/5425
Committed: http://github.com/openstack/nova/commit/0b89a35f25b62537457a3d327d1b5ac3e1fad056
Submitter: Jenkins
Branch: master

commit 0b89a35f25b62537457a3d327d1b5ac3e1fad056
Author: Vishvananda Ishaya <email address hidden>
Date: Thu Mar 15 15:50:12 2012 -0700

    Remove improper use of redirect for hairpin mode

     * Fixes bug 943316

    Change-Id: I7fb5ffa812f7474613500bd7d9f141f83ad70614

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → essex-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: essex-rc1 → 2012.1
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.