All of lore.kernel.org
 help / color / mirror / Atom feed
* [iproute2] finding the name of a TAP created with %d
@ 2021-04-06 13:42 Alyssa Ross
  2021-04-06 16:22 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Alyssa Ross @ 2021-04-06 13:42 UTC (permalink / raw)
  To: netdev

[-- Attachment #1: Type: text/plain, Size: 505 bytes --]

If I do

	ip tuntap add name tap%d mode tap

then a TAP device with a name like "tap0", "tap1", etc. will be created.
But there's no way for me to find out which name was chosen for the
device created by that command.

Perhaps ip should print the name of tuntap devices after they're
created?

I'd be interested in sending a patch, but I'd need some guidance on how
exactly it should work.  Would there be any harm in always printing it?
Should it be behind a flag?  Or just when the name contains a `%'?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [iproute2] finding the name of a TAP created with %d
  2021-04-06 13:42 [iproute2] finding the name of a TAP created with %d Alyssa Ross
@ 2021-04-06 16:22 ` Stephen Hemminger
  2021-04-06 17:15   ` Alyssa Ross
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2021-04-06 16:22 UTC (permalink / raw)
  To: Alyssa Ross; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 899 bytes --]

On Tue, 6 Apr 2021 13:42:40 +0000
Alyssa Ross <hi@alyssa.is> wrote:

> If I do
> 
> 	ip tuntap add name tap%d mode tap
> 
> then a TAP device with a name like "tap0", "tap1", etc. will be created.
> But there's no way for me to find out which name was chosen for the
> device created by that command.

Use a follow on ip link show or look in sysfs.

> Perhaps ip should print the name of tuntap devices after they're
> created?

You can already do that with followon command, or use batch to put two commands together.


> I'd be interested in sending a patch, but I'd need some guidance on how
> exactly it should work.  Would there be any harm in always printing it?
> Should it be behind a flag?  Or just when the name contains a `%'?

Printing the result would make ip tuntap behave differently, which makes
it unique (snowflakes are bad) and would break users scripts.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [iproute2] finding the name of a TAP created with %d
  2021-04-06 16:22 ` Stephen Hemminger
@ 2021-04-06 17:15   ` Alyssa Ross
  0 siblings, 0 replies; 3+ messages in thread
From: Alyssa Ross @ 2021-04-06 17:15 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

On Tue, Apr 06, 2021 at 09:22:31AM -0700, Stephen Hemminger wrote:
> On Tue, 6 Apr 2021 13:42:40 +0000
> Alyssa Ross <hi@alyssa.is> wrote:
>
> > If I do
> >
> > 	ip tuntap add name tap%d mode tap
> >
> > then a TAP device with a name like "tap0", "tap1", etc. will be created.
> > But there's no way for me to find out which name was chosen for the
> > device created by that command.
>
> Use a follow on ip link show or look in sysfs.
>
> > Perhaps ip should print the name of tuntap devices after they're
> > created?
>
> You can already do that with followon command, or use batch to put two commands together.

I don't think that's reliable, is it?  What happens if I create one
device, but by the time I do ip link show another one has been created?
There's no way to know for sure that the last device was created by the
command I ran.

As I understand it, the only way to avoid a race like that for sure
would be to look at the ifr_name returned by the kernel from TUNSETIFF.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-06 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 13:42 [iproute2] finding the name of a TAP created with %d Alyssa Ross
2021-04-06 16:22 ` Stephen Hemminger
2021-04-06 17:15   ` Alyssa Ross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.