Bug 240539 - tuntap: Getting "ifconfig: ioctl SIOCSIFNAME (set name): File exists" from `ifconfig tap create name tap0`
Summary: tuntap: Getting "ifconfig: ioctl SIOCSIFNAME (set name): File exists" from `i...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Kyle Evans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-12 14:36 UTC by Mateusz Piotrowski
Modified: 2019-09-21 01:41 UTC (History)
2 users (show)

See Also:
kevans: mfc-stable12+
kevans: mfc-stable11+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Piotrowski freebsd_committer freebsd_triage 2019-09-12 14:36:07 UTC
Here's a sample shell session:

> # ifconfig | grep tap0
> # ifconfig tap create name tap0
> ifconfig: ioctl SIOCSIFNAME (set name): File exists
> tap0
> # ifconfig | grep tap0
> tap0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500

FWIW, I am getting unexpected system hangs requiring hard reset when I'm destroying tap devices.

I am running FreeBSD 13.0-CURRENT r351819 GENERIC amd64.
Comment 1 Yuri Pankov freebsd_committer freebsd_triage 2019-09-12 14:42:20 UTC
It makes some sense, actually.  If you don't have any tap devices, `ifconfig tap create name tap0` would first create 'tap0', and then try to rename it to 'tap0' (which, of course, already exists at that time).  There could be a check if original and new name are the same, I guess.  Also, you could just create it as `ifconfig tap0 create`.
Comment 2 Kyle Evans freebsd_committer freebsd_triage 2019-09-12 15:06:03 UTC
I've thrown up a review to just let the rename succeed if the name isn't changing, because I think EEXIST is perhaps misleading: https://reviews.freebsd.org/D21618

For the "system hang" -- is it just the destroy command that's hanging? Double check that `ifconfig tap0` doesn't claim "Opened by PID ...", as the controlling process needs to properly release (close) the tun/tap device before the interface can be destroyed.
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-09-12 15:37:10 UTC
A commit references this bug:

Author: kevans
Date: Thu Sep 12 15:36:49 UTC 2019
New revision: 352246
URL: https://svnweb.freebsd.org/changeset/base/352246

Log:
  SIOCSIFNAME: Do nothing if we're not actually changing

  Instead of throwing EEXIST, just succeed if the name isn't actually
  changing. We don't need to trigger departure or any of that because there's
  no change from consumers' perspective.

  PR:		240539
  Reviewed by:	brooks
  MFC after:	5 days
  Differential Revision:	https://reviews.freebsd.org/D21618

Changes:
  head/sys/net/if.c
Comment 4 Kyle Evans freebsd_committer freebsd_triage 2019-09-12 15:52:46 UTC
Take, add net@ to CC; will MFC to stable/11 and stable/12 in ~1 week
Comment 5 Mateusz Piotrowski freebsd_committer freebsd_triage 2019-09-12 15:54:08 UTC
(In reply to Kyle Evans from comment #2)

I'll keep an eye on the destroying part. I'll open a separate PR if discover something.
Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2019-09-15 02:30:13 UTC
^Triage: Remain in progress until MFC's complete (please reference PR:'s in commit message)
Comment 7 commit-hook freebsd_committer freebsd_triage 2019-09-20 21:28:44 UTC
A commit references this bug:

Author: kevans
Date: Fri Sep 20 21:27:42 UTC 2019
New revision: 352565
URL: https://svnweb.freebsd.org/changeset/base/352565

Log:
  MFC r352246: SIOCSIFNAME: Do nothing if we're not actually changing

  Instead of throwing EEXIST, just succeed if the name isn't actually
  changing. We don't need to trigger departure or any of that because there's
  no change from consumers' perspective.

  PR:		240539

Changes:
_U  stable/11/
  stable/11/sys/net/if.c
_U  stable/12/
  stable/12/sys/net/if.c
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-09-21 01:40:06 UTC
A commit references this bug:

Author: kevans
Date: Sat Sep 21 01:39:50 UTC 2019
New revision: 352571
URL: https://svnweb.freebsd.org/changeset/base/352571

Log:
  MFS r352565: SIOCSIFNAME: Do nothing if we're not actually changing

  Instead of throwing EEXIST, just succeed if the name isn't actually
  changing. We don't need to trigger departure or any of that because there's
  no change from consumers' perspective.

  PR:		240539
  Approved by:	re (gjb)

Changes:
_U  releng/12.1/
  releng/12.1/sys/net/if.c
Comment 9 Kyle Evans freebsd_committer freebsd_triage 2019-09-21 01:41:03 UTC
Merged to stable and releng/12.1. Thanks for the report!