From owner-freebsd-net Tue Oct 10 20:45:26 2000 Delivered-To: freebsd-net@freebsd.org Received: from field.videotron.net (field.videotron.net [205.151.222.108]) by hub.freebsd.org (Postfix) with ESMTP id F02EC37B502 for ; Tue, 10 Oct 2000 20:45:18 -0700 (PDT) Received: from modemcable213.3-201-24.mtl.mc.videotron.ca ([24.201.3.213]) by field.videotron.net (Sun Internet Mail Server sims.3.5.1999.12.14.10.29.p8) with ESMTP id <0G28008PTX5K83@field.videotron.net> for freebsd-net@freebsd.org; Tue, 10 Oct 2000 23:17:44 -0400 (EDT) Date: Tue, 10 Oct 2000 23:21:49 -0400 (EDT) From: Bosko Milekic Subject: Re: ip_input.c patch In-reply-to: <200010110114.e9B1E0J40614@bubba.whistle.com> X-Sender: bmilekic@jehovah.technokratis.com To: Archie Cobbs Cc: freebsd-net@freebsd.org Message-id: MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Tue, 10 Oct 2000, Archie Cobbs wrote: > I think I'll wait for your diffs. > > Uh oh.. I just thought of a plan.. :-) > > > 1. Add a new macro to make an mbuf writable: > > #define M_MKWRITABLE(m, len) > do { > if ((m)->m_len < (len) > || (((m)->m_flags & M_EXT) != 0 && MEXT_IS_REF(m))) { > (m) = m_pullup((m), (len)); > } > } while (0) This is very similar to what I already have in these diffs (I'll post the old version tomorrow after my exam so that you can beat it up as you like :-) ). The difference is that in the diffs we already have, there is an additional flag added to the mbuf... for various different reasons (this is all archived probably in -net mail archives...) ... It would be cool to revive this this weekend and commit it. I'll do it by upcoming Sunday, because I know also that dwmalone was planning to commit some related stuff following that. I'll keep you and -net posted. > 2. Temporarily change the definition of mtod() as follows: > > BEFORE > ------ > > #define mtod(m, t) ((t)((m)->m_data)) > > AFTER > ----- > > #define mtod(m, t) ((const t)((m)->m_data)) > > 3. Compile LINT and find and fix every place that generates > an error from the const-cast in mtod(): > > (A) If the code doesn't need to modify the mbuf (probably > 99% of the time), then change it like so: > > BEFORE > ------ > struct ip *ip; > ip = mtod(m, struct ip *); > > AFTER > ------ > const struct ip *ip; > ip = mtod(m, struct ip *); > > (B) If the code does modify the mbuf, insert M_MKWRITABLE() > at the appropriate point. > > 4. Put mtod() back the way it was > > -Archie That's a pretty clever way of catching potentially problematic areas... let me finish this one last test tomorrow and I'll post another followup with more information regarding this diff I keep talking about (which I'll fish out of the attic then). :-) > ___________________________________________________________________________ > Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com Cheers, Bosko Milekic bmilekic@technokratis.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message