Date: Tue, 10 Oct 2000 23:21:49 -0400 (EDT) From: Bosko Milekic <bmilekic@dsuper.net> To: Archie Cobbs <archie@whistle.com> Cc: freebsd-net@freebsd.org Subject: Re: ip_input.c patch Message-ID: <Pine.BSF.4.21.0010102314260.9539-100000@jehovah.technokratis.com> In-Reply-To: <200010110114.e9B1E0J40614@bubba.whistle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0010102314260.9539-100000>