From owner-freebsd-hackers Mon Feb 19 23:31: 7 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id B4BCD37B4EC for ; Mon, 19 Feb 2001 23:31:00 -0800 (PST) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.0/8.11.0) id f1K7SIl25543; Tue, 20 Feb 2001 09:28:18 +0200 (EET) (envelope-from ru) Date: Tue, 20 Feb 2001 09:28:18 +0200 From: Ruslan Ermilov To: mouss Cc: idobarnea@NewMail.Net, hackers@FreeBSD.ORG, andrew@cnsec.co.za Subject: Re: Bug in creating ICMP error messages in FreeBSD4.2 Message-ID: <20010220092818.A25414@sunbay.com> Mail-Followup-To: mouss , idobarnea@NewMail.Net, hackers@FreeBSD.ORG, andrew@cnsec.co.za References: <3a912cee.150.0@NewMail.Net> <4.3.0.20010219202101.05cf15a0@pop.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <4.3.0.20010219202101.05cf15a0@pop.free.fr>; from usebsd@free.fr on Mon, Feb 19, 2001 at 08:26:56PM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Feb 19, 2001 at 08:26:56PM +0100, mouss wrote: > 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. > I wrote this code, and the above said is right. -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message