From nobody@FreeBSD.org  Wed Apr 12 20:39:23 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2D25C16A402
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 12 Apr 2006 20:39:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0DE0A43D6D
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 12 Apr 2006 20:39:17 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k3CKdGw0039456
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 12 Apr 2006 20:39:16 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k3CKdG70039442;
	Wed, 12 Apr 2006 20:39:16 GMT
	(envelope-from nobody)
Message-Id: <200604122039.k3CKdG70039442@www.freebsd.org>
Date: Wed, 12 Apr 2006 20:39:16 GMT
From: Johan Bolmsj <johan@nocrew.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: "ping: sendto: No buffer space available" with TUN interface (easily reproducable with test program)
X-Send-Pr-Version: www-2.3

>Number:         95665
>Category:       kern
>Synopsis:       [if_tun] "ping: sendto: No buffer space available" with TUN interface (easily reproducable with test program)
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-net
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 12 20:40:13 GMT 2006
>Closed-Date:    Sat Mar 08 20:27:23 UTC 2008
>Last-Modified:  Sat Mar 08 20:27:23 UTC 2008
>Originator:     Johan Bolmsj
>Release:        FreeBSD 6.0-RELEASE
>Organization:
>Environment:
FreeBSD matilda.nocrew.org 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Sat Mar 18 15:18:13 CET 2006     root@matilda.nocrew.org:/usr/obj/usr/src/sys/SMP  i386
>Description:
I was playing a little with the TUN device under FreeBSD. I wanted to test the
performance of the driver so I wrote a small ICMP echo reply server using the
TUN device. When I ping flood this interface with a large amount of 1k byte
packets the interface is "hung".

Pinging the interface shows the dreaded "ping: sendto: No buffer space
available" message.

Pinging the interface from another PC on the LAN shows no problems what
so ever. It seems that the sheer amount of traffic doing this localy is
causing this problem. No successfull flood ping rounds have shown any
dropped ping requests. What buffer space is out? This certainly looks like
a bug to me.

I have a 200 line test program to reproduce this very easily. At the start
of the test program there are detailed instructions on how to setup this test.

You can find it at:
http://six.nocrew.org/tmp/tun_icmp_echo_reply.c

>How-To-Repeat:
Run this test program:
http://six.nocrew.org/tmp/tun_icmp_echo_reply.c

There are detailed instructions at the top of the file on how to reproduce
the problem.

>Fix:

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Wed Apr 19 10:47:54 UTC 2006 
Responsible-Changed-Why:  
I'll give a try on this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95665 
Responsible-Changed-From-To: glebius->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Mon Sep 25 20:09:02 UTC 2006 
Responsible-Changed-Why:  
I'll take this 

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

From: Bruce M Simpson <bms@incunabulum.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/95665: [if_tun] "ping: sendto: No buffer space available"
 with TUN interface (easily reproducable with test program)
Date: Tue, 26 Sep 2006 23:13:01 +0100

 I attempted to reproduce this in 7-CURRENT and cannot; both the local 
 and remote pings transiting the tun interface (with the test program 
 listening at the other end) complete successfully with 100% packets 
 transmitted and received.

From: Bruce M Simpson <bms@incunabulum.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/95665: [if_tun] "ping: sendto: No buffer space available"
 with TUN interface (easily reproducable with test program)
Date: Tue, 26 Sep 2006 23:15:42 +0100

 I can't reproduce this locally on 6.1-RELEASE.
State-Changed-From-To: open->feedback 
State-Changed-By: bms 
State-Changed-When: Wed Sep 27 10:09:07 UTC 2006 
State-Changed-Why:  
I can't reproduce this on 7-CURRENT or 6.1-RELEASE with the sploit 
provided. can you try? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95665 
State-Changed-From-To: feedback->suspended 
State-Changed-By: bms 
State-Changed-When: Wed Sep 27 21:56:02 UTC 2006 
State-Changed-Why:  
Back to the free pool (can't reproduce) 


Responsible-Changed-From-To: bms->net 
Responsible-Changed-By: bms 
Responsible-Changed-When: Wed Sep 27 21:56:02 UTC 2006 
Responsible-Changed-Why:  
Back to the free pool (can't reproduce) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95665 
Responsible-Changed-From-To: net->freebsd-net 
Responsible-Changed-By: jmg 
Responsible-Changed-When: Mon Oct 2 23:14:29 UTC 2006 
Responsible-Changed-Why:  
move w/ the others... 

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

From: Astrodog <astrodog@gmail.com>
To: bug-followup@FreeBSD.org, johan@nocrew.org
Cc:  
Subject: Re: kern/95665: [if_tun] "ping: sendto: No buffer space available" with TUN interface (easily reproducable with test program)
Date: Sun, 8 Oct 2006 00:22:20 -0500

 I can reproduce this problem with some ease.
 
 It occurs when the buffer for tun0 fills up, because the NIC is unable
 to send the packets as quickly as the program is generating them.
 
 This is fairly common on slow or dodgy NICs, when combined with tun/gif/etc.
 
 There is not a real fix, because the outgoing NIC used by tun can
 change, so any attempt to make it aware of the buffer, and throttle
 accordingly would be painfully hacked together.
 
 To confirm that this is actually the issue, increase the size of the
 buffer. You should see a larger number of packets make it through.
State-Changed-From-To: suspended->closed 
State-Changed-By: rwatson 
State-Changed-When: Sat Mar 8 20:24:15 UTC 2008 
State-Changed-Why:  
Closing the PR as it appears that any bug in if_tun queue handling has now 
been resolved.  If you are still able to reproduce a *permanent* hang in 
processing of if_tun under load, please let us know; temporarily returning 
ENOBUFS when things get full due to the user process falling behind is 
expected.  Note that some other operating systems return success rather 
than ENOBUFS for datagram send to an interface with a full send queue, so 
if you see ENOBUFS only on FreeBSD (and not, say, Linux), this doesn't 
mean it's a bug.  If you reply with further information confirming a 
problem on a recent (FreeBSD 6.3, 7.0) version, I can re-open the PR and 
investigate further.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95665 
>Unformatted:
