OpenStack Compute (Nova)

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

Reported by Thierry Carrez on 2012-02-29
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
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.

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) on 2012-03-12
Changed in nova:
assignee: nobody → Evan Callicoat (diopter)

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

Thierry Carrez (ttx) wrote :

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

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

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) on 2012-03-20
Changed in nova:
milestone: none → essex-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in nova:
milestone: essex-rc1 → 2012.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers