From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 23 08:30:35 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 03A0116A4D3 for ; Mon, 23 Feb 2004 08:30:35 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB1E143D2F for ; Mon, 23 Feb 2004 08:30:34 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i1NGUYbv008306 for ; Mon, 23 Feb 2004 08:30:34 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i1NGUYHw008305; Mon, 23 Feb 2004 08:30:34 -0800 (PST) (envelope-from gnats) Date: Mon, 23 Feb 2004 08:30:34 -0800 (PST) Message-Id: <200402231630.i1NGUYHw008305@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Alexander Motin Subject: Re: kern/62957: When created dummynet pipe on output routerinterface with lower MTU system stops to generate 'Fragment Needed but DF was Set' ICMP in cases when it must X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Alexander Motin List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Feb 2004 16:30:35 -0000 The following reply was made to PR kern/62957; it has been noted by GNATS. From: Alexander Motin 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 #include #include +#include #include /* for struct arpcom */ #include @@ -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 #include #include +#include #include /* for struct arpcom */ #include @@ -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--