[libvirt] [PATCHv2] network: truncate bridges' dummy tap device names to IFNAMSIZ (15) chars

Eric Blake eblake at redhat.com
Thu Apr 14 19:19:15 UTC 2011


On 04/14/2011 01:06 PM, Laine Stump wrote:
> 
> (Change from V1 - define a static char[] containing the desired
> prefix, and use its size to figure out how much to truncate, rather
> than having a bunch of magic numbers. This also makes it simpler and
> less error-prone to change the suffix if we decide to.)

Indeed :)

> The solution is to shorten the part of the original name used to
> generate the tap device name. However, simply truncating it is
> insufficient, because the last few characters of an interface name are
> often a number used to indicate one of a list of several similar
> devices (for example, "verylongname123", "verylongname124", etc) and
> simple truncation would lead to duplicate names (eg "verlongnam-nic"
> and "verylongnam-nic"). So instead we take the first 8 characters of
> $bridgename ("verylong" in the example), add on the final 3 bytes
> ("123"), then add "-nic" (so "verylong123-nic").  Not pretty, but it
> is much more likely to generate a unique name, and is reproducible
> (unlike, say, a random number).
> ---
>  src/network/bridge_driver.c |   16 +++++++++++++++-
>  1 files changed, 15 insertions(+), 1 deletions(-)

Here's making my IRC review official:

ACK.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110414/40c881c2/attachment-0001.sig>


More information about the libvir-list mailing list