From owner-freebsd-hackers Mon Feb 19 11:26:41 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp.nettoll.com (matrix.nettoll.net [212.155.143.61]) by hub.freebsd.org (Postfix) with ESMTP id 2A94537B401 for ; Mon, 19 Feb 2001 11:26:34 -0800 (PST) Received: by smtp.nettoll.com; Mon, 19 Feb 2001 20:25:02 +0100 (MET) Message-Id: <4.3.0.20010219202101.05cf15a0@pop.free.fr> X-Sender: usebsd@pop.free.fr X-Mailer: QUALCOMM Windows Eudora Version 4.3 Date: Mon, 19 Feb 2001 20:26:56 +0100 To: idobarnea@NewMail.Net, hackers@freebsd.org From: mouss Subject: Re: Bug in creating ICMP error messages in FreeBSD4.2 Cc: andrew@cnsec.co.za In-Reply-To: <3a912cee.150.0@NewMail.Net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG At 14:25 19/02/01 +0200, idobarnea@NewMail.Net wrote: >Hi, > I encountered the following problem in the 4.2 version. >In ip_forward, the following lines intend to save the mbuf in case we want to >send ICMP error later: > mcopy = m_copy(m, 0, imin((int)ip->ip_len, 64)); > if (mcopy && (mcopy->m_flags & M_EXT)) > m_copydata(mcopy, 0, sizeof(struct ip), mtod(mcopy, caddr_t)); > >Later on, before sending the ICMP packet we do: > if (mcopy->m_flags & M_EXT) > m_copyback(mcopy, 0, sizeof(struct ip), mtod(mcopy, caddr_t)); > >The problem as I understand it is that the m_copydata and m_copyback, actually >do nothing (It just >copies from mcopy to itself). I'm speaking from memory, so don't take this for more than it is:) As far as I understand: m_copym copies the mbuf, but if there is external storage, only pointers are copied. so you get two mbuf chains with a common external storage. m_copydata will copy the external storage. that's why there are both m_copym and m_copydata. so while m_copydata(mcopy, .... (mcopy...)) is surprising, it's not nothing. it copies the data pointed to in mcopy. cheers, mouss To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message