From nobody@FreeBSD.org  Tue Feb 17 04:36:08 2004
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 3511916A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Feb 2004 04:36:08 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3125343D1D
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Feb 2004 04:36:08 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i1HCa772054113
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 17 Feb 2004 04:36:07 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i1HCa7p2054112;
	Tue, 17 Feb 2004 04:36:07 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200402171236.i1HCa7p2054112@www.freebsd.org>
Date: Tue, 17 Feb 2004 04:36:07 -0800 (PST)
From: Alexander Motin <mav@alkar.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: When created dummynet pipe on output router interface with lower MTU system stops to generate 'Fragment Needed but DF was Set' ICMP in cases when it must
X-Send-Pr-Version: www-2.3

>Number:         62957
>Category:       kern
>Synopsis:       When created dummynet pipe on output router interface with lower MTU system stops to generate 'Fragment Needed but DF was Set' ICMP in cases when it must
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    luigi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 17 04:40:20 PST 2004
>Closed-Date:    Fri Jun 18 09:32:11 GMT 2004
>Last-Modified:  Fri Jun 18 09:32:11 GMT 2004
>Originator:     Alexander Motin
>Release:        4.8 and 5.2
>Organization:
Alkar-Teleport ISP
>Environment:
FreeBSD ghsdr3-dp.alkar.net 4.8-RELEASE FreeBSD 4.8-RELEASE #2: Thu Oct  2 18:36:09 EEST 2003     povar@ghsdr3-dp.alkar.net:/usr/src/sys/compile/GHSDR2-DP  i386

FreeBSD orphanage.alkar.net 5.2-RELEASE FreeBSD 5.2-RELEASE #0: Wed Jan 14 04:41:35 EET 2004     mav@orphanage.alkar.net:/usr/obj/usr/src/sys/orphanage  i386

>Description:
When I create dummynet pipe on output router interface with lower MTU system stops to generate 'Fragment Needed but DF was Set' ICMP in cases when it must. If I create this pipe on incoming interface there is no problem. 
>How-To-Repeat:
Take router with 2 interfaces and small MTU on one of them.
Create output dummynet pipe on interface with small MTU.
Send big packet with DF flag set.
>Fix:
Check result code of ip_output() in ip_dummynet.c and send requires ICMP message.

Here is no any check of result code:
        case DN_TO_IP_OUT:                                                              
            (void)ip_output((struct mbuf *)pkt, NULL, NULL, 0, NULL, NULL);             
            rt_unref (pkt->ro.ro_rt, __func__) ;                                        
            break ;                                                                     

>Release-Note:
>Audit-Trail:

From: Alexander Motin <mav@alkar.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/62957: When created dummynet pipe on output router interface
 with lower MTU system stops to generate 'Fragment Needed but DF was Set'
 ICMP in cases when it must
Date: Mon, 23 Feb 2004 18:23:33 +0200

 This is a multi-part message in MIME format.
 --------------070208060804030100000702
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Here are my patches for this problem for 4.8 and 5.2.
 Review them please.
 
 -- 
 Alexander Motin mav@alkar.net
 ISP "Alkar-Teleport"
 
 --------------070208060804030100000702
 Content-Type: text/plain;
  name="dn_df_48.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="dn_df_48.patch"
 
 --- ip_dummynet.c.orig	Wed May 28 01:36:02 2003
 +++ ip_dummynet.c	Sat Feb 21 12:49:11 2004
 @@ -81,6 +81,7 @@
  #include <netinet/ip_fw.h>
  #include <netinet/ip_dummynet.h>
  #include <netinet/ip_var.h>
 +#include <netinet/ip_icmp.h>
  
  #include <netinet/if_ether.h> /* for struct arpcom */
  #include <net/bridge.h>
 @@ -407,6 +408,9 @@
  transmit_event(struct dn_pipe *pipe)
  {
      struct dn_pkt *pkt ;
 +    struct mbuf *mcopy;
 +    struct ip *ip;
 +    int error, type, code;
  
      while ( (pkt = pipe->head) && DN_KEY_LEQ(pkt->output_time, curr_time) ) {
  	/*
 @@ -426,7 +430,39 @@
  	 */
  	switch (pkt->dn_dir) {
  	case DN_TO_IP_OUT:
 -	    (void)ip_output((struct mbuf *)pkt, NULL, NULL, 0, NULL, NULL);
 +	    MGET(mcopy, M_DONTWAIT, pkt->dn_m->m_type);
 +	    if (mcopy != NULL && !m_dup_pkthdr(mcopy, pkt->dn_m, M_DONTWAIT)) {
 +		m_free(mcopy);
 +		mcopy = NULL;
 +	    }
 +	    if (mcopy != NULL) {
 +		ip = mtod(pkt->dn_m, struct ip *);
 +		mcopy->m_len = imin((ip->ip_hl << 2) + 8,
 +		    (int)ip->ip_len);
 +		m_copydata(pkt->dn_m, 0, mcopy->m_len, mtod(mcopy, caddr_t));
 +	    }
 +	    
 +	    error = ip_output((struct mbuf *)pkt, NULL, NULL, 0, NULL, NULL);
 +	    
 +	    if (mcopy != NULL) {
 +		switch (error) {
 +		    case ENETUNREACH:
 +		    case EHOSTUNREACH:
 +		    case ENETDOWN:
 +		    case EHOSTDOWN:
 +			type = ICMP_UNREACH;
 +		        code = ICMP_UNREACH_HOST;
 +			icmp_error(mcopy, type, code, 0, pkt->ifp);
 +			break;
 +		    case EMSGSIZE:
 +			type = ICMP_UNREACH;
 +		        code = ICMP_UNREACH_NEEDFRAG;
 +			icmp_error(mcopy, type, code, 0, pkt->ifp);
 +			break;
 +		    default:
 +			m_freem(mcopy);
 +		};
 +	    };
  	    rt_unref (pkt->ro.ro_rt) ;
  	    break ;
  
 
 --------------070208060804030100000702
 Content-Type: text/plain;
  name="dn_df_52.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="dn_df_52.patch"
 
 --- ip_dummynet.c.orig	Mon Dec  8 11:50:54 2003
 +++ ip_dummynet.c	Sat Feb 21 12:17:44 2004
 @@ -73,6 +73,7 @@
  #include <netinet/ip_fw.h>
  #include <netinet/ip_dummynet.h>
  #include <netinet/ip_var.h>
 +#include <netinet/ip_icmp.h>
  
  #include <netinet/if_ether.h> /* for struct arpcom */
  #include <net/bridge.h>
 @@ -426,6 +427,9 @@
  transmit_event(struct dn_pipe *pipe)
  {
      struct dn_pkt *pkt ;
 +    struct mbuf *mcopy;
 +    struct ip *ip;
 +    int error, type, code;
  
      DUMMYNET_LOCK_ASSERT();
  
 @@ -449,7 +453,39 @@
  	 */
  	switch (pkt->dn_dir) {
  	case DN_TO_IP_OUT:
 -	    (void)ip_output((struct mbuf *)pkt, NULL, NULL, 0, NULL, NULL);
 +	    MGET(mcopy, M_DONTWAIT, pkt->dn_m->m_type);
 +	    if (mcopy != NULL && !m_dup_pkthdr(mcopy, pkt->dn_m, M_DONTWAIT)) {
 +		m_free(mcopy);
 +		mcopy = NULL;
 +	    }
 +	    if (mcopy != NULL) {
 +		ip = mtod(pkt->dn_m, struct ip *);
 +		mcopy->m_len = imin((ip->ip_hl << 2) + 8,
 +		    (int)ip->ip_len);
 +		m_copydata(pkt->dn_m, 0, mcopy->m_len, mtod(mcopy, caddr_t));
 +	    }
 +	    
 +	    error = ip_output((struct mbuf *)pkt, NULL, NULL, 0, NULL, NULL);
 +	    
 +	    if (mcopy != NULL) {
 +		switch (error) {
 +		    case ENETUNREACH:
 +		    case EHOSTUNREACH:
 +		    case ENETDOWN:
 +		    case EHOSTDOWN:
 +			type = ICMP_UNREACH;
 +		        code = ICMP_UNREACH_HOST;
 +			icmp_error(mcopy, type, code, 0, pkt->ifp);
 +			break;
 +		    case EMSGSIZE:
 +			type = ICMP_UNREACH;
 +		        code = ICMP_UNREACH_NEEDFRAG;
 +			icmp_error(mcopy, type, code, 0, pkt->ifp);
 +			break;
 +		    default:
 +			m_freem(mcopy);
 +		};
 +	    };
  	    rt_unref (pkt->ro.ro_rt, __func__) ;
  	    break ;
  
 
 --------------070208060804030100000702--

From: Rob Wise <rob@ugh.net.au>
To: freebsd-gnats-submit@FreeBSD.org, mav@alkar.net
Cc:  
Subject: Re: kern/62957: When created dummynet pipe on output router interface
 with lower MTU system stops to generate 'Fragment Needed but DF was Set'
 ICMP in cases when it must
Date: Mon, 17 May 2004 20:45:47 +1000 (EST)

 Not much activity in the PR, so I just wanted to add this patch applied
 cleanly and works as expected on my 4-STABLE system with the most recent
 ip_dummynet.c from CVS.
 
 src/sys/netinet/ip_dummynet.c,v 1.24.2.26 2003/12/30 12:28:09
Responsible-Changed-From-To: freebsd-bugs->luigi 
Responsible-Changed-By: bms 
Responsible-Changed-When: Fri Jun 18 02:07:14 GMT 2004 
Responsible-Changed-Why:  
Luigi is Mr. Dummynet 

http://www.freebsd.org/cgi/query-pr.cgi?pr=62957 
State-Changed-From-To: open->closed 
State-Changed-By: bms 
State-Changed-When: Fri Jun 18 09:31:37 GMT 2004 
State-Changed-Why:  
luigi@ says this behaviour is by design. 

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