From owner-freebsd-net@FreeBSD.ORG Sat Apr 9 13:30:48 2005 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 84D3716A4CE; Sat, 9 Apr 2005 13:30:48 +0000 (GMT) Received: from mail-relay1.yahoo.com (mail-relay1.yahoo.com [216.145.48.34]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3B57543D2D; Sat, 9 Apr 2005 13:30:48 +0000 (GMT) (envelope-from gnn@neville-neil.com) Received: from minion.local.neville-neil.com (proxy7.corp.yahoo.com [216.145.48.98])j39DUjF1016125; Sat, 9 Apr 2005 06:30:46 -0700 (PDT) Date: Sat, 09 Apr 2005 22:30:45 +0900 Message-ID: From: gnn@freebsd.org To: snap-users@kame.net User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3.50 (powerpc-apple-darwin7.7.0) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII cc: freebsd-net@freebsd.org cc: rwatson@freebsd.org cc: sam Subject: Please review this diff... X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Apr 2005 13:30:48 -0000 Hi, I would like to check in the following diff against FreeBSD-CURRENT and to get feedback from the Kame folks on the general usefulness of these fixes. All changes are against icmp6.c. The first part of the diff removes dead code as I suspect MCLBYTES, the size of a cluster, will never be less than 48, which is the size of maxlen set above those lines. The second part checks for error returns from the duplication of the packets before starting to copy things around. Thanks, George Index: icmp6.c =================================================================== RCS file: /Volumes/exported/FreeBSD-CVS/src/sys/netinet6/icmp6.c,v retrieving revision 1.60 diff -u -r1.60 icmp6.c --- icmp6.c 2 Mar 2005 05:14:15 -0000 1.60 +++ icmp6.c 7 Apr 2005 15:26:28 -0000 @@ -524,15 +524,6 @@ const int maxlen = sizeof(*nip6) + sizeof(*nicmp6); int n0len; - /* - * Prepare an internal mbuf. m_pullup() doesn't - * always copy the length we specified. - */ - if (maxlen >= MCLBYTES) { - /* Give up remote */ - m_freem(n0); - break; - } MGETHDR(n, M_DONTWAIT, n0->m_type); n0len = n0->m_pkthdr.len; /* save for use below */ if (n) @@ -1943,9 +1934,14 @@ m->m_len <= MHLEN) { MGET(n, M_DONTWAIT, m->m_type); if (n != NULL) { - m_dup_pkthdr(n, m, M_NOWAIT); - bcopy(m->m_data, n->m_data, m->m_len); - n->m_len = m->m_len; + if (m_dup_pkthdr(n, m, M_NOWAIT)) { + bcopy(m->m_data, n->m_data, + m->m_len); + n->m_len = m->m_len; + } else { + m_free(n); + n = NULL; + } } } if (n != NULL || @@ -1983,12 +1979,16 @@ MGET(n, M_DONTWAIT, m->m_type); if (n != NULL) { - m_dup_pkthdr(n, m, M_NOWAIT); - bcopy(m->m_data, n->m_data, m->m_len); - n->m_len = m->m_len; - - m_freem(m); - m = n; + if (m_dup_pkthdr(n, m, M_NOWAIT)) { + bcopy(m->m_data, n->m_data, m->m_len); + n->m_len = m->m_len; + + m_freem(m); + m = n; + } else { + m_freem(n); + n = NULL; + } } } if (sbappendaddr(&last->in6p_socket->so_rcv,