Bug 173475 - [tun] tun(4) stays opened by PID after process is terminated
Summary: [tun] tun(4) stays opened by PID after process is terminated
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-08 15:30 UTC by Ralf Wenk
Modified: 2018-01-03 05:13 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Wenk 2012-11-08 15:30:01 UTC
After the first use of a tun interface with vpnc I am unable to reuse it,
getting the error message "Failed to bind to 0.0.0.0:500: Address already in use".

netstat shows the connection as active:
# netstat -anf inet
Active Internet connections (including servers)
Proto Recv-Q Send-Q Local Address          Foreign Address        (state)
udp4       0      0 193.196.65.251.500     193.196.64.233.500     

ifconfig tun0 and tun1 showed tun0 is still opened by the PID of the vpnc-process:
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1412
        options=80000<LINKSTATE>
        inet 192.168.120.10 --> 192.168.120.10 netmask 0xffffffff 
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        Opened by PID 1469
tun1: flags=8010<POINTOPOINT,MULTICAST> metric 0 mtu 1500
        options=80000<LINKSTATE>
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

but the process has been terminated:

# ps ax | grep 1469
1916  3  S+    0:00.01 grep 1469

This could be a regession because I was using vpnc on FreeBSD 8 without such
a problem.

How-To-Repeat: Generate the tun-interfaces by starting vpnc. Then terminate vpnc and try to
restart vpnc. The address is and stays in use.
If there was network traffic over the VPN tunnel when the vpnc-process terminates
netstat shows Send-Q is not zero and that stays till the next reboot as well.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-11-08 23:43:39 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 2 Emanuel Haupt freebsd_committer freebsd_triage 2013-01-23 06:59:07 UTC
Could you please try the following vpnc patch? It tries to work around
this deadlock situation:

http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/175067

However, the underlying problem with if_tun should be looked at
separately in this PR.

Emanuel
Comment 3 Ralf Wenk 2013-02-12 11:27:12 UTC
> Could you please try the following vpnc patch? It tries to work around
> this deadlock situation:
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/175067
> 
> However, the underlying problem with if_tun should be looked at
> separately in this PR.
> 
> Emanuel

Tried today with a newer (r245247) kernel than at the date of the bug report.

Without the patch the behavior was as described.
With the patch repeated use of vpnc, vpnc-disconnect works again. So this
patch is a sufficient workaround.

Ralf
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:50 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped