2001-10-21 16:09:22

by Guus Sliepen

[permalink] [raw]
Subject: [PATCH] [RFC] dev_alloc_name() requirement of %d and the 100 names limit

Hello,

Somewhere between 2.4.10 and 2.4.12 the dev_alloc_name() function was
changed to explicitly check for a %d in the name of a to-be allocated
network interface. The idea is that this function returns a unique name
or bails out.

The recent change broke at least tinc (a userspace VPN daemon), because
it tries to alloc a tun/tap device and gives it a name, but does not require
that the %d must be present (the documentation of the tun/tap driver nor
the example code in Documentation/ make any mention of that). I don't
see why the %d would have to be mandatory, so the attached patch allows
device names without a %d to work as well.

A comment in that function says that if anyone would need more than 100
devices the algorithm should be fixed. The patch does this, allowing a
virtually unlimitted amount of names, in O(log(n)) time, n being the
number of already allocated names.

I stresstested the patched, I was able to allocate 1901 network devices
using "test%d" as the name. After that my system claimed it didn't have
any file descriptors left.

--
Met vriendelijke groet / with kind regards,
Guus Sliepen <[email protected]>


Attachments:
(No filename) (0.00 B)
(No filename) (232.00 B)
Download all attachments