From dan@obluda.cz Thu Jul  1 14:30:26 1999
Return-Path: <dan@obluda.cz>
Received: from dan-h.fio.cz (fio.vol.cz [195.250.146.50])
	by hub.freebsd.org (Postfix) with ESMTP id 9D71C150D5
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  1 Jul 1999 14:30:13 -0700 (PDT)
	(envelope-from dan@obluda.cz)
Received: (from root@localhost)
	by dan-h.fio.cz (8.9.3/8.9.0) id XAA44082;
	Thu, 1 Jul 1999 23:26:03 +0200 (CEST)
Message-Id: <199907012126.XAA44082@dan-h.fio.cz>
Date: Thu, 1 Jul 1999 23:26:03 +0200 (CEST)
From: Dan Lukes <dan@obluda.cz>
Reply-To: dan@obluda.cz
To: FreeBSD-gnats-submit@freebsd.org
Subject: PATCH Send ICMP_SOURCEQUENCH when packet dropped by dummynet
X-Send-Pr-Version: 3.2

>Number:         12479
>Category:       kern
>Synopsis:       PATCH Send ICMP_SOURCEQUENCH when packet dropped by dummynet
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul  1 14:40:01 PDT 1999
>Closed-Date:    Sat Jul 3 13:04:17 PDT 1999
>Last-Modified:  Sat Jul  3 13:05:37 PDT 1999
>Originator:     Dan Lukes
>Release:        FreeBSD 3.2-RELEASE i386
>Organization:
Obludarium
>Environment:

	kernel with dummynet used for bandwidth limiting

>Description:

	the dummynet drop packets silently without ICMP_SOURCEQUENCH message
Althought the sending of ICMP after dropping is optional (MAY be send)
some realtime applications (voice telephony, ...), especially UDP based has 
serious problem with flow control without it

>How-To-Repeat:

	create limited pipe (ipfw pipe ...), route traffic into it (ipfw add
pipe), create trafic ...

>Fix:
	
	Send ICMP_SOURCEQUENCH if packed droped by pipe->queue_size or
pipe->queue_size_bytes limit overflow. Don't send ICMP when packed dropped
by random packet drop as it implement random packet droping on poor lines.

*** ip_dummynet.c.ORIG	Tue May  4 18:23:57 1999
--- ip_dummynet.c	Thu Jul  1 22:33:27 1999
***************
*** 52,57 ****
--- 52,58 ----
  #include <netinet/ip_fw.h>
  #include <netinet/ip_dummynet.h>
  #include <netinet/ip_var.h>
+ #include <netinet/ip_icmp.h>
  
  #include "opt_bdg.h"
  #ifdef BRIDGE
***************
*** 292,297 ****
--- 293,299 ----
      struct dn_pkt *pkt;
      struct dn_pipe *pipe;
      int len = m->m_pkthdr.len ;
+     int drop_by_rand=0;
  
      int s=splimp();
  
***************
*** 317,323 ****
       * should i drop ?
       * This section implements random packet drop.
       */
!     if ( (pipe->plr && random() < pipe->plr) ||
           (pipe->queue_size && pipe->r_len >= pipe->queue_size) ||
           (pipe->queue_size_bytes &&
  	    len + pipe->r_len_bytes > pipe->queue_size_bytes) ||
--- 319,326 ----
       * should i drop ?
       * This section implements random packet drop.
       */
!     drop_by_rand=(pipe->plr && random() < pipe->plr);
!     if ( drop_by_rand ||
           (pipe->queue_size && pipe->r_len >= pipe->queue_size) ||
           (pipe->queue_size_bytes &&
  	    len + pipe->r_len_bytes > pipe->queue_size_bytes) ||
***************
*** 328,333 ****
--- 331,342 ----
  	    printf("-- dummynet: drop from pipe %d, have %d pks, %d bytes\n",
  		pipe_nr,  pipe->r_len, pipe->r_len_bytes);
  	pipe->r_drops++ ;
+ 	if (!drop_by_rand) {
+ 	   register struct ip *ip = mtod(m, struct ip *);
+ 	   struct mbuf *mcopy = m_copy(m, 0, imin((int)ip->ip_len, 64));
+ 
+ 	   icmp_error(mcopy, ICMP_SOURCEQUENCH, 0, 0, NULL);
+ 	}
  	m_freem(m);
  	return 0 ; /* XXX error */
      }


>Release-Note:
>Audit-Trail:

From: Bill Fenner <fenner@research.att.com>
To: dan@obluda.cz
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: kern/12479: PATCH Send ICMP_SOURCEQUENCH when packet dropped by dummynet
Date: Sat, 3 Jul 1999 09:43:55 -0700

 >Althought the sending of ICMP after dropping is optional (MAY be send)
 
 You must be reading an old RFC.  Sending an ICMP after dropping is not
 recommended (SHOULD NOT) by RFC1812, Requirements for IP Version 4 Routers
 (section 4.3.3.3).  A better patch would be one to remove sending source
 quenches from the main IP stack.
 
   Bill
 
State-Changed-From-To: open->closed 
State-Changed-By: fenner 
State-Changed-When: Sat Jul 3 13:04:17 PDT 1999 
State-Changed-Why:  
RFC1812: A router SHOULD NOT originate ICMP Source Quench messages. 
>Unformatted:
